Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceListClient" /> class.
 /// </summary>
 /// <param name="priceListRepository">The price list repository.</param>
 /// <param name="customerSession">The customer session.</param>
 /// <param name="priceListEvaluator">The price list evaluator.</param>
 /// <param name="priceListEvalContext">The price list eval context.</param>
 /// <param name="cacheRepository">The cache repository.</param>
 public PriceListClient(IPricelistRepository priceListRepository, ICustomerSessionService customerSession, IPriceListAssignmentEvaluator priceListEvaluator, IPriceListAssignmentEvaluationContext priceListEvalContext, ICacheRepository cacheRepository)
 {
     _cacheRepository      = cacheRepository;
     _priceListRepository  = priceListRepository;
     _customerSession      = customerSession;
     _priceListEvalContext = priceListEvalContext;
     _priceListEvaluator   = priceListEvaluator;
     _isEnabled            = CatalogConfiguration.Instance.Cache.IsEnabled;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceListClient" /> class.
 /// </summary>
 /// <param name="priceListRepository">The price list repository.</param>
 /// <param name="customerSession">The customer session.</param>
 /// <param name="priceListEvaluator">The price list evaluator.</param>
 /// <param name="priceListEvalContext">The price list eval context.</param>
 /// <param name="cacheRepository">The cache repository.</param>
 public PriceListClient(IPricelistRepository priceListRepository, ICustomerSessionService customerSession, IPriceListAssignmentEvaluator priceListEvaluator, IPriceListAssignmentEvaluationContext priceListEvalContext, ICacheRepository cacheRepository)
 {
     _cacheRepository = cacheRepository;
     _priceListRepository = priceListRepository;
     _customerSession = customerSession;
     _priceListEvalContext = priceListEvalContext;
     _priceListEvaluator = priceListEvaluator;
     _isEnabled = CatalogConfiguration.Instance.Cache.IsEnabled;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidateLineItemsActivity"/> class.
 /// </summary>
 /// <param name="inventoryRepository">The inventory repository.</param>
 /// <param name="catalogRepository">The catalog repository.</param>
 /// <param name="storeRepository">The store repository.</param>
 /// <param name="customerService">The customer service.</param>
 /// <param name="priceListRepository">The price list repository.</param>
 /// <param name="currencyService">The currency service.</param>
 /// <param name="priceListEvaluator">The price list evaluator.</param>
 /// <param name="priceListEvalContext">The price list eval context.</param>
 /// <param name="cacheRepository">The cache repository.</param>
 public ValidateLineItemsActivity(IInventoryRepository inventoryRepository,
                                  ICatalogRepository catalogRepository,
                                  IStoreRepository storeRepository,
                                  ICustomerSessionService customerService,
                                  IPricelistRepository priceListRepository,
                                  ICurrencyService currencyService,
                                  IPriceListAssignmentEvaluator priceListEvaluator,
                                  IPriceListAssignmentEvaluationContext priceListEvalContext,
                                  ICacheRepository cacheRepository)
 {
     _inventoryRepository    = inventoryRepository;
     _catalogRepository      = catalogRepository;
     _storeRepository        = storeRepository;
     _customerSessionService = customerService;
     _pricelistRepository    = priceListRepository;
     _currencyService        = currencyService;
     _priceListEvalContext   = priceListEvalContext;
     _cacheRepository        = cacheRepository;
     _priceListEvaluator     = priceListEvaluator;
 }
        /// <summary>
        /// Evaluates the specified context and returns price lists in the order they should be applied.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public Pricelist[] Evaluate(IPriceListAssignmentEvaluationContext context)
        {
            Pricelist[] retVal = null;

            var query = GetPricelistAssignments();

            // sort content by type and priority
            query = query.OrderByDescending(x => x.Priority).ThenByDescending(x => x.Name);

            //filter by catalog
            query = query.Where(x => (x.CatalogId == context.CatalogId));

            //filter by currency
            query = query.Where(x => (x.Pricelist.Currency.Equals(context.Currency, StringComparison.OrdinalIgnoreCase)));

            //filter by date expiration
            query = query.Where(x => (x.StartDate == null || context.CurrentDate >= x.StartDate) && (x.EndDate == null || x.EndDate >= context.CurrentDate));

            //Evaluate query
            var current = query.ToArray();

            //Evaluate condition expression
            Func <string, bool> conditionPredicate = x =>
            {
                var condition = DeserializeExpression <Func <IEvaluationContext, bool> >(x);
                return(condition(context));
            };

            current = current.Where(x => String.IsNullOrEmpty(x.ConditionExpression) || conditionPredicate(x.ConditionExpression)).ToArray();

            var list = new List <Pricelist>();

            current.ToList().ForEach(x => list.Add(x.Pricelist));
            if (list.Count > 0)
            {
                retVal = list.ToArray();
            }

            return(retVal);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ValidateLineItemsActivity"/> class.
        /// </summary>
        /// <param name="inventoryRepository">The inventory repository.</param>
        /// <param name="catalogRepository">The catalog repository.</param>
        /// <param name="storeRepository">The store repository.</param>
        /// <param name="customerService">The customer service.</param>
        /// <param name="priceListRepository">The price list repository.</param>
        /// <param name="currencyService">The currency service.</param>
        /// <param name="priceListEvaluator">The price list evaluator.</param>
        /// <param name="priceListEvalContext">The price list eval context.</param>
        /// <param name="cacheRepository">The cache repository.</param>
        public ValidateLineItemsActivity(IInventoryRepository inventoryRepository, 
			ICatalogRepository catalogRepository, 
            IStoreRepository storeRepository, 
			ICustomerSessionService customerService, 
			IPricelistRepository priceListRepository,
            ICurrencyService currencyService, 
			IPriceListAssignmentEvaluator priceListEvaluator, 
			IPriceListAssignmentEvaluationContext priceListEvalContext,
			ICacheRepository cacheRepository)
        {
            _inventoryRepository = inventoryRepository;
            _catalogRepository = catalogRepository;
            _storeRepository = storeRepository;
            _customerSessionService = customerService;
            _pricelistRepository = priceListRepository;
            _currencyService = currencyService;
            _priceListEvalContext = priceListEvalContext;
	        _cacheRepository = cacheRepository;
	        _priceListEvaluator = priceListEvaluator;
        }