Presentation 2
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using AipsCore.Application.Abstract;
|
||||
using AipsCore.Application.Models.User.Command.CreateUser;
|
||||
using AipsCore.Domain.Common.Validation;
|
||||
using AipsCore.Domain.Models.User.ValueObjects;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -12,8 +13,14 @@ public class UserController : ControllerBase
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<int>> CreateUser(CreateUserCommand command, IDispatcher dispatcher, CancellationToken cancellationToken)
|
||||
{
|
||||
var userId = await dispatcher.Execute<UserId>(command, cancellationToken);
|
||||
|
||||
return Ok(userId.IdValue);
|
||||
try
|
||||
{
|
||||
var userId = await dispatcher.Execute(command, cancellationToken);
|
||||
return Ok(userId.IdValue);
|
||||
}
|
||||
catch (ValidationException validationException)
|
||||
{
|
||||
return BadRequest(validationException.ValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user