public async Task <IActionResult> Language([FromQuery][Required] string lang, int pageSize = 20, int pageNum = 0) { //massage query string into a list var langNames = lang.Split(','); var langNamesList = new List <string>(langNames); var langs = await _contextManager.GetLanguagesByNameListAsync(langNamesList); if (langs.Count() == 0) { return(NotFound("No languages from given names found.")); } var langIds = new List <int>(); foreach (var language in langs) { langIds.Add(language.LanguageId); } var slas = await _contextManager.GetServiceLanguageAssociationsByLanguageIdListAsync(langIds); if (slas.Count() == 0) { return(NotFound("No relationships found for given language(s).")); } var serviceIds = new List <int>(); foreach (var sla in slas) { serviceIds.Add(sla.ServiceId); } var services = await _contextManager.GetServicesFromIdListPaginated(serviceIds, pageSize, pageNum); var serviceDTOs = new List <ServiceV1DTO>(); foreach (var service in services) { serviceDTOs.Add(await populateService(service)); } return(Ok(serviceDTOs)); }