Beispiel #1
0
 public Promotion(int _promID, Dictionary <string, int> _prodInfo, decimal _pp, PromotionTypes _promotionType)
 {
     this.PromotionID   = _promID;
     this.ProductInfo   = _prodInfo;
     this.PromoPrice    = _pp;
     this.PromotionType = _promotionType;
 }
Beispiel #2
0
        public static decimal GetTotalPriceOfOrder(List <Order> orders, List <Promotion> promotions)
        {
            decimal cartTotal = 0M;

            foreach (Order ord in orders)
            {
                int            remainingQty = 0;
                List <decimal> promoprices  = promotions
                                              .Select(promo => PromotionChecker.GetTotalPriceOfItem(ord, promo, ref remainingQty))
                                              .ToList();
                decimal origprice = ord.Products.Sum(x => x.Price);
                decimal priceQty  = ord.Products.Select(q => q.Price).FirstOrDefault();

                decimal        promoprice = promoprices.Sum();
                PromotionTypes promoType  = promotions.Where(x => x.ProductInfo.Select(z => z.Key).FirstOrDefault().Equals(ord.Products.FirstOrDefault().Id)).Select(p => p.PromotionType).FirstOrDefault();
                decimal        finalPrice = 0m;
                if (promoType == PromotionTypes.FLATPERCENTAGE)
                {
                    finalPrice = origprice * (promoprice / 100);
                }
                else if (promoType == PromotionTypes.FLATRATE)
                {
                    finalPrice = promoprice;
                }
                cartTotal += finalPrice == 0M? origprice:finalPrice + (remainingQty * priceQty);
            }
            return(cartTotal);
        }
        protected List <PromotionTypes> GetPromotions()
        {
            var lPromotionType = new List <PromotionTypes>();
            var promoType      = new PromotionTypes();

            promoType.LetterPromo             = new Letter();
            promoType.numberOfDependentsPromo = new NumberOfDependents();
            lPromotionType.Add(promoType);
            return(lPromotionType);
        }
Beispiel #4
0
        public void ItShouldReturnNumDependentPromotion()
        {
            var lPromotionType = new List <PromotionTypes>();
            var promoType      = new PromotionTypes();

            promoType.numberOfDependentsPromo = new NumberOfDependents();

            lPromotionType.Add(promoType);

            results.ShouldBeEquivalentTo(lPromotionType);
        }
Beispiel #5
0
        public void ItShouldReturnLetterPromotion()
        {
            var lPromotionType = new List <PromotionTypes>();
            var promoType      = new PromotionTypes();

            promoType.LetterPromo = new Letter();

            lPromotionType.Add(promoType);

            results.ShouldBeEquivalentTo(lPromotionType);
        }