Ejemplo n.º 1
0
        public void EditFood(FoodViewModel food)
        {
            var query = db.Food.Where(x => x.id == food.id).First();

            query.name = food.name;
            query.calories = food.calories;
            query.categoryId = food.categoryId;
            db.SaveChanges();
        }
Ejemplo n.º 2
0
 public ActionResult EditFood(FoodViewModel food)
 {
     if (ModelState.IsValid)
     {
         foodModel.EditFood(food);
     }
     ViewBag.Categories = categoryModel.Categories();
     return RedirectToAction("Index", "Food");
 }
Ejemplo n.º 3
0
        public void AddFood(FoodViewModel food)
        {
            Food newFood = new Food()
            {
                name = food.name,
                calories = food.calories,
                categoryId = food.categoryId
            };

            db.Food.Add(newFood);
            db.SaveChanges();
        }