public static IPromotion GetFactory(PromoDefinition promoDef) { switch (promoDef.PromoType) { case PromotionTypes.SingleSku: return(new SingleSku(promoDef)); case PromotionTypes.DualProducts: return(new DualProduct(promoDef)); // case Percentage } throw new ArgumentException("Unable to create PromotionType, invalid promotion type"); }
public SingleSku(PromoDefinition promo) { this.product = promo.ProductList[0]; this.quantity = promo.Quantity; this.promoPrice = Convert.ToDouble(promo.Value); }
public DualProduct(PromoDefinition promo) { this.product1 = promo.ProductList[0]; this.product2 = promo.ProductList[1]; this.promoPrice = Convert.ToDouble(promo.Value); }