Esempio n. 1
0
        public MyApplicationsViewModel GetCandidateApplications(Guid candidateId)
        {
            _logService.Debug("Calling CandidateApprenticeshipApplicationProvider to get the applications for candidate ID: {0}.",
                              candidateId);

            try
            {
                var apprenticeshipApplicationSummaries = _candidateApplicationService.GetApprenticeshipApplications(candidateId);
                RecalculateSavedAndDraftCount(candidateId, apprenticeshipApplicationSummaries);

                var apprenticeshipApplications = apprenticeshipApplicationSummaries
                                                 .Select(each => new MyApprenticeshipApplicationViewModel(each))
                                                 .ToList();

                var traineeshipApplicationSummaries = _candidateApplicationService.GetTraineeshipApplications(candidateId);

                var traineeshipApplications = traineeshipApplicationSummaries
                                              .Select(each => new MyTraineeshipApplicationViewModel
                {
                    VacancyId     = each.LegacyVacancyId,
                    VacancyStatus = each.VacancyStatus,
                    Title         = each.Title,
                    EmployerName  = each.EmployerName,
                    IsArchived    = each.IsArchived,
                    DateApplied   = each.DateApplied
                })
                                              .ToList();

                var      traineeshipFeatureViewModel               = GetTraineeshipFeatureViewModel(candidateId, apprenticeshipApplicationSummaries, traineeshipApplicationSummaries);
                var      lastApplicationStatusNotification         = _userDataProvider.Get(UserDataItemNames.LastApplicationStatusNotification);
                DateTime?lastApplicationStatusNotificationDateTime = null;

                if (!string.IsNullOrWhiteSpace(lastApplicationStatusNotification))
                {
                    lastApplicationStatusNotificationDateTime = new DateTime(long.Parse(lastApplicationStatusNotification), DateTimeKind.Utc);
                }

                return(new MyApplicationsViewModel(apprenticeshipApplications, traineeshipApplications, traineeshipFeatureViewModel, lastApplicationStatusNotificationDateTime));
            }
            catch (Exception e)
            {
                var message = $"Get MyApplications failed for candidate ID: {candidateId}.";

                _logService.Error(message, e);

                throw;
            }
        }
        public CandidateApplicationsViewModel GetCandidateApplications(Guid candidateId)
        {
            var webSettings = _configurationService.Get <CommonWebConfiguration>();
            var domainUrl   = webSettings.SiteDomainName;

            _logService.Debug("Calling CandidateApprenticeshipApplicationProvider to get the applications for candidate ID: {0}.",
                              candidateId);

            try
            {
                var candidate     = _candidateApplicationService.GetCandidate(candidateId);
                var candidateName =
                    new Name(candidate.RegistrationDetails.FirstName, candidate.RegistrationDetails.MiddleNames,
                             candidate.RegistrationDetails.LastName).GetDisplayText();

                var apprenticeshipApplicationSummaries = _candidateApplicationService.GetApprenticeshipApplications(candidateId);
                var apprenticeshipApplications         = apprenticeshipApplicationSummaries
                                                         .Select(each => new CandidateApprenticeshipApplicationViewModel(each))
                                                         .ToList();

                var traineeshipApplicationSummaries = _candidateApplicationService.GetTraineeshipApplications(candidateId);
                var traineeshipApplications         = traineeshipApplicationSummaries
                                                      .Select(each => new CandidateTraineeshipApplicationViewModel
                {
                    ApplicationId = each.ApplicationId,
                    VacancyId     = each.LegacyVacancyId,
                    VacancyStatus = each.VacancyStatus,
                    Title         = each.Title,
                    EmployerName  = each.EmployerName,
                    IsArchived    = each.IsArchived,
                    DateApplied   = each.DateApplied
                })
                                                      .ToList();

                return(new CandidateApplicationsViewModel
                {
                    CandidateId = candidateId,
                    CandidateName = candidateName,
                    CandidateApprenticeshipApplications = apprenticeshipApplications,
                    CandidateTraineeshipApplications = traineeshipApplications,
                    NextStepUrl = string.Format($"https://{domainUrl}/nextsteps")
                });
            }
            catch (Exception e)
            {
                var message = $"Get MyApplications failed for candidate ID: {candidateId}.";

                _logService.Error(message, e);

                throw;
            }
        }