public NewUserResponseDto Register(NewUserDto newUserDto) { try { string hashedPassword = _hasher.HashPassword(newUserDto.Password); newUserDto.Password = hashedPassword; User user = _newUserAssembler.ToEntity(newUserDto); _userRepository.SaveOrUpdate(user); Customer customer = new Customer(); customer.FirstName = newUserDto.FirstName; customer.LastName = newUserDto.LastName; customer.CreatedAt = DateTime.UtcNow; customer.IdentityDocument = newUserDto.Document; customer.User = user.Id; customer.Active = true; _newCustomerRepository.SaveOrUpdate(customer); return(new NewUserResponseDto { HttpStatusCode = StatusCodes.Status201Created, Response = new ApiStringResponse(UserAppConstants.UserCreated) }); } catch (Exception ex) { //TODO: Log exception async, for now write exception in the console Console.WriteLine(ex.Message); return(new NewUserResponseDto { HttpStatusCode = StatusCodes.Status500InternalServerError, Response = new ApiStringResponse(ApiConstants.InternalServerError) }); } }
public NewUserResponseDto Register(NewUserDto newUserDto) { try { string hashedPassword = _hasher.HashPassword(newUserDto.Password); newUserDto.Password = hashedPassword; User user = _newUserAssembler.ToEntity(newUserDto); _userRepository.SaveOrUpdate(user); return(new NewUserResponseDto { HttpStatusCode = StatusCodes.Status201Created, Response = new ApiStringResponse(UserAppConstants.UserCreated) }); } catch (Exception ex) { //TODO: Log exception async, for now write exception in the console Console.WriteLine(ex.Message); return(new NewUserResponseDto { HttpStatusCode = StatusCodes.Status500InternalServerError, Response = new ApiStringResponse(ApiConstants.InternalServerError) }); } }