コード例 #1
0
        public void InsertOrder(ProductDTO product, int quantity, TimeSpan sysTime)
        {
            if (product.Stock.HasStockCapacity(quantity))
            {
                product.Stock.ReduceStock(quantity);

                var order = new OrderDTO(product, quantity);

                if (product.HasCampaign())
                {
                    var existingCampaign = product.GetCampaign();

                    if (existingCampaign.HasDuration(sysTime))
                    {
                        existingCampaign.IncraseTotalSalesCount(quantity);

                        order.SetCampaign(existingCampaign);
                        order.SetPriceSales(product.Price.Value);

                        OrderList.Add(order);
                        Logger.Log(String.Format("Succesfully! Order created. Product Code :{0}, Quantity: {1}", product.ProductCode.Value, quantity));
                    }
                }else
                {
                    order.SetPriceSales(product.Price.Value);
                    OrderList.Add(order);
                    Logger.Log(String.Format("Succesfully! Order created. Order created; product {0}, quantity {1}", product.ProductCode.Value, quantity));
                }
            }
        }