public void RegisterUser(RegisterUserAccountDto model) { var validationResults = model.Validate(new ValidationContext(model)); foreach (var validationResult in validationResults) { _modelState = new ModelStateDictionary(); var message = validationResult.ErrorMessage; var members = validationResult.MemberNames; // TODO Verify that this will work. I don't think this may be the correct key to be passing to this object _modelState.AddModelError(members.ToString(), message); } if (!_modelState.IsValid) { throw new ApiException(_modelState.Values); } var newUserAccount = new UserAccount { Email = model.Email, Username = model.Username, PasswordHash = model.Password.GetHashCode().ToString() //TODO Implement Actual Hasher }; _unitOfWork.UserAccounts.Add(newUserAccount); }
public ActionResult <UserAccount> PostUserAccount(RegisterUserAccountDto registerUserAccountDto) { if (!ModelState.IsValid) { throw new ApiException(ModelState.AllErrors()); } var userAccountGuid = Guid.NewGuid(); var userAccount = new UserAccount { //Guid = userAccountGuid, Email = registerUserAccountDto.Email, PasswordHash = registerUserAccountDto.Password.GetHashCode().ToString() // TODO Add Actual Hashing Algorithm }; _userAccountRepository.Add(userAccount); _unitOfWork.Commit(); return(CreatedAtAction("GetUserAccount", new { id = userAccountGuid }, userAccount)); }