Exemplo n.º 1
0
        public virtual void ChangePrice(decimal newPrice)
        {
            var priceHistory = new ProductPriceHistory(Id, Price);

            priceHistory.HasChangedPrice(newPrice);

            PriceHistories.Add(priceHistory);

            OldPrice = Price;
            Price    = newPrice;
        }
Exemplo n.º 2
0
        public virtual void SetSpecialPrice(decimal specialPrice, DateTime startDate, DateTime?endDate = null)
        {
            if (startDate < DateTime.Now)
            {
                throw new ArgumentException("Can not set start date in the past!", nameof(startDate));
            }

            if (endDate.HasValue && endDate <= startDate)
            {
                throw new ArgumentException("Can not set end date in the past of start date!", nameof(endDate));
            }

            var priceHistory = new ProductPriceHistory(Id, Price);

            priceHistory.HasSpecialPriceSet(specialPrice, startDate, endDate);

            SpecialPrice      = specialPrice;
            SpecialPriceStart = startDate;
            SpecialPriceEnd   = endDate;
        }