private void PopulatePromotionalTable()
        {
            _promotionalDiscounts = new List <PromotionalDiscountTable>();

            PromotionalDiscountTable discount1 = new PromotionalDiscountTable();

            discount1.PromotionalCode = "PROMO25";
            discount1.DiscountAmount  = Convert.ToDecimal("25.00");

            _promotionalDiscounts.Add(discount1);

            PromotionalDiscountTable discount2 = new PromotionalDiscountTable();

            discount2.PromotionalCode = "PROMO50";
            discount2.DiscountAmount  = Convert.ToDecimal("50.00");

            _promotionalDiscounts.Add(discount2);

            PromotionalDiscountTable discount3 = new PromotionalDiscountTable();

            discount3.PromotionalCode = "PROMO75";
            discount3.DiscountAmount  = Convert.ToDecimal("75.00");

            _promotionalDiscounts.Add(discount3);
        }
Exemple #2
0
        /// <summary>
        /// Calculate
        /// </summary>
        /// <param name="promotionalCode"></param>
        /// <param name="orderValue"></param>
        /// <returns></returns>
        public decimal Calculate(string promotionalCode, decimal orderValue)
        {
            PromotionalDiscountTable promotion = _dataAccessService.GetPromotionalDiscount(promotionalCode);

            if (promotion.DiscountAmount > orderValue)
            {
                return(orderValue);
            }

            decimal orderTotal = orderValue - promotion.DiscountAmount;

            return(orderTotal);
        }