public object POST(AddUser Request) { var user = Request.NewUser; UserValidations obj = new UserValidations(); ValidationResult result = obj.Validate(user); if (result.IsValid) { try { var newUser = _userBll.RegisterUser(user); if (newUser == null) { return(null); } else { return(newUser); } } catch (Exception e) { // _logger.Error("Exception Thrown", e); throw e; } } else { return("Error"); } }
public async Task <ActionResult <User> > RegisterUser([FromBody] User user) { try { var newUser = _userBll.RegisterUser(_automapper.UserToDto(user)); if (newUser == null) { return(BadRequest()); } else { var createdUser = _automapper.UserDtoToUser(newUser); return(CreatedAtAction(nameof(AuthenticateUser), new { email = user.Email }, createdUser)); } } catch (Exception e) { _logger.Error("Exception Thrown", e); throw; } }