public IActionResult Index(string providerCode, string courseCode, ResultsFilter filter)
        {
            if (featureFlags.RedirectToRailsPageCourse)
            {
                return(redirectUrlService.RedirectToNewApp("/course/" + $"{providerCode}" + "/" + $"{courseCode}"));
            }

            var course  = _api.GetCourse(providerCode, courseCode);
            var feeCaps = _api.GetFeeCaps();

            var latestFeeCaps = feeCaps.OrderByDescending(x => x.EndYear).FirstOrDefault();

            if (course == null || latestFeeCaps == null)
            {
                return(NotFound());
            }

            var viewModel = new CourseDetailsViewModel()
            {
                Course      = course,
                Finance     = new Shared.ViewModels.FinanceViewModel(course, latestFeeCaps),
                PreviewMode = false
            };

            return(View(viewModel));
        }
        public IActionResult SubjectGet(ResultsFilter filter)
        {
            if (_featureFlags.RedirectToRailsPageSubject)
            {
                return(_redirectUrlService.RedirectToNewApp());
            }

            var subjectAreas = _api.GetSubjectAreas();

            var viewModel = new SubjectFilterViewModel
            {
                SubjectAreas = subjectAreas,
                FilterModel  = filter
            };

            ViewBag.Errors = TempData.Get <ErrorViewModel>("Errors");

            return(View("Subject", viewModel));
        }
Beispiel #3
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));
        }
Beispiel #4
0
 public IActionResult Index(string providerCode, string courseCode, ResultsFilter filter)
 {
     return(redirectUrlService.RedirectToNewApp("/course/" + $"{providerCode}" + "/" + $"{courseCode}"));
 }