Esempio n. 1
0
 /// <summary>
 /// Add a new Coupon to this store, coupons applicable to items can only have one
 /// </summary>
 /// <param name="item">The Coupon to be added</param>
 public void Add(IDiscounter <ItemBase> item)
 {
     if (item.GetType() == typeof(PercentOffCoupon))
     {
         percentOff = (PercentOffCoupon)item;
         if (percentOff.percent > 100 || percentOff.percent < 0)
         {
             percentOff.percent = 0;
         }
         return;
     }
     if (item.GetType() == typeof(BxGyCoupon))
     {
         var coupon         = (BxGyCoupon)item;
         var existingCoupon = itemDiscounts.FirstOrDefault(i => i.itemName == coupon.itemName);
         if (existingCoupon != null)
         {
             itemDiscounts.Remove(existingCoupon);
         }
         itemDiscounts.Add(coupon);
     }
 }