public ActionResult DeleteMealPost(long Id) { var db = new CaloriesDataContext(); var Meal = db.Meals.Find(Id); db.Meals.Remove(Meal); db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Create(Models.sidedishs Side) { if (ModelState.IsValid) { var db = new CaloriesDataContext(); db.Sides.Add(Side); db.SaveChanges(); return RedirectToAction("Index"); } return View(); }
public ActionResult Create(Models.calcount caloriez) { var categoryList = new SelectList(new[] { "Breakfast", "Lunch", "Dinner", "Snack" }); ViewBag.CategoryList = categoryList; if (ModelState.IsValid) { var db = new CaloriesDataContext(); db.Meals.Add(caloriez); db.SaveChanges(); return RedirectToAction("Index"); } return View(); }
public ActionResult MealEditPost(long Id) { var db = new CaloriesDataContext(); var Meal = db.Meals.Find(Id); UpdateModel(Meal); db.SaveChanges(); return RedirectToAction("Index"); }