Example #1
0
        public IActionResult Checkout(Order order)
        {
            var wholesaler = context.Wholesalers.FirstOrDefault(p => p.Warehouse.Product.Id == order.ProductId);

            order.WholesalerId = wholesaler.WholesalerId;
            var product = productRepository.Products.FirstOrDefault(p => p.Id == order.ProductId);

            order.TotalPrice = order.Quantity * product.Price;
            warehouseRepository.DecreaseAvailableProducts(wholesaler.WholesalerId, product.Id, order.Quantity);
            repository.SaveOrder(order);
            return(RedirectToAction("List"));
        }