Exemplo n.º 1
0
 public IHttpActionResult AddNewUser([FromBody] User user)
 {
     if (user.UserName == null || user.UserId != 0)
     {
         return(BadRequest("A userName must be supplied and the supplied UserId must be empty or 0. "));
     }
     _logger.Info($"User Controller recieved request to create a new user: {user.UserName}");
     try
     {
         var existingUser = _facade.GetUser(user);
         if (existingUser != null)
         {
             return(Conflict());
         }
         _facade.AddUser(user);
         return(Ok("User successfully created. "));
     }
     catch (DbUpdateException ex)
     {
         _logger.Error(ex);
         return(BadRequest("Invalid Request. "));
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         return(InternalServerError());
     }
 }
Exemplo n.º 2
0
        public IHttpActionResult AddUsers([FromBody] UserModel userModel)
        {
            var userCode = _userFacade.AddUser(Mapper.Map <UserDTO>(userModel));

            return(Ok(userCode));
        }