예제 #1
0
 public ActionResult DeleteConfirmed(int id)
 {
     Food.Models.Food food = db.Foods.Find(id);
     db.Foods.Remove(food);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #2
0
 public ActionResult Edit([Bind(Include = "Id,Name,Type")] Food.Models.Food food)
 {
     if (ModelState.IsValid)
     {
         db.Entry(food).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(food));
 }
예제 #3
0
        public ActionResult Create([Bind(Include = "Id,Name,Type")] Food.Models.Food food)
        {
            if (ModelState.IsValid)
            {
                db.Foods.Add(food);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(food));
        }
예제 #4
0
 // GET: Foods/Delete/5
 public ActionResult Delete(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Food.Models.Food food = db.Foods.Find(id);
     if (food == null)
     {
         return(HttpNotFound());
     }
     return(View(food));
 }