Example #1
0
        public MediatorResponse Delete(Guid candidateId, int vacancyId)
        {
            var viewModel = _apprenticeshipApplicationProvider.GetApplicationViewModel(candidateId, vacancyId);

            if (viewModel.HasError())
            {
                if (viewModel.Status != ApplicationStatuses.ExpiredOrWithdrawn)
                {
                    return(GetMediatorResponse(AccountMediatorCodes.Delete.AlreadyDeleted, MyApplicationsPageMessages.ApplicationDeleted, UserMessageLevel.Warning));
                }
            }

            var applicationViewModel = _apprenticeshipApplicationProvider.DeleteApplication(candidateId, vacancyId);

            if (applicationViewModel.HasError())
            {
                return(GetMediatorResponse(AccountMediatorCodes.Delete.ErrorDeleting, applicationViewModel.ViewModelMessage, UserMessageLevel.Warning));
            }

            if (viewModel.VacancyDetail == null)
            {
                return(GetMediatorResponse(AccountMediatorCodes.Delete.SuccessfullyDeletedExpiredOrWithdrawn, MyApplicationsPageMessages.ApplicationDeleted, UserMessageLevel.Success));
            }

            return(GetMediatorResponse(AccountMediatorCodes.Delete.SuccessfullyDeleted, viewModel.VacancyDetail.Title, UserMessageLevel.Success));
        }
        public MediatorResponse <ApprenticeshipApplicationViewModel> Resume(Guid candidateId, int vacancyId)
        {
            var model = _apprenticeshipApplicationProvider.GetApplicationViewModel(candidateId, vacancyId);

            if (model.HasError())
            {
                return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Resume.HasError, null, model.ViewModelMessage, UserMessageLevel.Warning));
            }

            if (model.IsExpiredOrWithdrawn())
            {
                return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Resume.HasError, null, MyApplicationsPageMessages.ApprenticeshipNoLongerAvailable, UserMessageLevel.Warning));
            }

            if (model.Status != ApplicationStatuses.Draft)
            {
                return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Resume.IncorrectState, null, MyApplicationsPageMessages.ApplicationInIncorrectState, UserMessageLevel.Info));
            }

            return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Resume.Ok, parameters: new { id = vacancyId }));
        }
Example #3
0
        public ActionResult Index()
        {
            var statusTasks = new[]
            {
                new Task(() => _apprenticeshipApplicationProvider.GetApplicationViewModel(Guid.NewGuid(), 123456)),
                new Task(() => _candidateServiceProvider.GetCandidate(Guid.NewGuid())),
                new Task(() => _searchProvider.FindLocation("London"))
            };

            Parallel.ForEach(statusTasks, task => task.Start());

            Task.WaitAll(statusTasks);

            // GDS Performance platform (Pingdom) is configured to look for the following text
            // in a 200 response. Anything other than this will register the site as down.
            return(Content("System healthy."));
        }
Example #4
0
        public MediatorResponse <ApprenticeshipApplicationViewModel> Submit(Guid candidateId, int vacancyId)
        {
            var savedModel = _apprenticeshipApplicationProvider.GetApplicationViewModel(candidateId, vacancyId);

            if (savedModel.HasError())
            {
                return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Submit.Error, null, ApplicationPageMessages.SubmitApplicationFailed, UserMessageLevel.Warning, new { id = vacancyId }));
            }

            if (savedModel.IsExpiredOrWithdrawn())
            {
                return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Submit.VacancyNotFound));
            }

            var result = _apprenticeshipApplicationViewModelSaveValidator.Validate(savedModel);

            if (!result.IsValid)
            {
                return(GetMediatorResponse(ApprenticeshipApplicationMediatorCodes.Submit.ValidationError, savedModel, result));
            }

            var model = _apprenticeshipApplicationProvider.SubmitApplication(candidateId, vacancyId);

            if (model.ViewModelStatus == ApplicationViewModelStatus.ApplicationInIncorrectState)
            {
                return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Submit.IncorrectState));
            }
            if (model.ViewModelStatus == ApplicationViewModelStatus.Error || model.HasError())
            {
                return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Submit.Error, null, ApplicationPageMessages.SubmitApplicationFailed, UserMessageLevel.Warning, new { id = vacancyId }));
            }

            var parameters = new
            {
                id = vacancyId,
                vacancyReference = model.VacancyDetail.VacancyReference,
                vacancyTitle     = model.VacancyDetail.Title
            };

            return(GetMediatorResponse <ApprenticeshipApplicationViewModel>(ApprenticeshipApplicationMediatorCodes.Submit.Ok, parameters: parameters));
        }