private static BaseCourseEnrichmentViewModel GetCourseEnrichmentViewModel(UcasCourseEnrichmentGetModel ucasCourseEnrichmentGetModel, bool isSalary, CourseRouteDataViewModel routeData = null) { BaseCourseEnrichmentViewModel result = null; ucasCourseEnrichmentGetModel = ucasCourseEnrichmentGetModel ?? new UcasCourseEnrichmentGetModel(); var enrichmentModel = ucasCourseEnrichmentGetModel?.EnrichmentModel ?? new CourseEnrichmentModel(); if (isSalary) { result = new SalaryBasedCourseEnrichmentViewModel() { AboutCourse = enrichmentModel.AboutCourse, InterviewProcess = enrichmentModel.InterviewProcess, HowSchoolPlacementsWork = enrichmentModel.HowSchoolPlacementsWork, Qualifications = enrichmentModel.Qualifications, PersonalQualities = enrichmentModel.PersonalQualities, OtherRequirements = enrichmentModel.OtherRequirements, CourseLength = enrichmentModel.CourseLength.GetCourseLength(), CourseLengthInput = enrichmentModel.CourseLength.GetCourseLengthInput(), SalaryDetails = enrichmentModel.SalaryDetails, DraftLastUpdatedUtc = ucasCourseEnrichmentGetModel.UpdatedTimestampUtc, LastPublishedUtc = ucasCourseEnrichmentGetModel.LastPublishedTimestampUtc, RouteData = routeData }; } else { result = new FeeBasedCourseEnrichmentViewModel() { AboutCourse = enrichmentModel.AboutCourse, InterviewProcess = enrichmentModel.InterviewProcess, HowSchoolPlacementsWork = enrichmentModel.HowSchoolPlacementsWork, Qualifications = enrichmentModel.Qualifications, PersonalQualities = enrichmentModel.PersonalQualities, OtherRequirements = enrichmentModel.OtherRequirements, CourseLength = enrichmentModel.CourseLength.GetCourseLength(), CourseLengthInput = enrichmentModel.CourseLength.GetCourseLengthInput(), FeeUkEu = enrichmentModel.FeeUkEu.GetFeeValue(), FeeInternational = enrichmentModel.FeeInternational.GetFeeValue(), FeeDetails = enrichmentModel.FeeDetails, FinancialSupport = enrichmentModel.FinancialSupport, DraftLastUpdatedUtc = ucasCourseEnrichmentGetModel.UpdatedTimestampUtc, LastPublishedUtc = ucasCourseEnrichmentGetModel.LastPublishedTimestampUtc, RouteData = routeData }; } return(result); }
private CourseViewModel LoadViewModel(ProviderSummary org, Domain.Models.Course course, bool multipleOrganisations, UcasCourseEnrichmentGetModel ucasCourseEnrichmentGetModel, CourseRouteDataViewModel routeData) { var courseVariant = new ViewModels.CourseDetailsViewModel { CourseTitle = course.Name, Type = course.TypeDescription, AccreditingProviderName = course.AccreditingProvider?.ProviderName, AccreditingProviderCode = course.AccreditingProvider?.ProviderCode, CourseCode = course.CourseCode, ProviderCode = course.Provider.ProviderCode, AgeRange = course.AgeRange, Route = course.ProgramType, Qualifications = course.ProfpostFlag, StudyMode = course.StudyMode, Subjects = course.Subjects, Status = course.GetCourseStatus(), Sites = course.CourseSites.Select(courseSite => { var addressLines = (new List <string>() { courseSite.Site.Address1, courseSite.Site.Address2, courseSite.Site.Address3, courseSite.Site.Address4, courseSite.Site.Postcode }) .Where(line => !string.IsNullOrEmpty(line)); var address = addressLines.Count() > 0 ? addressLines.Where(line => !string.IsNullOrEmpty(line)) .Aggregate((string current, string next) => current + ", " + next) : ""; return(new SiteViewModel { ApplicationsAcceptedFrom = courseSite.ApplicationsAcceptedFrom.ToString(), Code = courseSite.Site.Code, LocationName = courseSite.Site.LocationName, Address = address, Status = courseSite.Status, VacStatus = courseSite.VacStatus }); }) }; var isSalary = course.ProgramType.Equals("SS", StringComparison.InvariantCultureIgnoreCase) || course.ProgramType.Equals("TA", StringComparison.InvariantCultureIgnoreCase); var courseEnrichmentViewModel = GetCourseEnrichmentViewModel(ucasCourseEnrichmentGetModel, isSalary, routeData); var viewModel = new CourseViewModel { ProviderName = org.ProviderName, ProviderCode = org.ProviderCode, CourseTitle = course.Name, AccreditingProviderCode = course.AccreditingProvider?.ProviderCode, MultipleOrganisations = multipleOrganisations, Course = courseVariant, CourseEnrichment = courseEnrichmentViewModel, LiveSearchUrl = searchAndCompareUrlService.GetCoursePageUri(org.ProviderCode, courseVariant.CourseCode), IsSalary = isSalary }; return(viewModel); }