예제 #1
0
        public ActionResult <ActivePromotionsModel> GetActivePromotions(string itemName)
        {
            var returnObject     = new ActivePromotionsModel();
            var promotionForItem = new DiscountsFactory().GetPromotions(itemName);

            returnObject.DiscountRunning = promotionForItem.DiscountOffered;
            returnObject.ItemName        = itemName;
            returnObject.NoOfItems       = promotionForItem.NoOfItems;
            return(returnObject);
        }
예제 #2
0
        private double CheckPromoDiscount(double unitPrice, AddItemRequestModel item)
        {
            var promotionForItem = new DiscountsFactory().GetPromotions(item.ItemType);
            var OnDiscountPrice  = (item.ItemQuantity / promotionForItem.NoOfItems) * promotionForItem.DiscountOffered;

            if (!Flag)
            {
                isPromoApplied = OnDiscountPrice > 0;
                Flag           = true;
            }
            var OffDiscountPrice = (item.ItemQuantity % promotionForItem.NoOfItems) * unitPrice;

            return(OnDiscountPrice + OffDiscountPrice);
        }
예제 #3
0
        public double GenerateBillForCAndD(IList <AddItemRequestModel> items)
        {
            var promotionForItem       = new DiscountsFactory().GetPromotions(items.FirstOrDefault().ItemType);
            var minimumCommonQtyinBoth = items.Select(x => x.ItemQuantity).Min();
            var OnDiscountPrice        = minimumCommonQtyinBoth * promotionForItem.DiscountOffered;

            if (!Flag)
            {
                isPromoApplied = OnDiscountPrice > 0;
                Flag           = true;
            }

            var itemWithMoreQty = items.Where(x => x.ItemQuantity > minimumCommonQtyinBoth);

            var unitPrice = GetUnitPriceOfItem(itemWithMoreQty.FirstOrDefault());

            var OffDiscountPrice = (itemWithMoreQty.FirstOrDefault().ItemQuantity - minimumCommonQtyinBoth) * unitPrice;

            return(OffDiscountPrice + OnDiscountPrice);
        }