public void UpdateUser(int id, UserProfileUpdateForm data) { User user = context.Users.Find(id); if (user == null) { throw new ObjectNotFoundException("User with specified ID not found"); } user.Email = data.Email; user.Password = data.Password; user.UserType = context.UserTypes.Find(data.UserType); context.SaveChanges(); }
public IHttpActionResult UpdateUser([FromBody] UserProfileUpdateForm data, int id) { if (!user_service.IsAuthorizedToEditUesrProfile(id)) { return(Unauthorized()); } if (RequestUtility.IsPreFlightRequest(Request)) { return(Ok()); } try{ user_repository.UpdateUser(id, data); return(Ok()); } catch (ObjectNotFoundException e) { return(NotFound()); } }