예제 #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();
     }
 }
예제 #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);
     }
 }
예제 #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;
        }
예제 #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;
     }
 }
예제 #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());
     }
 }
예제 #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);
     }
 }
예제 #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();
     }
 }