public async Task <IActionResult> Get(int id) { var communityDTO = await _contextManager.GetCommunityByIdAsync(id); if (communityDTO == null) { return(NotFound("No community from given id found.")); } return(Ok(communityDTO.ToCommunityV1DTO())); }
private async Task <ServiceV1DTO> populateService(Service service) { var serviceDTO = service.ToServiceV1DTO(); foreach (var sca in service.ServiceCommunityAssociation) { int id; id = (int)sca.CommunityId; var comm = await _contextManager.GetCommunityByIdAsync(id); if (comm == null) { continue; } serviceDTO.CommunityDTOs.Add(comm.ToCommunityV1DTO()); } foreach (var sla in service.ServiceLanguageAssociation) { int id; id = (int)sla.LanguageId; var lang = await _contextManager.GetLanguageByIdAsync(id); if (lang == null) { continue; } serviceDTO.LanguageDTOs.Add(lang.ToLanguageV1DTO()); } foreach (var sla in service.ServiceLocationAssociation) { int id; id = (int)sla.LocationId; var loc = await _contextManager.GetLocationByIdAsync(id); if (loc == null) { continue; } serviceDTO.LocationDTOs.Add(loc.ToLocationV1DTO()); } return(serviceDTO); }