Skip to content

Commit

Permalink
The projects were upgraded to .Net 6.
Browse files Browse the repository at this point in the history
Added  UserController and CRUD users.
  • Loading branch information
armanab committed May 31, 2023
1 parent 2d9f8b7 commit 506af30
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 6 deletions.
52 changes: 52 additions & 0 deletions src/Apps/WebApi/Controllers/UserController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using CleanApplication.Application.Common.Models;
using CleanApplication.Application.Dto;
using CleanApplication.Application.Users.Commands.Delete;
using CleanApplication.Application.Users.Commands.Update;
using CleanApplication.Application.Users.Queries.GetUserById;
using CleanApplication.Application.Users.Queries.GetUsersAdmin;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;

namespace CleanApplication.WebApi.Controllers
{
[Authorize]
public class UserController : ApiControllerBase
{
[HttpGet]
public async Task<ActionResult<ServiceResult<PaginatedList<ApplicationUserDto>>>> Get([FromQuery] GetUsersQuery query)
{
return Ok(await Mediator.Send(query));
}
[HttpGet("{id}")]
public async Task<ActionResult<ServiceResult<ApplicationUserDto>>> GetById(Guid id)
{
return await Mediator.Send(new GetUserByIdQuery { Id = id });
}

//[HttpPost]
//public async Task<ActionResult<ServiceResult<UserCreateAdminDto>>> Create(CreateUserCommand command)
//{
// return await Mediator.Send(command);
//}

[HttpPut("{id}")]
public async Task<ActionResult<ServiceResult<ApplicationUserDto>>> Update(Guid id, UpdateUserCommand command)
{
if (id != command.Id)
{
return Ok(ServiceResult.Failed(ServiceError.InvalidId));
}

return Ok(await Mediator.Send(command));
}

[HttpDelete("{id}")]
public async Task<ActionResult<ServiceResult<bool>>> Delete(Guid id)
{
return await Mediator.Send(new DeleteUserCommand { Id = id });

}
}
}
2 changes: 1 addition & 1 deletion src/Apps/WebApi/WebApi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>CleanApplication.WebApi</RootNamespace>
<AssemblyName>CleanApplication.WebApi</AssemblyName>
<UserSecretsId>aspnet-WebApi-58672EB4-2691-4613-ACE7-B3CD6A008334</UserSecretsId>
Expand Down
2 changes: 1 addition & 1 deletion src/Apps/WebApi/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"UseInMemoryDatabase": false,
"UseInMemoryDatabase": true,
"ConnectionStrings": {
"DefaultConnection": "Server=.; Database=CleanApplicationTemp; User Id=sa; Password=sa; MultipleActiveResultSets=true"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Application/Application.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>CleanApplication.Application</RootNamespace>
<AssemblyName>CleanApplication.Application</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Domain/Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>CleanApplication.Domain</RootNamespace>
<AssemblyName>CleanApplication.Domain</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>CleanApplication.Infrastructure</RootNamespace>
<AssemblyName>CleanApplication.Infrastructure</AssemblyName>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down

0 comments on commit 506af30

Please sign in to comment.