public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
		{
			if (bindingContext.ModelType != typeof(ListEntrySearchCriteria))
			{
				return false;
			}
			
			var qs = HttpUtility.ParseQueryString(actionContext.Request.RequestUri.Query as string);

			var result = new ListEntrySearchCriteria();

			result.ResponseGroup = ResponseGroup.WithCatalogs | ResponseGroup.WithCategories | ResponseGroup.WithProducts;

			var respGroup = qs["respGroup"].EmptyToNull();
			if(respGroup != null)
			{
				result.ResponseGroup = (ResponseGroup)Enum.Parse(typeof(ResponseGroup), respGroup, true);
			}
			result.Keyword = qs["q"].EmptyToNull();
		
			result.CatalogId = qs["catalog"].EmptyToNull();
			result.CategoryId = qs["category"].EmptyToNull();
			result.Count = qs["count"].TryParse(20);
			result.Start = qs["start"].TryParse(0);
			bindingContext.Model = result;
			return true;
		}
Beispiel #2
0
        public IHttpActionResult ListItemsSearch([ModelBinder(typeof(ListEntrySearchCriteriaBinder))] webModel.ListEntrySearchCriteria criteria)
        {
            var searchCriteria = criteria.ToCoreModel();

            ApplyRestrictionsForCurrentUser(searchCriteria);

            var serviceResult = _searchService.Search(searchCriteria);

            var retVal = new webModel.ListEntrySearchResult();

            var start = criteria.Start;
            var count = criteria.Count;

            // all categories
            var categories = serviceResult.Categories.Select(x => new webModel.ListEntryCategory(x.ToWebModel(_blobUrlResolver))).ToList();
            var products   = serviceResult.Products.Select(x => new webModel.ListEntryProduct(x.ToWebModel(_blobUrlResolver)));

            retVal.TotalCount = categories.Count() + serviceResult.ProductsTotalCount;
            retVal.ListEntries.AddRange(categories.Skip(start).Take(count));

            count -= categories.Count();

            retVal.ListEntries.AddRange(products.Take(count));

            return(Ok(retVal));
        }
		public static webModel.ListEntrySearchCriteria ToWebModel(this moduleModel.SearchCriteria criteria)
		{
			var retVal = new webModel.ListEntrySearchCriteria();
			retVal.InjectFrom(criteria);
			retVal.ResponseGroup = (webModel.ResponseGroup)(int)criteria.ResponseGroup;
			return retVal;
		}
Beispiel #4
0
        public static webModel.ListEntrySearchCriteria ToWebModel(this coreModel.SearchCriteria criteria)
        {
            var retVal = new webModel.ListEntrySearchCriteria();

            retVal.InjectFrom(criteria);
            retVal.ResponseGroup = (webModel.ResponseGroup)(int) criteria.ResponseGroup;
            return(retVal);
        }
        public static coreModel.SearchCriteria ToCoreModel(this webModel.ListEntrySearchCriteria criteria)
        {
            var retVal = new coreModel.SearchCriteria();

            retVal.InjectFrom(criteria);
            retVal.Skip          = criteria.Start;
            retVal.Take          = criteria.Count;
            retVal.WithHidden    = true;
            retVal.ResponseGroup = (coreModel.SearchResponseGroup)(int) criteria.ResponseGroup;

            return(retVal);
        }
Beispiel #6
0
        public IHttpActionResult ListItemsSearch([ModelBinder(typeof(ListEntrySearchCriteriaBinder))] webModel.ListEntrySearchCriteria criteria)
        {
            //Filter search criteria to the corresponding user permissions
            var searchCriteria = base.ChangeCriteriaToCurentUserPermissions(criteria.ToModuleModel());
            var serviceResult  = _searchService.Search(searchCriteria);

            var retVal = new webModel.ListEntrySearchResult();

            var start = criteria.Start;
            var count = criteria.Count;

            // all categories
            var categories = serviceResult.Categories.Select(x => new webModel.ListEntryCategory(x.ToWebModel(_blobUrlResolver)));
            var products   = serviceResult.Products.Select(x => new webModel.ListEntryProduct(x.ToWebModel(_blobUrlResolver)));

            retVal.TotalCount = categories.Count() + serviceResult.TotalCount;
            retVal.ListEntries.AddRange(categories.Skip(start).Take(count));

            count -= categories.Count();

            retVal.ListEntries.AddRange(products.Take(count));

            return(Ok(retVal));
        }