public IHttpActionResult Put(int id, [FromBody] UserViewModel user) { try { //var outDatedUser = UserMapper.DTOtoVMUser(service.GetUserByID(id)); if (ModelState.IsValid) { user.UserID = user.UserID == 0 ? id : user.UserID; var newUserDTO = UserMapper.VMtoDTOUser(user); user = UserMapper.DTOtoVMUser(service.EditUser(newUserDTO)); return(Content(HttpStatusCode.OK, user)); } else { return(Content(HttpStatusCode.BadRequest, GetModelStateErrors(ModelState))); } } catch (UserAlreadyExistsException e) { ModelState.AddModelError("", e.Message); return(Content(HttpStatusCode.BadRequest, GetModelStateErrors(ModelState))); } catch (UserDoesNotExistException e) { ModelState.AddModelError("", e.Message); return(Content(HttpStatusCode.NotFound, GetModelStateErrors(ModelState))); } catch (Exception e /* dex */) { ModelState.AddModelError("", e.Message); return(Content(HttpStatusCode.InternalServerError, GetModelStateErrors(ModelState))); } }