public ActionResult AddSchools()
        {
            var schoolComparisonListModel = _schoolBenchmarkListService.GetSchoolBenchmarkList();
            var vm = new SearchViewModel(schoolComparisonListModel, "");

            vm.Authorities = _laService.GetLocalAuthorities();

            return(View(vm));
        }
        /// <summary>
        /// Step 2 - Advanced
        /// </summary>
        /// <param name="urn"></param>
        /// <param name="comparisonType"></param>
        /// <param name="estType"></param>
        /// <returns></returns>
        public ViewResult ChooseRegion(int urn, ComparisonType comparisonType, EstablishmentType estType)
        {
            ViewBag.URN            = urn;
            ViewBag.ComparisonType = comparisonType;
            ViewBag.EstType        = estType;
            ViewBag.AreaType       = ComparisonArea.All;
            ViewBag.Authorities    = _laService.GetLocalAuthorities();

            var benchmarkSchool = new SchoolViewModel(_contextDataService.GetSchoolByUrn(urn.ToString()), base.ExtractSchoolComparisonListFromCookie());

            return(View("ChooseRegion", benchmarkSchool));
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            var schoolComparisonListModel = _schoolBenchmarkListService.GetSchoolBenchmarkList();
            var vm = new SearchViewModel(schoolComparisonListModel, "");

            vm.Authorities = _laService.GetLocalAuthorities();
            _manualBenchmarkListService.ClearManualBenchmarkList();
            _manualBenchmarkListService.SetSchoolAsDefaultInManualBenchmarkList(schoolComparisonListModel);
            return(View("Index", vm));
        }
        public List <LaModel> SearchContains(string name)
        {
            var localAuthorities =
                (List <dynamic>)JsonConvert.DeserializeObject <List <dynamic> >(_laService.GetLocalAuthorities());

            var filteredResults = localAuthorities
                                  .Where(la => la.LANAME.ToString().ToLowerInvariant().Contains(name.ToLowerInvariant()))
                                  .Select(la => new LaModel()
            {
                Id = la.id, LaName = la.LANAME
            })
                                  .ToList();

            return(filteredResults);
        }
        public ActionResult Index()
        {
            var vm = new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), null);

            vm.Authorities = _laService.GetLocalAuthorities();
            return(View(vm));
        }
Ejemplo n.º 6
0
        public ActionResult Index()
        {
            var vm = new SearchViewModel(_benchmarkBasketService.GetSchoolBenchmarkList(), null);

            vm.Authorities = _laService.GetLocalAuthorities();
            return(View(vm));
        }
