Example #1
0
        /// <summary>
        /// This method will get from cahce if the items was stored there.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected async Task <FeatureCollection> GetFromCacheIfExists(string id)
        {
            var featureCollection = await _elasticSearchGateway.GetCachedItemById(id, Source);

            if (featureCollection == null)
            {
                return(null);
            }
            var feature = featureCollection.Features.First();

            if (!feature.Attributes.Exists(FeatureAttributes.POI_CACHE_DATE))
            {
                return(null);
            }
            var date = DateTime.Parse(feature.Attributes[FeatureAttributes.POI_CACHE_DATE].ToString());

            return((date - DateTime.Now).TotalDays <= _options.DaysToKeepPoiInCache
                ? featureCollection
                : null);
        }