Esempio n. 1
0
        public JsonResult SearchByBranchName(string searchTerm, int pageSize, int pageNum)
        {
            //Get the paged results and the total count of the results for this query.
            _commonFacade = new CommonFacade();
            List <BranchEntity> branches = _commonFacade.GetBranchesByName(searchTerm, pageSize, pageNum);
            int branchCount = _commonFacade.GetBranchCountByName(searchTerm, pageSize, pageNum);

            //Translate the attendees into a format the select2 dropdown expects
            //Select2PagedResult pagedBranches = BranchesToSelect2Format(branches, branchCount);

            Select2PagedResult pagedBranches = new Select2PagedResult();

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

            //Loop through our branches and translate it into a text value and an id for the select list
            foreach (BranchEntity branch in branches)
            {
                pagedBranches.Results.Add(new Select2Result {
                    id = branch.BranchId, text = branch.BranchName
                });
            }

            //Set the total count of the results from the query.
            pagedBranches.Total = branchCount;

            //Return the data as a jsonp result
            return(Json(pagedBranches, JsonRequestBehavior.AllowGet));
        }