-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The projects were upgraded to .Net 6.
Added UserController and CRUD users.
- Loading branch information
armanab
committed
May 31, 2023
1 parent
2d9f8b7
commit 506af30
Showing
7 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ication.Application.IntegrationTests/CleanApplication.Application.IntegrationTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters