public ActionResult DeleteConfirmed(int id) { NiceFood niceFood = db.NiceFoods.Find(id); db.NiceFoods.Remove(niceFood); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,ImageUrl,Title,HeadContent,CreateDate,BlogContent")] NiceFood niceFood) { if (ModelState.IsValid) { db.Entry(niceFood).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(niceFood)); }
public ActionResult Create([Bind(Include = "Id,ImageUrl,Title,HeadContent,CreateDate,BlogContent")] NiceFood niceFood) { if (ModelState.IsValid) { niceFood.CreateDate = System.DateTime.Now; db.NiceFoods.Add(niceFood); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(niceFood)); }
// GET: ManageNiceFoods/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NiceFood niceFood = db.NiceFoods.Find(id); if (niceFood == null) { return(HttpNotFound()); } return(View(niceFood)); }
public ActionResult Details(int?id) { using (var db = new ShopOnlineDb()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NiceFood nicefood = db.NiceFoods.FirstOrDefault(x => x.Id == id); if (nicefood == null) { return(HttpNotFound()); } return(View(nicefood)); } }