コード例 #1
0
 public List <Dish> GetAll()
 {
     using (var context = new LunchDbContext())
     {
         return(context.Dishes.ToList());
     }
 }
コード例 #2
0
 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));
     }
 }
コード例 #4
0
 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();
     }
 }
コード例 #6
0
 public void CreateDish(Dish dish)
 {
     using (var context = new LunchDbContext())
     {
         context.Dishes.Add(dish);
         context.SaveChanges();
     }
 }
コード例 #7
0
        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);
        }
コード例 #9
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();
     }
 }
コード例 #10
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;
     }
 }
コード例 #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();
     }
 }
コード例 #14
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();
     }
 }