예제 #1
0
 public User(UserSignupDto credentials)
 {
     Name     = credentials.Name;
     Login    = credentials.Login;
     Surname  = credentials.Surname;
     Password = credentials.Password;
 }
 public async Task <IActionResult> Signup([FromBody] UserSignupDto credentials)
 {
     if (!ModelState.IsValid)
     {
         return(new BadRequestObjectResult(ModelState.Values.Select(value => value.Errors.FirstOrDefault()).FirstOrDefault()?.ErrorMessage));
     }
     try
     {
         return(new OkObjectResult(await _authentication.Signup(new User(credentials))));
     }
     catch (ArgumentException ex)
     {
         return(new BadRequestObjectResult(ex.Message));
     }
 }