Exemple #1
0
        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");
            }
        }
Exemple #2
0
 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;
     }
 }