예제 #1
0
        public List <OrderMerchandise> ComplementMerchandiseList(List <OrderMerchandise> merchandiseList, int orderId = 0)
        {
            var result = new List <OrderMerchandise>();
            var merchandiseRepository = new MerchandiseRepository(_context);

            merchandiseList.ForEach(m => {
                var stockMerchandise         = merchandiseRepository.GetByBookId(m.Book.Id);
                var newOrderMerchandise      = new OrderMerchandise(stockMerchandise);
                newOrderMerchandise.Quantity = m.Quantity;
                newOrderMerchandise.Status   = m.Status;
                result.Add(newOrderMerchandise);
            });

            return(result);
        }
예제 #2
0
        public OrderMerchandise GetMerchandiseByOrderIdAndBookId(int bookId, int orderId = 0)
        {
            OrderMerchandise result = null;
            var _order = _context.Orders
                         .Include(o => o.MerchandiseList)
                         .ThenInclude(m => m.Book)
                         .FirstOrDefault(OrderQueries.GetById(orderId));

            if (_order != null)
            {
                result = _order.MerchandiseList.FirstOrDefault(m => m.Book.Id == bookId);
            }

            return(result);
        }