public void ProcessRequest(BookingRequest bookingRequest) { foreach (var productRequest in bookingRequest.ProductRequests) { if (productRequest.Quantity > 0) { if (!_orderService.IsProductVariantEnabled(productRequest.VariantId)) throw new ProductVariantNotEnabledException("Product is not available"); var shoppingCartItem = new ShoppingCartItem { ProductVariantId = productRequest.VariantId, Quantity = productRequest.Quantity, UserId = bookingRequest.UserId }; _shoppingCartRepository.Add(shoppingCartItem); } } }
private void AddProductVariant(Order order, ShoppingCartItem shoppingCartItem) { if (order.ProductVariants == null) order.ProductVariants = new List<OrderProductVariant>(); order.ProductVariants.Add(new OrderProductVariant { ProductVariant = shoppingCartItem.ProductVariant, Quantity = shoppingCartItem.Quantity, UnitPrice = shoppingCartItem.ProductVariant.Price }); }