public Tuple <ShopProduct, int> ApplyPolicy(ShoppingCart cart, Guid productGuid, int quantity, BaseUser user, IUnitOfWork unitOfWork) { if (CheckPolicy(cart, productGuid, quantity, user, unitOfWork)) { int prevDiscountPercentage = DiscountPolicy2.DiscountPercentage; DiscountPolicy2.DiscountPercentage = DiscountPercentage; var discountProductAndQuantity = DiscountPolicy2.ApplyPolicy(cart, productGuid, quantity, user, unitOfWork); DiscountPolicy2.DiscountPercentage = prevDiscountPercentage; return(discountProductAndQuantity); } return(null); }
public bool CheckPolicy(ShoppingCart cart, Guid productGuid, int quantity, BaseUser user, IUnitOfWork unitOfWork) { return(Operator.Operate(DiscountPolicy1.CheckPolicy(cart, productGuid, quantity, user, unitOfWork), DiscountPolicy2.CheckPolicy(cart, productGuid, quantity, user, unitOfWork))); }