Esempio n. 1
0
        public FridgeFood Update(FridgeFood FridgeFoodChanges)
        {
            var ff = context.FridgeFoods.Attach(FridgeFoodChanges);

            ff.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(FridgeFoodChanges);
        }
Esempio n. 2
0
        public FridgeFood Delete(int id)
        {
            FridgeFood ff = _fridgeFoodList.FirstOrDefault(f => f.ID == id);

            if (ff != null)
            {
                _fridgeFoodList.Remove(ff);
            }
            return(ff);
        }
Esempio n. 3
0
        public FridgeFood Update(FridgeFood fridgeFoodChanges)
        {
            FridgeFood OldFF = GetFridgeFood(fridgeFoodChanges.ID);

            OldFF.Name        = fridgeFoodChanges.Name;
            OldFF.BestBefore  = fridgeFoodChanges.BestBefore;
            OldFF.Category    = fridgeFoodChanges.Category;
            OldFF.Unit        = fridgeFoodChanges.Unit;
            OldFF.Measurement = fridgeFoodChanges.Measurement;
            return(fridgeFoodChanges);
        }
Esempio n. 4
0
        public FridgeFood Delete(int id)
        {
            FridgeFood ff = context.FridgeFoods.Find(id);

            if (ff != null)
            {
                context.FridgeFoods.Remove(ff);
                context.SaveChanges();
            }
            return(ff);
        }
Esempio n. 5
0
 public FridgeFood Add(FridgeFood fridgeFood)
 {
     fridgeFood.ID = _fridgeFoodList.Max(ff => ff.ID) + 1;
     _fridgeFoodList.Add(fridgeFood);
     return(fridgeFood);
 }
Esempio n. 6
0
 public FridgeFood Add(FridgeFood fridgeFood)
 {
     context.FridgeFoods.Add(fridgeFood);
     context.SaveChanges();
     return(fridgeFood);
 }