Ejemplo n.º 1
0
        public IActionResult Index(ResultsFilter filter)
        {
            if (_featureFlags.RedirectToRailsPageResults)
            {
                return(_redirectUrlService.RedirectToNewApp());
            }

            var subjects = _api.GetSubjects();

            if (subjects == null)
            {
                throw new Exception("Failed to retrieve subject list from api");
            }
            filter.qualifications = !string.IsNullOrWhiteSpace(filter.qualifications) ? filter.qualifications : string.Join(",", Enum.GetNames(typeof(QualificationOption)));
            FilteredList <Subject> filteredSubjects;

            if (filter.SelectedSubjects.Count > 0)
            {
                filteredSubjects = new FilteredList <Subject>(
                    subjects.Where(subject => filter.SelectedSubjects.Contains(subject.Id)).ToList(),
                    subjects.Count
                    );
            }
            else
            {
                filteredSubjects = new FilteredList <Subject>(subjects, subjects.Count);
            }

            var mapsEnabled = _featureFlags.Maps;

            var queryFilter = filter.ToQueryFilter();

            var viewModel = new ResultsViewModel
            {
                Subjects    = filteredSubjects,
                FilterModel = filter,
                MapsEnabled = mapsEnabled
            };

            queryFilter.pageSize = 10;

            viewModel.Courses = _api.GetCourses(queryFilter);

            return(View(viewModel));
        }
        private string GetSiteMapContents()
        {
            var emptyQuery = new ResultsFilter().ToQueryFilter();

            emptyQuery.pageSize = 10_000_000;

            var allCourses = _api.GetCourses(emptyQuery).Items;

            var stringBuilder = new StringBuilder();

            foreach (var item in allCourses)
            {
                var action = Url.Action("Index", "Course", new { providerCode = item.Provider.ProviderCode, courseCode = item.ProgrammeCode }, Request.Scheme);
                stringBuilder.AppendLine(action);
            }

            return(stringBuilder.ToString());
        }