Пример #1
0
        public JsonResult SearchByCampaignName(string searchTerm, int pageSize, int pageNum, int?productGroupId, int?productId)
        {
            _productFacade = new ProductFacade();
            List <CampaignServiceEntity> campaigns = _productFacade.GetCampaignServiceByName(searchTerm, pageSize, pageNum, productGroupId, productId);
            int campaignsCount = _productFacade.GetCampaignServiceCountByName(searchTerm, pageSize, pageNum, productGroupId, productId);

            //Select2PagedResult pagedBranches = CampaignToSelect2Format(campaigns, campaignsCount);

            Select2PagedResult pagedBranches = new Select2PagedResult();

            pagedBranches.Results = new List <Select2Result>();

            foreach (CampaignServiceEntity campaign in campaigns)
            {
                pagedBranches.Results.Add(new Select2Result {
                    id = campaign.CampaignServiceId, text = campaign.CampaignServiceName
                });
            }

            pagedBranches.Total = campaignsCount;

            return(Json(pagedBranches, JsonRequestBehavior.AllowGet));
        }