public void EditRebate(int id, string name, string type, int productId, double discount, int quantity, DateTime startDate, DateTime endDate) { Rebate rebate = factory.CreatRebate(name, productId, quantity, startDate, endDate, discount, type); rebate.Id = id; store.EditRebate(id, rebate); }
public double CalculatePrice() { List <Rebate> rebates = Customer.RebateAgreement; Rebate rebate = SelectRebate(rebates, Product.Id, Quantity, Date); if (rebate != null) { Price *= (100 - rebate.Discount) / 100; } return(Price); }
private Rebate SelectRebate(List <Rebate> rebates, int productId, int quantity, DateTime date) { Rebate rebate = null; foreach (Rebate r in rebates) { if (r.IsRebateApplicable(productId, quantity, date)) { rebate = (rebate == null || r.Discount >= rebate.Discount) ? r : rebate; } } return(rebate); }
public Customer CreateCustomer(string name, List <int> rebateIdList) { //Generate list of applicable rebates List <Rebate> rebateList = new List <Rebate>(); foreach (int id in rebateIdList) { Rebate rebate = store.GetRebate(id); rebateList.Add(rebate); } Customer cust = new Customer(); cust.Name = name; cust.RebateAgreement = rebateList; return(cust); }
public void AddRebate(string name, string type, int productId, double discount, int quantity, DateTime startDate, DateTime endDate) { Rebate rebate = factory.CreatRebate(name, productId, quantity, startDate, endDate, discount, type); store.AddRebate(rebate); }