private int ApplyPromotionRule(List <Cart> carts, Cart cart, PromotionRule promoRule) { var item = _itemServices.GetItemBySkuId(cart.SkuId); if (promoRule == null) { return(cart.TotalCount * item.Price); } if (promoRule.LumpSumAmountToReduceFromPrice > 0) { return(CalculatePrice(carts, cart, promoRule)); } return(0); }
private int ApplyPromotionRule(List <Cart> carts, Cart cart, PromotionRule promoRule) { var item = itemServices.GetItemBySkuId(cart.SKUId); if (promoRule == null) { return(cart.CountOfRemainingItemsForPromo * item.Price); // "CountOfRemainingItemsForPromo" test case Scenario6 } if (promoRule.LumsumAmountToReduceFromPrice > 0) { return(CalculatePrice(carts, cart, promoRule)); } if (promoRule.PercentageToReduceFromPrice > 0) { // we can add future requirement here Ex : discount based on percentage } throw new Exception("invalid input..."); }