Esempio n. 1
0
 public void AddFood(Food food)
 {
     using (FoodDBEntities foodEntites = new FoodDBEntities())
     {
         foodEntites.Foods.Add(food);
         foodEntites.SaveChanges();
     }
 }
Esempio n. 2
0
        public Food DeleteFood(int id)
        {
            Food Delete;

            using (FoodDBEntities foodEntites = new FoodDBEntities())
            {
                Delete = foodEntites.Foods.FirstOrDefault(f => f.ID == id);
                foodEntites.Foods.Remove(Delete);
                foodEntites.SaveChanges();
            }
            return(Delete);
        }
Esempio n. 3
0
        public Food UpdateFood(int id, Food food)
        {
            Food Update = new Food();

            using (FoodDBEntities foodEntites = new FoodDBEntities())
            {
                Update             = foodEntites.Foods.FirstOrDefault(f => f.ID == id);
                Update.Name        = food.Name;
                Update.Calories    = food.Calories;
                Update.Ingridients = food.Ingridients;
                Update.Grade       = food.Grade;
                foodEntites.SaveChanges();
            }
            return(Update);
        }