コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }