Permalink
Switch branches/tags
Nothing to show
Find file Copy path
ab1aa9b Oct 25, 2018
1 contributor

Users who have contributed to this file

35 lines (31 sloc) 1.21 KB
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Web.Api.Core.Dto.UseCaseRequests;
using Web.Api.Core.Interfaces.UseCases;
using Web.Api.Presenters;
namespace Web.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class AccountsController : ControllerBase
{
private readonly IRegisterUserUseCase _registerUserUseCase;
private readonly RegisterUserPresenter _registerUserPresenter;
public AccountsController(IRegisterUserUseCase registerUserUseCase, RegisterUserPresenter registerUserPresenter)
{
_registerUserUseCase = registerUserUseCase;
_registerUserPresenter = registerUserPresenter;
}
// POST api/accounts
[HttpPost]
public async Task<ActionResult> Post([FromBody] Models.Request.RegisterUserRequest request)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
await _registerUserUseCase.Handle(new RegisterUserRequest(request.FirstName, request.LastName, request.Email, request.UserName, request.Password), _registerUserPresenter);
return _registerUserPresenter.ContentResult;
}
}
}