public async Task <IPagedList <Contact> > SearchOrganizationContactsAsync(OrganizationContactsSearchCriteria criteria)
        {
            var criteriaDto = new customerDto.MembersSearchCriteria
            {
                MemberId     = criteria.OrganizationId,
                Skip         = (criteria.PageNumber - 1) * criteria.PageSize,
                Take         = criteria.PageSize,
                Sort         = criteria.Sort,
                SearchPhrase = criteria.SearchPhrase
            };

            var searchResult = await _customerApi.SearchAsync(criteriaDto);

            var contacts = _customerApi.GetContactsByIds(searchResult.Results.Select(x => x.Id).ToList()).Select(x => x.ToContact()).ToList();

            return(new StaticPagedList <Contact>(contacts, criteria.PageNumber, criteria.PageSize, searchResult.TotalCount.Value));
        }
Example #2
0
        public virtual IPagedList <Vendor> SearchVendors(string keyword, int pageNumber, int pageSize, IEnumerable <SortInfo> sortInfos)
        {
            // TODO: implement indexed search for vendors
            var workContext = _workContextFactory();
            var criteria    = new customerDto.MembersSearchCriteria
            {
                SearchPhrase = keyword,
                DeepSearch   = true,
                Skip         = (pageNumber - 1) * pageSize,
                Take         = pageSize
            };

            if (!sortInfos.IsNullOrEmpty())
            {
                criteria.Sort = SortInfo.ToString(sortInfos);
            }
            var result = _customerApi.CustomerModule.SearchVendors(criteria);

            return(new StaticPagedList <Vendor>(result.Vendors.Select(x => x.ToVendor(workContext.CurrentLanguage, workContext.CurrentStore)), pageNumber, pageSize, result.TotalCount.Value));
        }
        public virtual IPagedList <Vendor> SearchVendors(Store store, Language language, string keyword, int pageNumber, int pageSize, IEnumerable <SortInfo> sortInfos)
        {
            // TODO: implement indexed search for vendors
            //TODO: Add caching for vendors
            var criteria = new customerDto.MembersSearchCriteria
            {
                SearchPhrase = keyword,
                DeepSearch   = true,
                Skip         = (pageNumber - 1) * pageSize,
                Take         = pageSize
            };

            if (!sortInfos.IsNullOrEmpty())
            {
                criteria.Sort = SortInfo.ToString(sortInfos);
            }
            var vendorSearchResult = _customerApi.SearchVendors(criteria);
            var vendors            = vendorSearchResult.Vendors.Select(x => x.ToVendor(language, store));

            return(new StaticPagedList <Vendor>(vendors, pageNumber, pageSize, vendorSearchResult.TotalCount.Value));
        }
        public virtual IPagedList <Vendor> SearchVendors(Store store, Language language, string keyword, int pageNumber, int pageSize, IEnumerable <SortInfo> sortInfos)
        {
            // TODO: implement indexed search for vendors
            var criteria = new customerDto.MembersSearchCriteria
            {
                SearchPhrase = keyword,
                DeepSearch   = true,
                Skip         = (pageNumber - 1) * pageSize,
                Take         = pageSize
            };

            if (!sortInfos.IsNullOrEmpty())
            {
                criteria.Sort = SortInfo.ToString(sortInfos);
            }
            var cacheKey = CacheKey.With(GetType(), "SearchVendors", keyword, pageNumber.ToString(), pageSize.ToString(), criteria.Sort);
            var result   = _memoryCache.GetOrCreateExclusive(cacheKey, cacheEntry =>
            {
                return(_customerApi.SearchVendors(criteria));
            });
            var vendors = result.Vendors.Select(x => x.ToVendor(language, store));

            return(new StaticPagedList <Vendor>(vendors, pageNumber, pageSize, result.TotalCount.Value));
        }