Example #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);
        }
Example #2
0
        public bool ValidateMerchandiseStock(int orderId, int bookId, int quantity)
        {
            var merchandiseRepository = new MerchandiseRepository(_context);
            var stockMerchandise      = merchandiseRepository.GetByBookId(bookId);

            int incremetOrDeclementToStock = quantity;

            var stockQuantityResult = stockMerchandise.Quantity - incremetOrDeclementToStock;

            if (stockQuantityResult > -1)
            {
                return(true);
            }
            return(false);
        }