private async Task <dynamic> GetSearchResults(
            string nameId,
            string searchType,
            List <string> urnList,
            string locationorpostcode,
            string locationCoordinates,
            string laCode,
            decimal?radius,
            string orderby,
            int page,
            int take = SearchDefaults.RESULTS_PER_PAGE)
        {
            dynamic response;

            switch (searchType)
            {
            case SearchTypes.SEARCH_BY_NAME_ID:
                response = await _schoolSearchService.SearchSchoolByName(nameId,
                                                                         (page - 1) *SearchDefaults.RESULTS_PER_PAGE, take, orderby,
                                                                         Request.QueryString);

                break;

            case SearchTypes.SEARCH_BY_LOCATION:
                if (string.IsNullOrEmpty(locationCoordinates))
                {
                    response = await _schoolSearchService.SearchSchoolByLocation(locationorpostcode,
                                                                                 (radius ?? SearchDefaults.LOCATION_SEARCH_DISTANCE) * 1.6m,
                                                                                 (page - 1) *SearchDefaults.RESULTS_PER_PAGE, take, orderby,
                                                                                 Request.QueryString);
                }
                else
                {
                    var latLng = locationCoordinates.Split(',');
                    response = await _schoolSearchService.SearchSchoolByLocation(latLng[0], latLng[1],
                                                                                 (radius ?? SearchDefaults.LOCATION_SEARCH_DISTANCE) * 1.6m,
                                                                                 (page - 1) *SearchDefaults.RESULTS_PER_PAGE, take, orderby,
                                                                                 Request.QueryString);
                }
                break;

            case SearchTypes.SEARCH_BY_LA_CODE_NAME:
                response = await _schoolSearchService.SearchSchoolByLaCode(laCode,
                                                                           (page - 1) *SearchDefaults.RESULTS_PER_PAGE, take,
                                                                           string.IsNullOrEmpty(orderby)? "EstablishmentName" : orderby,
                                                                           Request.QueryString);

                break;

            default:
                response = _contextDataService.GetMultipleSchoolsByUrns(urnList);
                break;
            }
            return(response);
        }
        public ActionResult Index()
        {
            var comparisonList = base.ExtractSchoolComparisonListFromCookie();

            if (comparisonList.BenchmarkSchools.Count > 1)
            {
                dynamic dynamicBenchmarkSchools = _contextDataService.GetMultipleSchoolsByUrns(comparisonList.BenchmarkSchools.Select(b => b.Urn.ToString()).ToList());

                comparisonList.BenchmarkSchools = new List <BenchmarkSchoolViewModel>();

                foreach (var dynamicBenchmarkSchool in dynamicBenchmarkSchools)
                {
                    var school          = new SchoolViewModel(dynamicBenchmarkSchool);
                    var benchmarkSchool = new BenchmarkSchoolViewModel()
                    {
                        Address       = school.Address,
                        Name          = school.Name,
                        Phase         = school.OverallPhase,
                        Type          = school.Type,
                        FinancialType = school.FinancialType.ToString(),
                        Urn           = school.Id
                    };

                    comparisonList.BenchmarkSchools.Add(benchmarkSchool);
                }
            }
            else if (comparisonList.BenchmarkSchools.Count == 1)
            {
                var dynamicBenchmarkSchool = _contextDataService.GetSchoolByUrn(comparisonList.BenchmarkSchools[0].Urn);

                comparisonList.BenchmarkSchools = new List <BenchmarkSchoolViewModel>();

                var school          = new SchoolViewModel(dynamicBenchmarkSchool);
                var benchmarkSchool = new BenchmarkSchoolViewModel()
                {
                    Address       = school.Address,
                    Name          = school.Name,
                    Phase         = school.OverallPhase,
                    Type          = school.Type,
                    FinancialType = school.FinancialType.ToString(),
                    Urn           = school.Id
                };

                comparisonList.BenchmarkSchools.Add(benchmarkSchool);
            }

            return(View(comparisonList));
        }