Beispiel #1
0
 public void Update(Domain.Models.Provider entity)
 {
     throw new NotImplementedException();
 }
Beispiel #2
0
 public async Task <int> UpdateAsync(Domain.Models.Provider provider)
 {
     _unit.ProviderRepository.Update(provider.Id, provider);
     return(await _unit.CommitChangesAsync());
 }
Beispiel #3
0
        public async Task Then_Make_TLevel_Provider_Flag_To_True(
            MatchingDbContext dbContext,
            Domain.Models.Provider provider,
            List <ProviderVenueViewModel> venueViewModels,
            MatchingConfiguration config,
            ILogger <GenericRepository <Domain.Models.Provider> > providerLogger,
            ILogger <GenericRepository <ProviderReference> > providerReferenceLogger,
            IHttpContextAccessor httpContextAccessor,
            IDateTimeProvider dateTimeProvider
            )
        {
            //Arrange
            provider.IsTLevelProvider = false;

            await dbContext.AddAsync(provider);

            await dbContext.SaveChangesAsync();

            dbContext.Entry(provider).State = EntityState.Detached;

            var viewModel = new ProviderDetailViewModel
            {
                Id = provider.Id,
                IsTLevelProvider = true,
                ProviderVenues   = venueViewModels
            };

            httpContextAccessor.HttpContext.Returns(new DefaultHttpContext
            {
                User = new ClaimsPrincipal(new ClaimsIdentity(new[]
                {
                    new Claim(ClaimTypes.GivenName, "System")
                }))
            });

            var mapperConfig = new MapperConfiguration(c =>
            {
                c.AddMaps(typeof(ProviderMapper).Assembly);
                c.ConstructServicesUsing(type =>
                                         type.Name.Contains("LoggedInUserNameResolver")
                        ? (object)new LoggedInUserNameResolver <ProviderDetailViewModel, Domain.Models.Provider>(httpContextAccessor)
                        : type.Name.Contains("UtcNowResolver")
                                ? new UtcNowResolver <ProviderDetailViewModel, Domain.Models.Provider>(dateTimeProvider)
                                : null);
            });

            var mapper = new Mapper(mapperConfig);

            var providerReferenceRepo = new GenericRepository <ProviderReference>(providerReferenceLogger, dbContext);
            var repo            = new GenericRepository <Domain.Models.Provider>(providerLogger, dbContext);
            var providerService = new ProviderService(mapper, repo, providerReferenceRepo);

            var sut = new ProviderController(providerService, config);

            //Act
            await sut.SaveProviderDetailAsync(viewModel);

            //Assert
            var result = await repo.GetSingleOrDefaultAsync(x => x.Id == provider.Id);

            provider.IsTLevelProvider.Should().BeFalse();
            result.IsTLevelProvider.Should().BeTrue();
        }
Beispiel #4
0
 public async Task <int> AddAsync(Domain.Models.Provider provider)
 {
     _unit.ProviderRepository.Add(provider);
     return(await _unit.CommitChangesAsync());
 }
        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);
        }