예제 #1
0
        public async Task <List <ContactResponse> > Handle(GetContactsWhoCanBePrimaryForOrganisationRequest request, CancellationToken cancellationToken)
        {
            var response = new List <ContactResponse>();
            var contacts = await _contactQueryRepository.GetContactsForEpao(request.EndPointAssessorOrganisationId);

            if (contacts == null)
            {
                return(response);
            }
            return(Mapper.Map <List <ContactResponse> >(
                       contacts.Where(x => x.Status == ContactStatus.Live)));
        }
        public async Task <IActionResult> SearchContactsForAnOrganisation(string endPointAssessorOrganisationId)
        {
            _logger.LogInformation(
                $"Received Search for Contacts using endPointAssessorOrganisationId = {endPointAssessorOrganisationId}");

            var result = _searchOrganisationForContactsValidator.Validate(endPointAssessorOrganisationId);

            if (!result.IsValid)
            {
                throw new ResourceNotFoundException(result.Errors[0].ErrorMessage);
            }

            var contacts =
                Mapper.Map <List <ContactResponse> >(await _contactQueryRepository.GetContactsForEpao(endPointAssessorOrganisationId)).ToList();

            return(Ok(contacts));
        }