コード例 #1
0
 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.");
 }
コード例 #2
0
        public static int GetCartItemsOfProductQuantity(this PromotionEvaluationContext context, string productId)
        {
            var retVal = context.CartPromoEntries.InProducts(new[] { productId })
                         .Sum(x => x.Quantity);

            return(retVal);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 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.");
 }
コード例 #9
0
        public static bool IsItemsInStockQuantity(this PromotionEvaluationContext context, bool isExactly, int quantity)
        {
            var compareCondition = isExactly ? ConditionOperation.Exactly : ConditionOperation.AtLeast;

            return(IsItemsInStockQuantityNew(context, compareCondition, quantity, 0));
        }
コード例 #10
0
 public static bool IsItemInProducts(this PromotionEvaluationContext context, string[] productIds)
 {
     return(new ProductPromoEntry[] { context.PromoEntry }.InProducts(productIds).Any());
 }