예제 #1
0
        private void SetUsersApplicationContext(Guid candidateId)
        {
            var applications       = _candidateServiceProvider.GetApprenticeshipApplications(candidateId).ToList();
            var savedAndDraftCount = applications.Count(each =>
                                                        each.Status == ApplicationStatuses.Draft || each.Status == ApplicationStatuses.Saved);

            _userDataProvider.Push(UserDataItemNames.SavedAndDraftCount, savedAndDraftCount.ToString(CultureInfo.InvariantCulture));

            var lastApplicationStatusNotification = _userDataProvider.Get(UserDataItemNames.LastApplicationStatusNotification);

            if (!string.IsNullOrWhiteSpace(lastApplicationStatusNotification))
            {
                var applicationStatuses = new[]
                {
                    ApplicationStatuses.Successful,
                    ApplicationStatuses.Unsuccessful,
                    ApplicationStatuses.ExpiredOrWithdrawn
                };

                var lastApplicationStatusNotificationDate = new DateTime(long.Parse(lastApplicationStatusNotification), DateTimeKind.Utc);

                var applicationStatusChangeCount = applications.Count(each =>
                                                                      each.DateUpdated > lastApplicationStatusNotificationDate &&
                                                                      each.DateApplied.HasValue &&
                                                                      applicationStatuses.Any(status => status == each.Status));

                if (applicationStatusChangeCount > 0)
                {
                    _userDataProvider.Push(UserDataItemNames.ApplicationStatusChangeCount, applicationStatusChangeCount.ToString(CultureInfo.InvariantCulture));
                }
            }
        }
예제 #2
0
        private void SetSavedVacancyStatuses(Guid candidateId, ApprenticeshipSearchResponseViewModel results)
        {
            var apprenticeshipApplications = _candidateServiceProvider.GetApprenticeshipApplications(candidateId, false).ToList();

            foreach (var result in results.Vacancies)
            {
                var apprenticeshipApplication = apprenticeshipApplications
                                                .SingleOrDefault(each => each.LegacyVacancyId == result.Id);

                result.CandidateApplicationStatus = apprenticeshipApplication == null
                    ? default(ApplicationStatuses?)
                                                    : apprenticeshipApplication.Status;
            }
        }