Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of a <see cref="FacetPredicate"/> from a <see cref="SearchFilter"/> object.
        /// </summary>
        /// <param name="filter">Filter to create the facet predicate from.</param>
        public Overture.ServiceModel.Search.FacetPredicate CreateFacetPredicate(SearchFilter filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }

            if (string.IsNullOrWhiteSpace(filter.Name))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Name"), "filter");
            }

            if (string.IsNullOrWhiteSpace(filter.Value))
            {
                return(null);
            }

            var values = filter.Value.Split(SearchConfiguration.MultiFacetValueSplitter).ToList();

            var facetPredicate = new Overture.ServiceModel.Search.FacetPredicate
            {
                OperatorType = FacetValuesOperator.Or,
                ExcludeFilterForFacetsCount = true,
                FieldName = filter.Name,
                FacetType = FacetType.Field,
                Values    = values
            };

            return(facetPredicate);
        }
        /// <summary>
        /// Creates a new instance of <see cref="Facet"/> based on a <param name="facet"></param> object.
        /// </summary>
        public Facet CreateFacet(Overture.ServiceModel.Search.Facet facet, IReadOnlyList <SearchFilter> selectedFacets, CultureInfo cultureInfo)
        {
            if (facet == null)
            {
                throw new ArgumentNullException("facet");
            }
            if (string.IsNullOrWhiteSpace(facet.FieldName))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("FieldName"), "facet");
            }

            var setting = FacetConfigContext.GetFacetSettings()
                          .FirstOrDefault(s => s.FieldName.Equals(facet.FieldName, StringComparison.OrdinalIgnoreCase));

            if (setting == null)
            {
                return(null);
            }

            Type factoryType = FacetProviderRegistry.ResolveProviderType(setting.FacetType.ToString());

            var instance = GetProviderInstance(factoryType);

            return(instance.CreateFacet(facet, setting, selectedFacets, cultureInfo));
        }
        /// <summary>
        /// Creates a new list of <see cref="SelectedFacet"/> based on a <param name="filter"></param> object.
        /// </summary>
        public virtual IEnumerable <SelectedFacet> CreateSelectedFacet(SearchFilter filter, CultureInfo cultureInfo)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }
            if (string.IsNullOrWhiteSpace(filter.Name))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Name"), "filter");
            }

            var setting = FacetConfigContext.GetFacetSettings()
                          .FirstOrDefault(s => s.FieldName.Equals(filter.Name, StringComparison.OrdinalIgnoreCase));

            if (setting == null)
            {
                return(Enumerable.Empty <SelectedFacet>());
            }

            Type factoryType = SelectedFacetProviderRegistry.ResolveProviderType(setting.FacetType.ToString());

            var instance = GetProviderInstance(factoryType);

            return(instance.CreateSelectedFacetList(filter, setting, cultureInfo));
        }
Esempio n. 4
0
        /// <summary>
        /// Get the Shipping methods available for a shipment.
        /// The Cost and Expected Delivery Date are calculated in overture.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>The ShippingMethodsViewModel</returns>
        /// <remarks>This cannot be cached because Overture may include custom logic depending on the current cart state.</remarks>
        public virtual Task <List <FulfillmentMethod> > GetCalculatedFulfillmentMethods(GetShippingMethodsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CartName"), "param");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Scope"), "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CustomerId"), "param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CultureInfo"), "param");
            }

            var request = new FindCalculatedFulfillmentMethodsRequest
            {
                CartName   = param.CartName,
                CustomerId = param.CustomerId,
                ScopeId    = param.Scope,
                ShipmentId = param.ShipmentId
            };

            return(OvertureClient.SendAsync(request));
        }
Esempio n. 5
0
        public async Task <CategoryBrowsingViewModel> GetCategoryBrowsingViewModelAsync(GetCategoryBrowsingViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (param.CategoryId == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("CategoryId"));
            }
            if (param.SelectedFacets == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("SelectedFacets"));
            }

            var viewModel = new CategoryBrowsingViewModel
            {
                CategoryId           = param.CategoryId,
                CategoryName         = param.CategoryName,
                SelectedFacets       = await GetSelectedFacetsAsync(param).ConfigureAwait(false),
                ProductSearchResults = await GetProductSearchResultsAsync(param).ConfigureAwait(false),
                ChildCategories      = await GetChildCategoriesAsync(param).ConfigureAwait(false)
            };

            viewModel.Context["ProductSearchResults"] = viewModel.ProductSearchResults;
            viewModel.Context["ListName"]             = "Category Browsing";

            return(viewModel);
        }
Esempio n. 6
0
        /// <summary>
        /// Retrieve the CountryViewModel
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <CountryViewModel> RetrieveCountryAsync(RetrieveCountryParam param)
        {
            if (string.IsNullOrWhiteSpace(param.IsoCode))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("IsoCode"), "param");
            }

            var country = await CountryRepository.RetrieveCountry(param).ConfigureAwait(false);

            var countryViewModel = ViewModelMapper.MapTo <CountryViewModel>(country, param.CultureInfo);

            return(countryViewModel);
        }