Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (24 sloc) 1.02 KB
using System.Linq;
using System.Threading.Tasks;
using Web.Api.Core.Dto.UseCaseRequests;
using Web.Api.Core.Dto.UseCaseResponses;
using Web.Api.Core.Interfaces;
using Web.Api.Core.Interfaces.Gateways.Repositories;
using Web.Api.Core.Interfaces.UseCases;
namespace Web.Api.Core.UseCases
{
public sealed class RegisterUserUseCase : IRegisterUserUseCase
{
private readonly IUserRepository _userRepository;
public RegisterUserUseCase(IUserRepository userRepository)
{
_userRepository = userRepository;
}
public async Task<bool> Handle(RegisterUserRequest message, IOutputPort<RegisterUserResponse> outputPort)
{
var response = await _userRepository.Create(message.FirstName, message.LastName,message.Email, message.UserName, message.Password);
outputPort.Handle(response.Success ? new RegisterUserResponse(response.Id, true) : new RegisterUserResponse(response.Errors.Select(e => e.Description)));
return response.Success;
}
}
}