Пример #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
        protected int GetResultsPerPage()
        {
            int resultsPerPage;

            if (!int.TryParse(UserDataProvider.Get(UserDataItemNames.ResultsPerPage), out resultsPerPage))
            {
                resultsPerPage = _vacancyResultsPerPage;
            }

            return(resultsPerPage);
        }
Пример #3
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 void SendToMail(string userId, Guid rAnimalId)
        {
            var animal = _registeredAnimalProvider.Get(rAnimalId);

            if (animal == null)
            {
                throw new ApiException(HttpStatusCode.Forbidden, ApiError.NotFound);
            }
            if (!animal.UserId.Equals(userId))
            {
                throw new ApiException(HttpStatusCode.Forbidden, ApiError.AccessForbidden);
            }

            var user = _userDataProvider.Get(userId);
            var file = _fileService.Get(new Guid(animal.QR));

            _emailService.Generate(user.Email, "QRCode", new EmailObject {
            }, MailConstant.QR_CODE, new [] { file });
        }
Пример #5
0
        public List <DataPoint> GenerateData()
        {
            List <UserData> userDataList = _userDataFactory.Get();

            return(userDataList.Select(userData => userData.ConvertToDataPoint()).ToList());
        }