Exemplo n.º 1
0
        public IHttpActionResult Search([FromUri] SearchCriteria criteria)
        {
            criteria = criteria ?? new SearchCriteria();
            criteria.Normalize();
            criteria.ApplyRestrictionsForUser(User.Identity.Name, _securityService);

            var result = new SearchResult();

            if ((criteria.ResponseGroup & SearchResponseGroup.WithProducts) == SearchResponseGroup.WithProducts)
            {
                result = SearchProducts(criteria);
            }

            var catalogResponseGroup = criteria.ResponseGroup & (SearchResponseGroup.WithCatalogs | SearchResponseGroup.WithCategories);

            if (catalogResponseGroup != SearchResponseGroup.None)
            {
                criteria.ResponseGroup = catalogResponseGroup;
                var catalogResult = _catalogSearchService.Search(criteria);
                result.Catalogs   = catalogResult.Catalogs;
                result.Categories = catalogResult.Categories;
            }

            return(Ok(result.ToWebModel(_blobUrlResolver)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Filter catalog search criteria based on current user permissions
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>
        protected void ApplyRestrictionsForCurrentUser(SearchCriteria criteria)
        {
            var userName = User.Identity.Name;

            criteria.ApplyRestrictionsForUser(userName, _securityService);
        }