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