public HttpResponseMessage Post(FoodBook c1) { try { db.FoodBooks.Add(c1); db.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage Put(int id, FoodBook c1) { try { if (id == c1.FBookid) { db.Entry(c1).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage Delete(int id) { try { FoodBook c1 = db.FoodBooks.Find(id); if (c1 != null) { db.FoodBooks.Remove(c1); db.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }