コード例 #1
0
        public async Task <IActionResult> BuildingId([FromQuery][Required] string buildingId)
        {
            var locations = await _contextManager.GetLocationsByBuildingId(buildingId);

            if (locations.Count() == 0)
            {
                return(NotFound("No locations found from given building id."));
            }

            var locationIds = new List <int>();

            foreach (var l in locations)
            {
                locationIds.Add(l.LocationId);
            }

            var slas = await _contextManager.GetServiceLocationAssociationsByLocationIdListAsync(locationIds);

            if (slas.Count() == 0)
            {
                return(NotFound("Location(s) found have no relationships to any services."));
            }

            var serviceIds = new List <int>();

            foreach (var sla in slas)
            {
                serviceIds.Add(sla.ServiceId);
            }

            var services = await _contextManager.GetServicesFromIdList(serviceIds);

            var serviceDTOs = new List <ServiceV1DTO>();

            foreach (var service in services)
            {
                serviceDTOs.Add(await populateService(service));
            }

            return(Ok(serviceDTOs));
        }