// PUT: odata/Users(5) public IHttpActionResult Put([FromODataUri] Guid key, Delta <User> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } User user = db.Users.Find(key); if (user == null) { return(NotFound()); } patch.Put(user); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(key)) { return(NotFound()); } else { throw; } } return(Updated(user)); }
public bool Post(User user) { DB.Users.Add(user); return(DB.SaveChanges() > 0); }