Esempio n. 1
0
 public List <Dish> GetAll()
 {
     using (var context = new LunchDbContext())
     {
         return(context.Dishes.ToList());
     }
 }
 public List<Dish> GetAll()
 {
     using (var context = new LunchDbContext())
     {
         return context.Dishes.ToList();
     }
 }
Esempio n. 3
0
 public Dish GetById(int id)
 {
     using (var context = new LunchDbContext())
     {
         return(context.Dishes.FirstOrDefault(d => d.Id == id));
     }
 }
 public Dish GetById(int id)
 {
     using (var context = new LunchDbContext())
     {
         return context.Dishes.FirstOrDefault(d => d.Id == id);
     }
 }
Esempio n. 5
0
 public void CreateDish(Dish dish)
 {
     using (var context = new LunchDbContext())
     {
         context.Dishes.Add(dish);
         context.SaveChanges();
     }
 }
 public void CreateDish(Dish dish)
 {
     using (var context = new LunchDbContext())
     {
         context.Dishes.Add(dish);
         context.SaveChanges();
     }
 }
        public int Save(Order order)
        {
            using (var context = new LunchDbContext())
            {
                context.Orders.Add(order);
                context.SaveChanges();
            }

            return order.Id;
        }
Esempio n. 8
0
        public int Save(Order order)
        {
            using (var context = new LunchDbContext())
            {
                context.Orders.Add(order);
                context.SaveChanges();
            }

            return(order.Id);
        }
 public List<Order> GetPendingOrders()
 {
     using (var context = new LunchDbContext())
     {
         return context.Orders
             .Include(o => o.OrderDetails)
             .Include(o => o.OrderDetails.Select(d => d.Dish))
             .Where(o => !o.IsServed)
             .ToList();
     }
 }
 public Order GetById(int id)
 {
     using (var context = new LunchDbContext())
     {
         var firstOrDefault = context.Orders
             .Include(o => o.OrderDetails)
             .Include(o => o.OrderDetails.Select(d => d.Dish))
             .FirstOrDefault(o => o.Id == id);
         return firstOrDefault;
     }
 }
Esempio n. 11
0
 public List <Order> GetPendingOrders()
 {
     using (var context = new LunchDbContext())
     {
         return(context.Orders
                .Include(o => o.OrderDetails)
                .Include(o => o.OrderDetails.Select(d => d.Dish))
                .Where(o => !o.IsServed)
                .ToList());
     }
 }
Esempio n. 12
0
 public Order GetById(int id)
 {
     using (var context = new LunchDbContext())
     {
         var firstOrDefault = context.Orders
                              .Include(o => o.OrderDetails)
                              .Include(o => o.OrderDetails.Select(d => d.Dish))
                              .FirstOrDefault(o => o.Id == id);
         return(firstOrDefault);
     }
 }
Esempio n. 13
0
 public void UpdateDish(Dish dish)
 {
     using (var context = new LunchDbContext())
     {
         var original = context.Dishes.Find(dish.Id);
         if (original == null)
         {
             throw new InvalidOperationException();
         }
         context.Entry(original).CurrentValues.SetValues(dish);
         context.SaveChanges();
     }
 }
 public void UpdateDish(Dish dish)
 {
     using (var context = new LunchDbContext())
     {
         var original = context.Dishes.Find(dish.Id);
         if (original == null)
         {
             throw new InvalidOperationException();
         }
         context.Entry(original).CurrentValues.SetValues(dish);
         context.SaveChanges();
     }
 }