Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }