public Rebate CreatRebate(string name, int productId, int quantity, DateTime start, DateTime end, double discount, string type) { type = type.ToUpper().Trim(); Product product = store.GetProduct(productId); Rebate rebate; switch (type) { case "VOLUME": rebate = new VolumeBasedRebate(name, product, discount, quantity); break; case "SEASONAL": rebate = new SeasonalRebate(name, product, discount, start, end); break; case "SPECIAL": rebate = new SpecialRebate(name, product, discount, quantity, start, end); break; default: rebate = null; break; } return(rebate); }
public static BindingList <GridRebate> GetAllGridRebates(List <Rebate> input) { BindingList <GridRebate> result = new BindingList <GridRebate>(); foreach (Rebate reb in input) { GridRebate item = null; if (reb.GetType() == typeof(VolumeBasedRebate)) { VolumeBasedRebate r = (VolumeBasedRebate)reb; item = new GridRebate { Id = r.Id, Name = r.Name, RebateType = "Volume Based", Product = r.Product.Name, Discount = r.Discount.ToString(), MinimalVolume = r.Volume.ToString(), PeriodStart = "N/A", PeriodEnd = "N/A" }; } else if (reb.GetType() == typeof(SeasonalRebate)) { SeasonalRebate r = (SeasonalRebate)reb; item = new GridRebate { Id = r.Id, Name = r.Name, RebateType = "Seasonal", Product = r.Product.Name, Discount = r.Discount.ToString(), MinimalVolume = "N/A", PeriodStart = r.Start.ToString(), PeriodEnd = r.End.ToString() }; } else { SpecialRebate r = (SpecialRebate)reb; item = new GridRebate { Id = r.Id, Name = r.Name, RebateType = "Special Offer", Product = r.Product.Name, Discount = r.Discount.ToString(), MinimalVolume = r.Volume.ToString(), PeriodStart = r.Start.ToString(), PeriodEnd = r.End.ToString() }; } result.Add(item); } return(result); }