Ejemplo n.º 1
0
        public static catalogDto.CategorySearchCriteria ToCategorySearchCriteriaDto(this CategorySearchCriteria criteria, WorkContext workContext)
        {
            var result = new catalogDto.CategorySearchCriteria
            {
                SearchPhrase  = criteria.Keyword,
                LanguageCode  = criteria.Language?.CultureName ?? workContext.CurrentLanguage.CultureName,
                StoreId       = workContext.CurrentStore.Id,
                CatalogId     = workContext.CurrentStore.Catalog,
                Outline       = criteria.Outline,
                Sort          = criteria.SortBy,
                Skip          = criteria.Start,
                Take          = criteria.PageSize,
                ResponseGroup = ((int)criteria.ResponseGroup).ToString(),
            };
            var contact = workContext.CurrentUser?.Contact;

            if (contact != null && !contact.UserGroups.IsNullOrEmpty())
            {
                if (result.UserGroups == null)
                {
                    result.UserGroups = new List <string>();
                }
                //search categories with user_groups defined in customer
                result.UserGroups.AddRange(contact.UserGroups);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public virtual catalogDto.CategorySearchCriteria ToCategorySearchCriteriaDto(CategorySearchCriteria criteria, WorkContext workContext)
        {
            var result = new catalogDto.CategorySearchCriteria
            {
                SearchPhrase  = criteria.Keyword,
                LanguageCode  = criteria.Language?.CultureName ?? workContext.CurrentLanguage.CultureName,
                StoreId       = workContext.CurrentStore.Id,
                CatalogId     = workContext.CurrentStore.Catalog,
                Outline       = criteria.Outline,
                Sort          = criteria.SortBy,
                Skip          = criteria.Start,
                Take          = criteria.PageSize,
                ResponseGroup = ((int)criteria.ResponseGroup).ToString(),
            };

            return(result);
        }
Ejemplo n.º 3
0
        public static catalogDto.CategorySearchCriteria ToCategorySearchCriteriaDto(this CategorySearchCriteria criteria, WorkContext workContext)
        {
            var result = new catalogDto.CategorySearchCriteria
            {
                SearchPhrase  = criteria.Keyword,
                LanguageCode  = criteria.Language?.CultureName ?? workContext.CurrentLanguage.CultureName,
                StoreId       = workContext.CurrentStore.Id,
                CatalogId     = workContext.CurrentStore.Catalog,
                Outline       = criteria.Outline,
                UserGroups    = workContext.CurrentUser?.Contact?.UserGroups ?? new List <string>(), // null value disables filtering by user groups
                Sort          = criteria.SortBy,
                Skip          = criteria.Start,
                Take          = criteria.PageSize,
                ResponseGroup = ((int)criteria.ResponseGroup).ToString(),
                IsFuzzySearch = criteria.IsFuzzySearch,
            };

            return(result);
        }