예제 #1
0
        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);
        }
예제 #2
0
 public ShopCartController()
 {
     this.sessionMenager = new SessionMenager();
     this.db             = new ShopContext();
     this.manager        = new ShopCartManager(sessionMenager, db);
 }
예제 #3
0
 public CartController(IProductRepository productRepository, ShopCartManager cartManager, ICartRepository cartRepository)
 {
     _productRepository = productRepository;
     _cartManager       = cartManager;
     _cartRepository    = cartRepository;
 }