예제 #1
0
        public JsonResult SearchByProductName(string searchTerm, int pageSize, int pageNum, int?productGroupId, int?campaignId)
        {
            _productFacade = new ProductFacade();
            List <ProductEntity> products = _productFacade.GetProductByName(searchTerm, pageSize, pageNum, productGroupId, campaignId);
            int productCount = _productFacade.GetProductCountByName(searchTerm, pageSize, pageNum, productGroupId, campaignId);

            //Select2PagedResult pagedBranches = ProductToSelect2Format(products, productCount);

            Select2PagedResult pagedBranches = new Select2PagedResult();

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

            foreach (ProductEntity product in products)
            {
                pagedBranches.Results.Add(new Select2Result {
                    id = product.ProductId, text = product.ProductName
                });
            }

            pagedBranches.Total = productCount;

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