Exemplo n.º 1
0
 public Order Create(int quantity, string productCode)
 {
     ProductCode = productCode;
     Quantity    = quantity;
     DomainEventRepository.Add(new NewOrderCreatedEvent(productCode, quantity));
     return(this);
 }
Exemplo n.º 2
0
 public Sale Create(string productCode, int pricePerProduct, int quantity, string campaignName)
 {
     ProductCode  = productCode;
     Quantity     = quantity;
     TotalPaid    = pricePerProduct * quantity;
     CampaignName = campaignName;
     DomainEventRepository.Add(new SaleConfirmedEvent(this));
     return(this);
 }
Exemplo n.º 3
0
        public Campaign UpdatePrice(int priceManipulation)
        {
            if ((PriceManipulationLimit >= CurrentPriceManipulation + priceManipulation))
            {
                CurrentPriceManipulation += priceManipulation;
            }

            DomainEventRepository.Add(new UpdateCampaignCurrentManipulationEvent(this));
            return(this);
        }
Exemplo n.º 4
0
 public Campaign CreateCampaign(string name, string productCode, int duration, int priceManipulationLimit, int targetSalesCount)
 {
     Duration = duration;
     Name     = name;
     PriceManipulationLimit = priceManipulationLimit;
     ProductCode            = productCode;
     TargetSalesCount       = targetSalesCount;
     Status = Status.Active;
     CurrentPriceManipulation = 0;
     DomainEventRepository.Add(new AddNewCampaignEvent(Name, ProductCode, Duration, PriceManipulationLimit, TargetSalesCount));
     return(this);
 }
Exemplo n.º 5
0
        public ProductOrder Create(Product product, Order order, Campaign campaign)
        {
            ProductCode = product.ProductCode;
            Quantity    = order.Quantity;
            if (campaign != null)
            {
                DiscountAmount = product.OriginalPrice * campaign.CurrentPriceManipulation / 100;
            }
            PricePerItem             = product.OriginalPrice;
            PricePerItemWithDiscount = PricePerItem - DiscountAmount;
            TotalAmount             = product.OriginalPrice * order.Quantity;
            TotalAmountWithDiscount = order.Quantity * PricePerItemWithDiscount;
            TotalDiscount           = DiscountAmount * Quantity;
            OriginalStock           = product.Stock;
            StockAfterSale          = product.Stock - order.Quantity;

            OrderedProduct       = product;
            OrderedProduct.Stock = StockAfterSale;

            CampaignName = campaign?.Name;
            DomainEventRepository.Add(new NewProductOrderCreatedEvent(this));
            return(this);
        }
Exemplo n.º 6
0
 public void Create(string productCode, int price, int stock)
 {
     DiscountedPrice = price;
     DomainEventRepository.Add(new AddNewProductEvent(productCode, price, stock));
 }
Exemplo n.º 7
0
 public Campaign ChangeStatus(Status status)
 {
     Status = status;
     DomainEventRepository.Add(new CampaignDeactivedEvent(this));
     return(this);
 }