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); }
private decimal CalculateRelativeDiscount(ProductPrice price, RelativeDiscount relativeDiscount) { var discount = price.Value * relativeDiscount.Value / 100M; return(price.Value - discount); }
public Product(ProductName name, ProductPrice price, Either <AbsoluteDiscount, RelativeDiscount> discount) { Name = name; Price = price; Discount = discount; }