Beispiel #1
0
        public int Create(Order order)
        {
            _context.AttachRange(order.Items.Select(l => l.DishAvail));
            var newOrder = _context.Orders.Add(order);

            _context.SaveChanges();

            foreach (var orderItem in order.Items)
            {
                orderItem.DishAvail.Quantity -= orderItem.Quantity;
                _dishAvailabilityRepository.Update(orderItem.DishAvail);
            }

            return(newOrder.Entity.Id);
        }