public MyApplicationsViewModel(
            IEnumerable <MyApprenticeshipApplicationViewModel> apprenticeshipApplications,
            IEnumerable <MyTraineeshipApplicationViewModel> traineeshipApplications,
            TraineeshipFeatureViewModel traineeshipFeature)
        {
            AllApprenticeshipApplications = apprenticeshipApplications
                                            .Where(a => !a.IsArchived)
                                            .OrderByDescending(a => a.DateUpdated);

            TraineeshipApplications = traineeshipApplications
                                      .Where(a => !a.IsArchived)
                                      .OrderByDescending(a => a.DateApplied);

            TraineeshipFeature = traineeshipFeature;
        }
Example #2
0
        private TraineeshipFeatureViewModel GetTraineeshipFeatureViewModel(Guid candidateId, IList <ApprenticeshipApplicationSummary> apprenticeshipApplicationSummaries, IList <TraineeshipApplicationSummary> traineeshipApplicationSummaries)
        {
            var candididate = _candidateService.GetCandidate(candidateId);

            var unsuccessfulApplicationsToShowTraineeshipsPrompt = _configurationManager.GetCloudAppSetting <int>("UnsuccessfulApplicationsToShowTraineeshipsPrompt");
            var allowTraineeshipPrompts = candididate.CommunicationPreferences.AllowTraineeshipPrompts;

            var sufficentUnsuccessfulApprenticeshipApplicationsToPrompt = apprenticeshipApplicationSummaries.Count(each => each.Status == ApplicationStatuses.Unsuccessful) >= unsuccessfulApplicationsToShowTraineeshipsPrompt;
            var candidateHasSuccessfulApprenticeshipApplication         = apprenticeshipApplicationSummaries.Any(each => each.Status == ApplicationStatuses.Successful);
            var candidateHasAppliedForTraineeship = traineeshipApplicationSummaries.Any();

            var viewModel = new TraineeshipFeatureViewModel
            {
                ShowTraineeshipsPrompt = allowTraineeshipPrompts && sufficentUnsuccessfulApprenticeshipApplicationsToPrompt && !candidateHasSuccessfulApprenticeshipApplication && !candidateHasAppliedForTraineeship,
                ShowTraineeshipsLink   = (sufficentUnsuccessfulApprenticeshipApplicationsToPrompt || candidateHasAppliedForTraineeship)
            };

            return(viewModel);
        }
Example #3
0
 public MyApplicationsViewModelBuilder With(TraineeshipFeatureViewModel traineeshipFeatureViewModel)
 {
     _traineeshipFeatureViewModel = traineeshipFeatureViewModel;
     return(this);
 }
Example #4
0
 public MyApplicationsViewModelBuilder()
 {
     _apprenticeshipApplicationViewModels = new List <MyApprenticeshipApplicationViewModel>();
     _traineeshipApplicationViewModels    = new List <MyTraineeshipApplicationViewModel>();
     _traineeshipFeatureViewModel         = new TraineeshipFeatureViewModel();
 }