public static bool IsAnyLineItemExtendedTotalNew(this PromotionEvaluationContext context, decimal lineItemTotal, decimal lineItemTotalSecond, string compareCondition, string[] excludingCategoryIds, string[] excludingProductIds) { if (compareCondition.EqualsInvariant(ConditionOperation.Exactly)) { return(context.CartPromoEntries.Where(x => x.Price * x.Quantity == lineItemTotal) .ExcludeCategories(excludingCategoryIds) .ExcludeProducts(excludingProductIds) .Any()); } else if (compareCondition.EqualsInvariant(ConditionOperation.AtLeast)) { return(context.CartPromoEntries.Where(x => x.Price * x.Quantity >= lineItemTotal) .ExcludeCategories(excludingCategoryIds) .ExcludeProducts(excludingProductIds) .Any()); } else if (compareCondition.EqualsInvariant(ConditionOperation.IsLessThanOrEqual)) { return(context.CartPromoEntries.Where(x => x.Price * x.Quantity <= lineItemTotal) .ExcludeCategories(excludingCategoryIds) .ExcludeProducts(excludingProductIds) .Any()); } else if (compareCondition.EqualsInvariant(ConditionOperation.Between)) { return(context.CartPromoEntries.Where(x => x.Price * x.Quantity >= lineItemTotal && x.Quantity <= lineItemTotalSecond) .ExcludeCategories(excludingCategoryIds) .ExcludeProducts(excludingProductIds) .Any()); } throw new Exception("CompareCondition has incorrect value."); }
public static int GetCartItemsOfProductQuantity(this PromotionEvaluationContext context, string productId) { var retVal = context.CartPromoEntries.InProducts(new[] { productId }) .Sum(x => x.Quantity); return(retVal); }
public static decimal GetCartTotalWithExcludings(this PromotionEvaluationContext context, string[] excludingCategoryIds, string[] excludingProductIds) { var retVal = context.CartPromoEntries.ExcludeCategories(excludingCategoryIds) .ExcludeProducts(excludingProductIds) .Sum(x => x.Price * x.Quantity); return(retVal); }
public static int GetCartItemsQuantity(this PromotionEvaluationContext context, string[] excludingCategoryIds, string[] excludingProductIds) { var retVal = context.CartPromoEntries.ExcludeCategories(excludingCategoryIds) .ExcludeProducts(excludingProductIds) .Sum(x => x.Quantity); return(retVal); }
public static bool IsItemInCategory(this PromotionEvaluationContext context, string categoryId, string[] excludingCategoryIds, string[] excludingProductIds) { var result = new ProductPromoEntry[] { context.PromoEntry }.InCategories(new[] { categoryId }) .ExcludeCategories(excludingCategoryIds) .ExcludeProducts(excludingProductIds) .Any(); return(result); }
public static bool IsItemCodeContains(this PromotionEvaluationContext context, string code) { var result = context.PromoEntry != null && !string.IsNullOrEmpty(context.PromoEntry.Code); if (result) { result = context.PromoEntry.Code.IndexOf(code, StringComparison.OrdinalIgnoreCase) != -1; } return(result); }
public static bool IsAnyLineItemExtendedTotal(this PromotionEvaluationContext context, decimal lineItemTotal, bool isExactly, string[] excludingCategoryIds, string[] excludingProductIds) { var compareCondition = ConditionOperation.AtLeast; if (isExactly) { compareCondition = ConditionOperation.Exactly; } return(IsAnyLineItemExtendedTotalNew(context, lineItemTotal, 0, compareCondition, excludingCategoryIds, excludingProductIds)); }
public static bool IsItemsInStockQuantityNew(this PromotionEvaluationContext context, string compareCondition, int quantity, int quantitySecond) { if (compareCondition.EqualsInvariant(ConditionOperation.Exactly)) { return(context.PromoEntry.InStockQuantity == quantity); } else if (compareCondition.EqualsInvariant(ConditionOperation.AtLeast)) { return(context.PromoEntry.InStockQuantity >= quantity); } else if (compareCondition.EqualsInvariant(ConditionOperation.IsLessThanOrEqual)) { return(context.PromoEntry.InStockQuantity <= quantity); } else if (compareCondition.EqualsInvariant(ConditionOperation.Between)) { return(context.PromoEntry.InStockQuantity >= quantity && context.PromoEntry.InStockQuantity <= quantitySecond); } throw new Exception("CompareCondition has incorrect value."); }
public static bool IsItemsInStockQuantity(this PromotionEvaluationContext context, bool isExactly, int quantity) { var compareCondition = isExactly ? ConditionOperation.Exactly : ConditionOperation.AtLeast; return(IsItemsInStockQuantityNew(context, compareCondition, quantity, 0)); }
public static bool IsItemInProducts(this PromotionEvaluationContext context, string[] productIds) { return(new ProductPromoEntry[] { context.PromoEntry }.InProducts(productIds).Any()); }