Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CleanAspNetCoreWebApi/src/Web.Api/Controllers/AccountsController.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34 lines (31 sloc)
1.25 KB
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
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) | |
{ // re-render the view when validation failed. | |
return BadRequest(ModelState); | |
} | |
await _registerUserUseCase.Handle(new RegisterUserRequest(request.FirstName,request.LastName,request.Email, request.UserName,request.Password), _registerUserPresenter); | |
return _registerUserPresenter.ContentResult; | |
} | |
} | |
} |