public async Task <IActionResult> Community([FromQuery][Required] string community) { try { //this can be changed to check if the community name contains the input, for now im going for an explicit match of them lowercased var comm = await _contextManager.GetCommunityByNameAsync(community); if (comm == null) { return(NotFound("Community given does not exist.")); } //fetch any ServiceCommunityAssociations that have our community's id, then grab the service ids to prep the next DB call to get only the services we want var scas = await _contextManager.GetServiceCommunityAssociationsByCommunityIdAsync(comm.CommunityId); if (scas.Count() == 0) { return(NotFound("Community has no relationships.")); } var ids = new List <int>(); //nullable for now, schema has these ids nullable at the moment, will probably fix this in next sprint foreach (var sca in scas) { ids.Add(sca.ServiceId); } //fetch only the services with the service ids we just got from the SCAs, then convert to DTO var services = _contextManager.GetServicesFromIdList(ids).Result; var serviceDTOs = new List <ServiceV1DTO>(); foreach (var service in services) { serviceDTOs.Add(await populateService(service)); } return(Ok(serviceDTOs)); } catch (Exception e) { throw e; } }