/// <summary>
        /// GetLocationsAsync
        /// </summary>
        /// <returns></returns>
        public async Task <Location[]> GetLocationsAsync()
        {
            if (_cachingManager.GetFromCache(Constants.KEY_CACHE_LOCATIONS) != null)
            {
                _locations = _cachingManager.GetFromCache(Constants.KEY_CACHE_LOCATIONS) as Location[];
            }
            else
            {
                _locations = await ExtractLocations();

                _cachingManager.AddToCache(Constants.KEY_CACHE_LOCATIONS, _locations);
            }

            return(_locations);
        }
        public JsonResult GetDistance(DistanceInput distanceInput)
        {
            double distance     = 0;
            var    airportsData = _cachingManager.GetFromCache(Constants.KEY_CACHE_LOCATIONS) as Location[];

            if (airportsData == null)
            {
                return(Json(distance, JsonRequestBehavior.AllowGet));
            }

            var source      = airportsData.First(airport => airport.iata.Equals(distanceInput.SourceAirport));
            var destination = airportsData.First(airport => airport.iata.Equals(distanceInput.DestinationAirport));

            var sourceCoordinates      = new Coordinates();
            var destinationCoordinates = new Coordinates();

            if (source != null && destination != null)
            {
                sourceCoordinates = new Coordinates
                {
                    latitude  = double.Parse(source.lat),
                    longitude = double.Parse(source.lon)
                };
                destinationCoordinates = new Coordinates
                {
                    latitude  = double.Parse(destination.lat),
                    longitude = double.Parse(destination.lon)
                };
            }

            distance = _distanceCalculator.Calculate(sourceCoordinates, destinationCoordinates);

            return(Json(distance, JsonRequestBehavior.AllowGet));
        }
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     _customHeaderValue = _cachingManager.GetFromCache(Constants.KEY_CACHE_LOCATIONS) == null ? "true" : "false";
     filterContext.HttpContext.Response.Headers.Add("from-feed", _customHeaderValue);
 }