public async Task <IEnumerable <CommunicationUser> > GetParticipantsAsync(CommunicationRequest request)
        {
            _logger.LogDebug($"Resolving participants for RequestType: '{request.RequestType}'");

            var entityId = request.Entities.Single(e => e.EntityType == CommunicationConstants.EntityTypes.Vacancy).EntityId.ToString();

            if (long.TryParse(entityId, out var vacancyReference) == false)
            {
                return(Array.Empty <CommunicationUser>());
            }

            var vacancy = await _vacancyRepository.GetVacancyAsync(vacancyReference);

            List <User> users = null;

            if (vacancy.OwnerType == OwnerType.Employer)
            {
                users = await _userRepository.GetEmployerUsersAsync(vacancy.EmployerAccountId);
            }
            else
            {
                users = await _userRepository.GetProviderUsersAsync(vacancy.TrainingProvider.Ukprn.GetValueOrDefault());
            }

            var primaryUserIdamsId = vacancy.Status == VacancyStatus.Rejected ? vacancy.ReviewByUser?.UserId : vacancy.SubmittedByUser?.UserId;

            return(ParticipantResolverPluginHelper.ConvertToCommunicationUsers(users, primaryUserIdamsId));
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <CommunicationUser> > GetParticipantsAsync(CommunicationRequest request)
        {
            _logger.LogInformation($"Resolving participants for RequestType: '{request.RequestType}'");
            var employerAccountId = request.Entities.Single(e => e.EntityType == CommunicationConstants.EntityTypes.Employer).EntityId.ToString();

            if (string.IsNullOrWhiteSpace(employerAccountId))
            {
                return(Array.Empty <CommunicationUser>());
            }
            var users = await _userRepository.GetEmployerUsersAsync(employerAccountId);

            return(ParticipantResolverPluginHelper.ConvertToCommunicationUsers(users, null));
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <CommunicationUser> > GetParticipantsAsync(CommunicationRequest request)
        {
            _logger.LogInformation($"Resolving participants for RequestType: '{request.RequestType}'");
            var entityId = request.Entities.Single(e => e.EntityType == CommunicationConstants.EntityTypes.Provider).EntityId.ToString();

            if (long.TryParse(entityId, out var ukprn) == false)
            {
                _logger.LogInformation($"entity id: {entityId} is invalid ukprn for RequestType: '{request.RequestType}' and request id: {request.RequestId}");
                return(Array.Empty <CommunicationUser>());
            }
            var users = await _userRepository.GetProviderUsersAsync(ukprn);

            return(ParticipantResolverPluginHelper.ConvertToCommunicationUsers(users, null));
        }