Пример #1
0
        private decimal CalculateAbsoluteDiscount(ProductPrice price, AbsoluteDiscount absoluteDiscount)
        {
            var totalDiscount = absoluteDiscount.Periodicity switch {
                Periodicity.Monthly => absoluteDiscount.Value * 12,
                Periodicity.Quarter => absoluteDiscount.Value * 4,
                Periodicity.Biannual => absoluteDiscount.Value * 2,
                Periodicity.Annual => absoluteDiscount.Value
            };

            return(price.Value - totalDiscount);
        }
Пример #2
0
        private decimal CalculateRelativeDiscount(ProductPrice price, RelativeDiscount relativeDiscount)
        {
            var discount = price.Value * relativeDiscount.Value / 100M;

            return(price.Value - discount);
        }
Пример #3
0
 public Product(ProductName name, ProductPrice price, Either <AbsoluteDiscount, RelativeDiscount> discount)
 {
     Name     = name;
     Price    = price;
     Discount = discount;
 }