Ejemplo n.º 7
0
        private ActionResult ErrorView(string searchType, string referrer, string errorMessage)
        {
            var searchVM = new SearchViewModel(_schoolBenchmarkListService.GetSchoolBenchmarkList(), searchType)
            {
                SearchType   = searchType,
                ErrorMessage = errorMessage,
                Authorities  = _laService.GetLocalAuthorities()
            };

            return(View("../" + referrer, searchVM));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Step 2 - Advanced
        /// </summary>
        /// <param name="urn"></param>
        /// <param name="comparisonType"></param>
        /// <param name="estType"></param>
        /// <returns></returns>
        public async Task <ViewResult> ChooseRegion(long?urn, ComparisonType comparisonType, EstablishmentType?estType, bool excludePartial = false)
        {
            ViewBag.URN            = urn;
            ViewBag.ComparisonType = comparisonType;
            ViewBag.EstType        = estType;
            //ViewBag.AreaType = ComparisonArea.All;
            ViewBag.Authorities    = _laService.GetLocalAuthorities();
            ViewBag.ExcludePartial = excludePartial.ToString();

            if (urn.HasValue)
            {
                var benchmarkSchool = new SchoolViewModel(await _contextDataService.GetSchoolDataObjectByUrnAsync(urn.Value), _benchmarkBasketService.GetSchoolBenchmarkList());

                if (estType.HasValue)
                {
                    return(View("ChooseRegion", benchmarkSchool));
                }

                benchmarkSchool.ErrorMessage = ErrorMessages.SelectSchoolType;

                ViewBag.URN            = urn;
                ViewBag.ComparisonType = comparisonType;

                return(View("SelectSchoolType", benchmarkSchool));
            }
            else
            {
                if (estType.HasValue)
                {
                    return(View("ChooseRegion", new SchoolViewModelWithNoDefaultSchool()));
                }

                var bs = new SchoolViewModelWithNoDefaultSchool
                {
                    ErrorMessage = ErrorMessages.SelectSchoolType
                };

                return(View("SelectSchoolType", bs));
            }
        }
        public async Task <ActionResult> Search(
            string nameId,
            string trustName,
            string searchType,
            string suggestionUrn,
            string locationorpostcode,
            string locationCoordinates,
            string laCodeName,
            decimal?radius,
            string orderby = "",
            int page       = 1,
            string tab     = "list")
        {
            dynamic searchResp = null;
            string  errorMessage;

            ViewBag.tab = tab;

            switch (searchType)
            {
            case SearchTypes.SEARCH_BY_NAME_ID:
                var nameIdSanitized = Regex.Replace(nameId, @"(-|/)", "");
                if (IsNumeric(nameIdSanitized))
                {
                    errorMessage = _valService.ValidateSchoolIdParameter(nameIdSanitized);
                    if (string.IsNullOrEmpty(errorMessage))
                    {
                        searchResp = IsLaEstab(nameId)
                                ? _contextDataService.GetSchoolByLaEstab(nameIdSanitized)
                                : _contextDataService.GetSchoolByUrn(nameIdSanitized);

                        if (searchResp == null)
                        {
                            return(View("EmptyResult",
                                        new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(),
                                                                  SearchTypes.SEARCH_BY_NAME_ID)));
                        }

                        nameId = ((Microsoft.Azure.Documents.Document)searchResp).GetPropertyValue <string>("URN");

                        return(RedirectToAction("Detail", "School", new { urn = nameId }));
                    }
                    else
                    {
                        var searchVM = new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), searchType)
                        {
                            SearchType   = searchType,
                            ErrorMessage = errorMessage,
                            Authorities  = _laService.GetLocalAuthorities()
                        };

                        return(View("../Home/Index", searchVM));
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(_valService.ValidateSchoolIdParameter(suggestionUrn)))
                    {
                        return(RedirectToAction("Detail", "School", new { urn = suggestionUrn }));
                    }

                    errorMessage = _valService.ValidateNameParameter(nameId);
                    if (string.IsNullOrEmpty(errorMessage))
                    {
                        // first see if we get a match on the word
                        searchResp = await GetSearchResults(nameId, searchType, null, null, null, null, radius,
                                                            orderby, page);

                        if (searchResp.NumberOfResults == 0)
                        {
                            return(RedirectToActionPermanent("SuggestSchool", "SchoolSearch",
                                                             new RouteValueDictionary {
                                { "nameId", nameId }
                            }));
                        }
                    }
                    else
                    {
                        var searchVM = new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), searchType)
                        {
                            SearchType   = searchType,
                            ErrorMessage = errorMessage,
                            Authorities  = _laService.GetLocalAuthorities()
                        };

                        return(View("../Home/Index", searchVM));
                    }
                }
                break;

            case SearchTypes.SEARCH_BY_TRUST_NAME:

                errorMessage = _valService.ValidateTrustNameParameter(trustName);
                if (string.IsNullOrEmpty(errorMessage))
                {
                    return(RedirectToAction("Search", "Trust", new { name = trustName }));
                }
                else
                {
                    var searchVM = new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), searchType)
                    {
                        SearchType   = searchType,
                        ErrorMessage = errorMessage,
                        Authorities  = _laService.GetLocalAuthorities()
                    };

                    return(View("../Home/Index", searchVM));
                }

            case SearchTypes.SEARCH_BY_LA_CODE_NAME:
                if (!IsNumeric(laCodeName))
                {
                    errorMessage = _valService.ValidateLaNameParameter(laCodeName);
                    if (string.IsNullOrEmpty(errorMessage))
                    {
                        var exactMatch = _laSearchService.SearchExactMatch(laCodeName);
                        if (exactMatch != null)
                        {
                            laCodeName = exactMatch.id;
                            return(await Search(nameId, trustName, searchType, suggestionUrn, locationorpostcode,
                                                locationCoordinates, laCodeName, radius, orderby, page, tab));
                        }
                        return(RedirectToAction("Search", "La", new { name = laCodeName }));
                    }
                    else
                    {
                        var searchVM = new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), searchType)
                        {
                            SearchType   = searchType,
                            ErrorMessage = errorMessage,
                            Authorities  = _laService.GetLocalAuthorities()
                        };

                        return(View("../Home/Index", searchVM));
                    }
                }
                else
                {
                    errorMessage = _valService.ValidateLaCodeParameter(laCodeName);
                    if (string.IsNullOrEmpty(errorMessage))
                    {
                        searchResp = await GetSearchResults(nameId, searchType, null, locationorpostcode,
                                                            locationCoordinates, laCodeName, radius, orderby, page);

                        int resultCount = searchResp.NumberOfResults;
                        switch (resultCount)
                        {
                        case 0:
                            return(View("EmptyResult",
                                        new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), searchType)));

                        case 1:
                            return(RedirectToAction("Detail", "School",
                                                    new
                            {
                                urn = ((Domain.Models.QueryResultsModel)searchResp).Results.First()["URN"]
                            }));
                        }
                    }
                    else
                    {
                        var searchVM = new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), searchType)
                        {
                            SearchType   = searchType,
                            ErrorMessage = errorMessage,
                            Authorities  = _laService.GetLocalAuthorities()
                        };

                        return(View("../Home/Index", searchVM));
                    }
                }

                break;

            case SearchTypes.SEARCH_BY_LOCATION:
                errorMessage = _valService.ValidateLocationParameter(locationorpostcode);
                if (string.IsNullOrEmpty(errorMessage))
                {
                    searchResp = await GetSearchResults(nameId, searchType, null, locationorpostcode,
                                                        locationCoordinates, laCodeName, radius, orderby, page);

                    int resultCnt = searchResp.NumberOfResults;
                    switch (resultCnt)
                    {
                    case 0:
                        return(View("EmptyResult",
                                    new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), searchType)));

                    case 1:
                        return(RedirectToAction("Detail", "School",
                                                new { urn = ((Domain.Models.QueryResultsModel)searchResp).Results.First()["URN"] }));
                    }
                }
                else
                {
                    var searchVM = new SchoolSearchViewModel(base.ExtractSchoolComparisonListFromCookie(), searchType)
                    {
                        SearchType   = searchType,
                        ErrorMessage = errorMessage,
                        Authorities  = _laService.GetLocalAuthorities()
                    };

                    return(View("../Home/Index", searchVM));
                }
                break;
            }

            var laName = _laService.GetLaName(laCodeName);

            return(View("SearchResults", GetSchoolViewModelList(searchResp, orderby, page, searchType, nameId, locationorpostcode, laName)));
        }