コード例 #1
0
        public ActionResult DeleteMealPost(long Id)
        {
            var db = new CaloriesDataContext();
            var Meal = db.Meals.Find(Id);
            db.Meals.Remove(Meal);
            db.SaveChanges();

            return RedirectToAction("Index");
        }
コード例 #2
0
        public ActionResult Create(Models.sidedishs Side)
        {
            if (ModelState.IsValid)
            {
                var db = new CaloriesDataContext();
                db.Sides.Add(Side);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        public ActionResult MealEditPost(long Id)
        {
            var db = new CaloriesDataContext();
            var Meal = db.Meals.Find(Id);
            UpdateModel(Meal);
            db.SaveChanges();

            return RedirectToAction("Index");
        }