public static string GetContactInformation(this Vacancy vacancy, ProviderSite providerSite)
        {
            var sb = new StringBuilder();

            if (!vacancy.EditedInRaa)
            {
                sb.Append(providerSite.ContactDetailsForCandidate);
            }
            else
            {
                if (!string.IsNullOrEmpty(vacancy.ContactName))
                {
                    sb.Append(vacancy.ContactName);
                }
                if (!string.IsNullOrEmpty(vacancy.ContactNumber))
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(" ");
                    }
                    sb.Append(vacancy.ContactNumber);
                }
                if (!string.IsNullOrEmpty(vacancy.ContactEmail))
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(" ");
                    }
                    sb.Append(vacancy.ContactEmail);
                }
            }

            return(sb.ToString());
        }
        public static ProviderSiteViewModel Convert(this ProviderSite providerSite)
        {
            var viewModel = new ProviderSiteViewModel
            {
                ProviderSiteId             = providerSite.ProviderSiteId,
                EdsUrn                     = providerSite.EdsUrn,
                FullName                   = providerSite.FullName,
                TradingName                = providerSite.TradingName,
                EmployerDescription        = providerSite.EmployerDescription,
                CandidateDescription       = providerSite.CandidateDescription,
                ContactDetailsForEmployer  = providerSite.ContactDetailsForEmployer,
                ContactDetailsForCandidate = providerSite.ContactDetailsForCandidate,
                Address                    = providerSite.Address.Convert(),
                WebPage                    = providerSite.WebPage,
                TrainingProviderStatus     = providerSite.TrainingProviderStatus,
                ProviderSiteRelationships  = providerSite.ProviderSiteRelationships.Select(psr => psr.Convert()).ToList()
            };

            return(viewModel);
        }
 public ProviderSite SaveProviderSite(ProviderSite providerSite)
 {
     return(_providerSiteWriteRepository.Update(providerSite));
 }
 public ProviderSite CreateProviderSite(ProviderSite providerSite)
 {
     return(_providerSiteWriteRepository.Create(providerSite));
 }
        public static ApprenticeshipVacancyDetail GetApprenticeshipVacancyDetail(Vacancy vacancy, Employer employer, Provider provider, ProviderSite providerSite, IList <Category> categories, ILogService logService)
        {
            //Manually mapping rather than using automapper as the two enties are significantly different

            var subcategory = vacancy.GetSubCategory(categories);

            LogSubCategory(vacancy, logService, subcategory);

            var detail = new ApprenticeshipVacancyDetail
            {
                Id = vacancy.VacancyId,
                VacancyReference = vacancy.VacancyReferenceNumber.GetVacancyReference(),
                Title            = vacancy.Title,
                Description      = vacancy.ShortDescription,
                FullDescription  = vacancy.LongDescription,
                //SubCategory = vacancy.,
                StartDate   = vacancy.PossibleStartDate ?? DateTime.MinValue,
                ClosingDate = vacancy.ClosingDate ?? DateTime.MinValue,
                PostedDate  = vacancy.DateQAApproved ?? DateTime.MinValue,
                //TODO: Where should this come from?
                InterviewFromDate = DateTime.MinValue,
                Wage             = vacancy.Wage,
                WorkingWeek      = vacancy.WorkingWeek,
                HoursPerWeek     = vacancy.Wage.HoursPerWeek,
                OtherInformation = vacancy.OtherInformation,
                FutureProspects  = vacancy.FutureProspects,
                //TODO: Where from?
                //VacancyOwner = vacancy.,
                //VacancyManager = vacancy.,
                //LocalAuthority = vacancy.,
                NumberOfPositions         = vacancy.NumberOfPositions ?? 0,
                RealityCheck              = vacancy.ThingsToConsider,
                Created                   = vacancy.CreatedDateTime,
                VacancyStatus             = vacancy.Status.GetVacancyStatuses(),
                EmployerName              = employer.FullName,
                AnonymousEmployerName     = vacancy.EmployerAnonymousName,
                AnonymousAboutTheEmployer = vacancy.AnonymousAboutTheEmployer,
                IsEmployerAnonymous       = !string.IsNullOrWhiteSpace(vacancy.EmployerAnonymousName),
                EmployerDescription       = string.IsNullOrWhiteSpace(vacancy.AnonymousAboutTheEmployer) ? vacancy.EmployerDescription : vacancy.AnonymousAboutTheEmployer,
                EmployerWebsite           = vacancy.EmployerWebsiteUrl,
                ApplyViaEmployerWebsite   = vacancy.OfflineVacancy ?? false,
                VacancyUrl                = vacancy.OfflineApplicationUrl,
                ApplicationInstructions   = vacancy.OfflineApplicationInstructions,
                IsPositiveAboutDisability = employer.IsPositiveAboutDisability,
                ExpectedDuration          = vacancy.ExpectedDuration,
                VacancyAddress            = GetVacancyAddress(vacancy.Address),
                //TODO: How is this captured in RAA?
                //IsRecruitmentAgencyAnonymous = vacancy.,
                //TODO: How is this captured in RAA?
                //IsSmallEmployerWageIncentive = vacancy.,
                SupplementaryQuestion1 = vacancy.FirstQuestion,
                SupplementaryQuestion2 = vacancy.SecondQuestion,
                //TODO: How is this captured in RAA?
                RecruitmentAgency = providerSite.TradingName,
                ProviderName      = provider.TradingName,
                TradingName       = employer.TradingName,
                //ProviderDescription = vacancy.,
                Contact = vacancy.GetContactInformation(providerSite),
                TrainingToBeProvided = vacancy.TrainingProvided,
                //TODO: How is this captured in RAA?
                //ContractOwner = vacancy.,
                //DeliveryOrganisation = vacancy.,
                //IsNasProvider = vacancy.,
                PersonalQualities             = vacancy.PersonalQualities,
                QualificationRequired         = vacancy.DesiredQualifications,
                SkillsRequired                = vacancy.DesiredSkills,
                VacancyLocationType           = vacancy.VacancyLocationType == VacancyLocationType.Nationwide ? ApprenticeshipLocationType.National : ApprenticeshipLocationType.NonNational,
                ApprenticeshipLevel           = vacancy.ApprenticeshipLevel.GetApprenticeshipLevel(),
                SubCategory                   = subcategory.FullName,
                TrainingType                  = vacancy.TrainingType.GetTrainingType(),
                EditedInRaa                   = vacancy.EditedInRaa,
                AdditionalLocationInformation = vacancy.AdditionalLocationInformation
            };

            return(detail);
        }