Ejemplo n.º 1
0
        public async Task <DistanceDTO> Get(string iataCode1, string iataCode2)
        {
            if (Validation.ValidateIataCode(iataCode1) && Validation.ValidateIataCode(iataCode2))
            {
                string[]          iataCodes = { iataCode1.ToUpper(), iataCode2.ToUpper() };
                List <AirportDTO> _airports = await _airportService.GetAirports(iataCodes);

                DistanceDTO _distance = new DistanceDTO();

                if (_airports != null)
                {
                    GeoCoordinate pin1 = new GeoCoordinate(_airports[0].Location.Lat, _airports[0].Location.Lon);
                    GeoCoordinate pin2 = new GeoCoordinate(_airports[1].Location.Lat, _airports[1].Location.Lon);

                    double distanceBetween = pin1.GetDistanceTo(pin2);
                    if (_airports[0].Name != null)
                    {
                        _distance.FirstAirportName = _airports[0].Name;
                    }
                    if (_airports.Count > 1 && _airports[1].Name != null)
                    {
                        _distance.SecondAirportName = _airports[1].Name;
                    }
                    _distance.Distance = Conversion.GetMiles(distanceBetween);
                }
                return(_distance);
            }
            else
            {
                return(null);
            }
        }
        public IActionResult Get()
        {
            try
            {
                IEnumerable <Airport> airports = airportService.GetAirports();
                return(Ok(airports));
            }
            catch (Exception ex)
            {
                logger.LogError(LoggingEvents.GetItem,
                                ex,
                                "Error on getting airports");
            }

            return(new StatusCodeResult(HttpStatusCodes.InternalServerError));
        }
Ejemplo n.º 3
0
 public IEnumerable <AirportViewModel> GetAirports()
 {
     return(mapper.Map <IEnumerable <AirportViewModel> >(airportService.GetAirports()));
 }
Ejemplo n.º 4
0
 public List <Airport> GetAirports()
 {
     return(airportService.GetAirports());
 }
Ejemplo n.º 5
0
        public IActionResult GetAirports()
        {
            var airports = _airportService.GetAirports();

            return(new JsonResult(airports.Adapt <AirportViewModel[]>()));
        }
Ejemplo n.º 6
0
 public async Task <IEnumerable <AirportModel> > Get() => await airportService.GetAirports();
Ejemplo n.º 7
0
        // GET: Airports
        public ActionResult AirportIndex(int pageNumber = 1)
        {
            int pageSize = 10;

            ViewData["PageNumber"] = pageNumber;

            IEnumerable <AirportViewModel> airports = Mapper.Map <IEnumerable <Airport>, IEnumerable <AirportViewModel> >(_airportService.GetAirports(pageNumber, pageSize, out var totalPages));

            ViewData["TotalPages"] = totalPages;

            return(PartialView(airports));
        }
Ejemplo n.º 8
0
        public IActionResult GetAllAirports()
        {
            var airports = _airportService.GetAirports();

            return(View(airports));
        }