|
|
|
@@ -1,5 +1,4 @@ |
|
|
|
using BlackRock.Reporting.API.Controllers.Model; |
|
|
|
using BlackRock.Reporting.API.Jwt.Filters; |
|
|
|
using BlackRock.Reporting.API.Mediator.UserMediator.Commands; |
|
|
|
using BlackRock.Reporting.API.Mediator.UserMediator.Queries; |
|
|
|
using MediatR; |
|
|
|
@@ -8,9 +7,8 @@ using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
|
|
namespace BlackRock.Reporting.API.Controllers |
|
|
|
{ |
|
|
|
//[Route("api/users")] |
|
|
|
[Authorize] |
|
|
|
//[JwtAuthentication] |
|
|
|
[Route("api/users")] |
|
|
|
public class UsersController : Controller |
|
|
|
{ |
|
|
|
private readonly IMediator mediator; |
|
|
|
@@ -22,7 +20,7 @@ namespace BlackRock.Reporting.API.Controllers |
|
|
|
|
|
|
|
// GET: api/users/1 |
|
|
|
[HttpGet] |
|
|
|
[Route("api/users/{id}")] |
|
|
|
[Route("{id}")] |
|
|
|
public async Task<IActionResult> GetUser(int id) |
|
|
|
{ |
|
|
|
var result = await mediator.Send(new GetUserQuery { Id = id }); |
|
|
|
@@ -36,7 +34,6 @@ namespace BlackRock.Reporting.API.Controllers |
|
|
|
} |
|
|
|
// GET: api/users?Page=2&PageSize=25 |
|
|
|
[HttpGet] |
|
|
|
[Route("api/users")] |
|
|
|
public async Task<IActionResult> GetAllUsers(GetAllUsersQuery query) |
|
|
|
{ |
|
|
|
var result = await mediator.Send(query); |
|
|
|
@@ -52,7 +49,6 @@ namespace BlackRock.Reporting.API.Controllers |
|
|
|
} |
|
|
|
// POST: api/users |
|
|
|
[HttpPost] |
|
|
|
[Route("api/users")] |
|
|
|
public async Task<IActionResult> CreateUser([FromBody] CreateUserCommand user) |
|
|
|
{ |
|
|
|
if (!ModelState.IsValid) |
|
|
|
@@ -68,7 +64,7 @@ namespace BlackRock.Reporting.API.Controllers |
|
|
|
} |
|
|
|
// PUT: api/users/1 |
|
|
|
[HttpPut] |
|
|
|
[Route("api/users/{id}")] |
|
|
|
[Route("{id}")] |
|
|
|
public async Task<IActionResult> UpdateUser(int id, [FromBody] UpdateUserCommand user) |
|
|
|
{ |
|
|
|
if (!ModelState.IsValid) |
|
|
|
@@ -82,7 +78,7 @@ namespace BlackRock.Reporting.API.Controllers |
|
|
|
} |
|
|
|
// PATCH: api/users/1/email |
|
|
|
[HttpPatch] |
|
|
|
[Route("api/users/{id}/email")] |
|
|
|
[Route("{id}/email")] |
|
|
|
public async Task<IActionResult> UpdateUserEmail(int id, [FromBody] UpdateUserEmailCommand user) |
|
|
|
{ |
|
|
|
if (!ModelState.IsValid) |
|
|
|
@@ -97,7 +93,7 @@ namespace BlackRock.Reporting.API.Controllers |
|
|
|
} |
|
|
|
// DELETE: api/users/1 |
|
|
|
[HttpDelete] |
|
|
|
[Route("api/users/{id}")] |
|
|
|
[Route("{id}")] |
|
|
|
public async Task<IActionResult> DeleteUser(int id) |
|
|
|
{ |
|
|
|
if (!ModelState.IsValid) |