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); }
private static Func <AccreditingProviderEnrichment, bool> TrainingProviderMatchesProviderCourse(Domain.Models.Course x) { return(y => String.Equals(x.AccreditingProvider?.ProviderCode, y.UcasProviderCode, StringComparison.InvariantCultureIgnoreCase)); }
public SearchAndCompare.Domain.Models.Course MapToSearchAndCompareCourse(Domain.Models.Provider ucasProviderData, Domain.Models.Course ucasCourseData, ProviderEnrichmentModel providerEnrichmentModel, CourseEnrichmentModel courseEnrichmentModel) { ucasProviderData = ucasProviderData ?? new Domain.Models.Provider(); ucasCourseData = ucasCourseData ?? new Domain.Models.Course(); var courseSites = ucasCourseData.PublishableSites ?? new ObservableCollection <CourseSite>(); providerEnrichmentModel = providerEnrichmentModel ?? new ProviderEnrichmentModel(); courseEnrichmentModel = courseEnrichmentModel ?? new CourseEnrichmentModel(); var useUcasContact = string.IsNullOrWhiteSpace(providerEnrichmentModel.Email) && string.IsNullOrWhiteSpace(providerEnrichmentModel.Website) && string.IsNullOrWhiteSpace(providerEnrichmentModel.Address1) && string.IsNullOrWhiteSpace(providerEnrichmentModel.Address2) && string.IsNullOrWhiteSpace(providerEnrichmentModel.Address3) && string.IsNullOrWhiteSpace(providerEnrichmentModel.Address4) && string.IsNullOrWhiteSpace(providerEnrichmentModel.Postcode); var subjectStrings = ucasCourseData?.CourseSubjects != null ? subjectMapper.GetSubjectList(ucasCourseData.Name, ucasCourseData.CourseSubjects.Select(x => x.Subject.SubjectName)) : new List <string>(); var subjects = new Collection <SearchAndCompare.Domain.Models.Joins.CourseSubject>(subjectStrings.Select(subject => new SearchAndCompare.Domain.Models.Joins.CourseSubject { Subject = new SearchAndCompare.Domain.Models.Subject { Name = subject } }).ToList()); var provider = new SearchAndCompare.Domain.Models.Provider { Name = ucasProviderData.ProviderName, ProviderCode = ucasProviderData.ProviderCode }; var accreditingProvider = ucasCourseData.AccreditingProvider == null ? null : new SearchAndCompare.Domain.Models.Provider { Name = ucasCourseData.AccreditingProvider.ProviderName, ProviderCode = ucasCourseData.AccreditingProvider.ProviderCode }; var routeName = ucasCourseData.Route; var isSalaried = string.Equals(ucasCourseData?.ProgramType, "ss", StringComparison.InvariantCultureIgnoreCase) || string.Equals(ucasCourseData?.ProgramType, "ta", StringComparison.InvariantCultureIgnoreCase); var fees = courseEnrichmentModel.FeeUkEu.HasValue ? new Fees { Uk = (int)(courseEnrichmentModel.FeeUkEu ?? 0), Eu = (int)(courseEnrichmentModel.FeeUkEu ?? 0), International = (int)(courseEnrichmentModel.FeeInternational ?? 0), } : new Fees(); var address = useUcasContact ? MapAddress(ucasProviderData) : MapAddress(providerEnrichmentModel); var mappedCourse = new SearchAndCompare.Domain.Models.Course { ProviderLocation = new Location { Address = address }, Duration = MapCourseLength(courseEnrichmentModel.CourseLength), StartDate = ucasCourseData.StartDate, Name = ucasCourseData.Name, ProgrammeCode = ucasCourseData.CourseCode, Provider = provider, AccreditingProvider = accreditingProvider, IsSen = ucasCourseData.IsSend, Route = new Route { Name = routeName, IsSalaried = isSalaried }, IncludesPgce = MapQualification(ucasCourseData.Qualification), HasVacancies = ucasCourseData.HasVacancies, Campuses = new Collection <SearchAndCompare.Domain.Models.Campus>( courseSites .Select(school => new SearchAndCompare.Domain.Models.Campus { Name = school.Site.LocationName, CampusCode = school.Site.Code, Location = new Location { Address = MapAddress(school.Site) }, VacStatus = school.VacStatus } ).ToList()), CourseSubjects = subjects, Fees = fees, IsSalaried = isSalaried, ContactDetails = new Contact { Phone = useUcasContact ? ucasProviderData.Telephone : providerEnrichmentModel.Telephone, Email = useUcasContact ? ucasProviderData.Email : providerEnrichmentModel.Email, Website = useUcasContact ? ucasProviderData.Url : providerEnrichmentModel.Website, Address = address }, ApplicationsAcceptedFrom = courseSites.Select(x => x.ApplicationsAcceptedFrom).Where(x => x.HasValue) .OrderBy(x => x.Value) .FirstOrDefault(), FullTime = ucasCourseData.StudyMode == "P" ? VacancyStatus.NA : VacancyStatus.Vacancies, PartTime = ucasCourseData.StudyMode == "F" ? VacancyStatus.NA : VacancyStatus.Vacancies, Mod = ucasCourseData.TypeDescription, }; mappedCourse.DescriptionSections = new Collection <CourseDescriptionSection>(); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { //TODO move the CourseDetailsSections constants into SearchAndCompare.Domain.Models // but this will work ftm Name = "about this training programme",//CourseDetailsSections.AboutTheCourse, Text = courseEnrichmentModel.AboutCourse }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "interview process",//CourseDetailsSections.InterviewProcess, Text = courseEnrichmentModel.InterviewProcess }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "about fees",//CourseDetailsSections.AboutFees, Text = courseEnrichmentModel.FeeDetails }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "about salary",//CourseDetailsSections.AboutSalary, Text = courseEnrichmentModel.SalaryDetails }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "entry requirements",//CourseDetailsSections.EntryRequirementsQualifications, Text = courseEnrichmentModel.Qualifications }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "entry requirements personal qualities",//CourseDetailsSections.EntryRequirementsPersonalQualities, Text = courseEnrichmentModel.PersonalQualities }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "entry requirements other",//CourseDetailsSections.EntryRequirementsOther, Text = courseEnrichmentModel.OtherRequirements }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "financial support",//CourseDetailsSections.FinancialSupport, Text = courseEnrichmentModel.FinancialSupport }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "about school placements",//CourseDetailsSections.AboutSchools, Text = courseEnrichmentModel.HowSchoolPlacementsWork }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "about this training provider",//CourseDetailsSections.AboutTheProvider, Text = providerEnrichmentModel.TrainWithUs }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "about this training provider accrediting",//CourseDetailsSections.AboutTheAccreditingProvider, Text = GetAccreditingProviderEnrichment(ucasCourseData?.AccreditingProvider?.ProviderCode, providerEnrichmentModel) }); mappedCourse.DescriptionSections.Add(new CourseDescriptionSection { Name = "training with disabilities",//CourseDetailsSections.TrainWithDisabilities, Text = providerEnrichmentModel.TrainWithDisability }); return(mappedCourse); }