// this method takes care of discount job for products public IList<Product> GetAllProductsFor(EnmCustomerType enmCustomerType) { IDiscountStrategy discountStrategy = DiscountFactory.GetDiscountStrategyFor(enmCustomerType); IList<Product> products = _productRepository.FindAll(); products.Apply(discountStrategy); return products; }
public static IDiscountStrategy GetDiscountStrategyFor(EnmCustomerType enmCustomerType) { switch (enmCustomerType) { case EnmCustomerType.Trade: return new TradeDiscountStrategy(); default: return new NullDiscountStrategy(); } }