public IHttpActionResult PutBestFriends(int id, BestFriends bestFriends) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bestFriends.FriendID) { return(BadRequest()); } db.Entry(bestFriends).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BestFriendsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetBestFriends(int id) { BestFriends bestFriends = db.BestFriends.Find(id); if (bestFriends == null) { return(NotFound()); } return(Ok(bestFriends)); }
public IHttpActionResult PostBestFriends(BestFriends bestFriends) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BestFriends.Add(bestFriends); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = bestFriends.FriendID }, bestFriends)); }
public IHttpActionResult DeleteBestFriends(int id) { BestFriends bestFriends = db.BestFriends.Find(id); if (bestFriends == null) { return(NotFound()); } db.BestFriends.Remove(bestFriends); db.SaveChanges(); return(Ok(bestFriends)); }