Ejemplo n.º 1
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);
        }