Пример #1
0
        public List <js_City> GetCityByDepartamentId(int departamentId)
        {
            ObjectCache    cache  = System.Runtime.Caching.MemoryCache.Default;
            var            dep    = cache.Get($"CityDataCollectionCache{departamentId}");
            List <js_City> cities = null;

            if (dep == null)
            {
                CityData cityData = new CityData();
                var      success  = cityData.GetCities(departamentId);
                cache.Set($"CityDataCollectionCache{departamentId}", success.IsSuccess ? success.Result : null, DateTimeOffset.Now.AddHours(1));
                cities = success.IsSuccess ? success.Result : null;
            }
            else
            {
                cities = (List <js_City>)cache.Get($"CityDataCollectionCache{departamentId}");
            }
            return(cities);
        }