Ejemplo n.º 1
0
 public async Task <IActionResult> GetAsync()
 {
     try
     {
         return(Ok(await _ooParkingLotRepository.GetAllEntryPointsAsync()));
     }
     catch (Exception ex)
     {
         _logger.LogError(JsonConvert.SerializeObject(ex));
         return(BadRequest());
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetAsync()
        {
            try
            {
                List <ParkingDistance> parkingDistances = await _ooParkingLotRepository.GetAllDistancesAsync();

                List <EntryPoint> entryPoints = await _ooParkingLotRepository.GetAllEntryPointsAsync();

                List <ParkingSpace> parkingSpaces = await _ooParkingLotRepository.GetAllParkingSpacesAsync();

                object res = from ps in parkingSpaces
                             orderby ps.Code
                             select new
                {
                    ParkingSpaceCode = ps.Code,
                    ps.IsOccupied,
                    EntryPoints = from pd in parkingDistances
                                  join ep in entryPoints on pd.EntryPointId equals ep.Id
                                  where ps.Id == pd.ParkingSpaceId
                                  orderby ep.Name
                                  select new
                    {
                        EntryPointName = ep.Name,
                        pd.DistanceInMeters
                    }
                };


                return(Ok(res));
            }
            catch (Exception ex)
            {
                _logger.LogError(JsonConvert.SerializeObject(ex));
                return(BadRequest());
            }
        }