private async Task <SubmitVacancyResponse> SubmitActionAsync(Vacancy vacancy, VacancyUser user)
        {
            var hasLegalEntityAgreementTask = _legalEntityAgreementService.HasLegalEntityAgreementAsync(vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId);
            var hasProviderAgreementTask    = _trainingProviderAgreementService.HasAgreementAsync(vacancy.TrainingProvider.Ukprn.Value);

            await Task.WhenAll(hasLegalEntityAgreementTask, hasProviderAgreementTask);

            var response = new SubmitVacancyResponse
            {
                HasLegalEntityAgreement = hasLegalEntityAgreementTask.Result,
                HasProviderAgreement    = hasProviderAgreementTask.Result,
                IsSubmitted             = false
            };

            if (response.HasLegalEntityAgreement && response.HasProviderAgreement)
            {
                var command = new SubmitVacancyCommand(vacancy.Id, user, OwnerType.Provider);

                await _messaging.SendCommandAsync(command);

                response.IsSubmitted = true;
            }

            return(response);
        }
Exemplo n.º 2
0
        private async Task <SubmitVacancyResponse> SubmitActionAsync(Vacancy vacancy, VacancyUser user)
        {
            var hasLegalEntityAgreementTask = _legalEntityAgreementService.HasLegalEntityAgreementAsync(vacancy.EmployerAccountId, vacancy.LegalEntityId);
            var hasProviderAgreementTask    = _trainingProviderAgreementService.HasAgreementAsync(vacancy.TrainingProvider.Ukprn.Value);

            await Task.WhenAll(hasLegalEntityAgreementTask, hasProviderAgreementTask);

            var response = new SubmitVacancyResponse
            {
                HasLegalEntityAgreement = hasLegalEntityAgreementTask.Result,
                HasProviderAgreement    = hasProviderAgreementTask.Result,
                IsSubmitted             = false
            };

            if (response.HasLegalEntityAgreement && response.HasProviderAgreement)
            {
                await _client.SubmitVacancyAsync(vacancy.Id, user);

                response.IsSubmitted = true;
            }

            return(response);
        }
        private async Task <SubmitVacancyResponse> SubmitActionAsync(Vacancy vacancy, VacancyUser user)
        {
            var hasLegalEntityAgreementTask = _legalEntityAgreementService.HasLegalEntityAgreementAsync(vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId);
            var hasProviderAgreementTask    = _trainingProviderAgreementService.HasAgreementAsync(vacancy.TrainingProvider.Ukprn.Value);

            await Task.WhenAll(hasLegalEntityAgreementTask, hasProviderAgreementTask);

            var hasProviderReviewPermission = await _providerRelationshipsService.HasProviderGotEmployersPermissionAsync(vacancy.TrainingProvider.Ukprn.Value, vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId, OperationType.RecruitmentRequiresReview);

            var response = new SubmitVacancyResponse
            {
                HasLegalEntityAgreement = hasLegalEntityAgreementTask.Result,
                HasProviderAgreement    = hasProviderAgreementTask.Result,
                IsSubmitted             = false
            };

            if (response.HasLegalEntityAgreement && response.HasProviderAgreement)
            {
                if (hasProviderReviewPermission)
                {
                    var command = new ReviewVacancyCommand(vacancy.Id, user, OwnerType.Provider);
                    await _messaging.SendCommandAsync(command);

                    response.IsSentForReview = true;
                }
                else
                {
                    var command = new SubmitVacancyCommand(vacancy.Id, user, OwnerType.Provider);
                    await _messaging.SendCommandAsync(command);

                    response.IsSubmitted = true;
                }
            }

            return(response);
        }