Exemplo n.º 1
0
 public void RemoveFood(int id)
 {
     using (FoodDBEntities ResEntities = new FoodDBEntities())
     {
         ResEntities.Foods.Remove(ResEntities.Foods.FirstOrDefault(fo => fo.ID == id));
         ResEntities.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void AddFood(Food f)
 {
     using (FoodDBEntities ResEntities = new FoodDBEntities())
     {
         ResEntities.Foods.Add(f);
         ResEntities.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public void UpdateFood(Food f)
        {
            Food food = new Food();

            using (FoodDBEntities ResEntities = new FoodDBEntities())
            {
                food             = ResEntities.Foods.FirstOrDefault(fo => fo.ID == f.ID);
                food.Name        = f.Name;
                food.Ingridients = f.Ingridients;
                food.Calories    = f.Calories;
                food.Grade       = f.Grade;
                ResEntities.SaveChanges();
            }
        }