public IHttpActionResult Put(string id, [FromBody] User user) { if (string.IsNullOrEmpty(id) || !userModel.UserExist(id)) { return(NotFound()); } if (userModel.UpdateUser(id, AutoMapper.Mapper.Map <Objects.User>(user))) { user.Password = null; return(Content(HttpStatusCode.Accepted, user)); } else { return(InternalServerError()); } }
public IActionResult UpdateUser([FromBody] Users user) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } bool status = UserModal.UpdateUser(user); if (status) { return(Ok()); } else { return(NotFound()); } } catch (Exception ex) { return(BadRequest(ex)); } }