public async Task <ProductOrder> CreateOrder(ProductBoughtContext boughtContext) { foreach (BoughtItem boughtItem in boughtContext.BoughtItems) { boughtItem.Specification = SpecificationRepository.Get(boughtItem.SpecificationId); boughtItem.ProductId = boughtItem.Specification.ProductId; ProductManager.CheckStock(boughtItem.Specification, boughtItem.Count); if (boughtItem.CartItemId.HasValue) { ShopCartManager.RemoveItem(boughtItem.CartItemId.Value); } DecreaseStockWhen decreaseStockWhen = (DecreaseStockWhen)(Enum.Parse(typeof(DecreaseStockWhen), SettingManager.GetSettingValueForTenant(ShopSettings.General.DecreaseStockWhen, InfrastructureSession.TenantId.Value))); if (decreaseStockWhen == DecreaseStockWhen.Create) { ProductManager.DecreaseStock(boughtItem.Specification, boughtItem.Count); } } ProductOrder order = await Create(boughtContext); return(order); }
public ShopCartController() { this.sessionMenager = new SessionMenager(); this.db = new ShopContext(); this.manager = new ShopCartManager(sessionMenager, db); }
public CartController(IProductRepository productRepository, ShopCartManager cartManager, ICartRepository cartRepository) { _productRepository = productRepository; _cartManager = cartManager; _cartRepository = cartRepository; }