Exemple #1
0
 public static User CommandToDomain(AthenticationUserCommand command, string context)
 {
     return(new User
     {
         Context = context,
         UserName = command.Name,
         Email = command.Email,
         PasswordHash = command.Password,
         FullName = command.FullName
     });
 }
Exemple #2
0
        public async Task <IActionResult> Register([FromBody] AthenticationUserCommand command)
        {
            try
            {
                var user   = UserAdapter.CommandToDomain(command, command.Context);
                var result = await _userManager.CreateAsync(user, user.PasswordHash);

                if (result.Succeeded)
                {
                    return(Created("GetUser", command));
                }
                return(BadRequest(result.Errors));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }