示例#1
0
        public IList <StrativeView> GetProvince()
        {
            var data = _cacheStorage.SortedSetRangeByRank <string, StrativeView>
                           (AdministrativeAreaStaticResource.DBINDEX, AdministrativeAreaStaticResource.PROVINCE);

            if (data == null || data.Count == 0)
            {
                var entities = _provinceRepository.GetList(x => true).ToList();

                data = StrativeView.ToProvinces(entities);
            }
            return(data);
        }
示例#2
0
        private void SetArea(City city)
        {
            IList <KeyValuePair <StrativeView, double> > values =
                new List <KeyValuePair <StrativeView, double> >();

            var areas = StrativeView.ToArea(city);

            foreach (var item in areas)
            {
                values.Add(new KeyValuePair <StrativeView, double>(item, item.score));
            }
            _cacheStorage.SortedSetAdd(_cacheModel, city.Code, values);
        }
示例#3
0
        public IList <StrativeView> GetAreas(string cityCode)
        {
            var data = _cacheStorage.SortedSetRangeByRank <string, StrativeView>
                           (AdministrativeAreaStaticResource.DBINDEX, cityCode);

            if (data == null || data.Count == 0)
            {
                var entity = _provinceRepository.GetCityArea(cityCode);

                data = StrativeView.ToArea(entity);
            }
            return(data);
        }
示例#4
0
        private void SetCity(Province entity)
        {
            IList <KeyValuePair <StrativeView, double> > values =
                new List <KeyValuePair <StrativeView, double> >();

            var cities = StrativeView.ToCities(entity);

            foreach (var item in cities)
            {
                values.Add(new KeyValuePair <StrativeView, double>(item, item.score));
            }
            _cacheStorage.SortedSetAdd(_cacheModel, entity.Code, values);

            foreach (var item in entity.Cities)
            {
                this.SetArea(item);
            }
        }
示例#5
0
        private void SetProvince()
        {
            var datas = _provinceRepository
                        .GetList(x => true, "Cities", "Cities.Areas")
                        .OrderBy(x => x.Score)
                        .ToList();

            var provinces = StrativeView.ToProvinces(datas);

            IList <KeyValuePair <StrativeView, double> > values =
                new List <KeyValuePair <StrativeView, double> >();

            foreach (var item in provinces)
            {
                values.Add(new KeyValuePair <StrativeView, double>(item, item.score));
            }
            _cacheStorage.SortedSetAdd(_cacheModel,
                                       AdministrativeAreaStaticResource.PROVINCE, values);

            foreach (var item in datas)
            {
                this.SetCity(item);
            }
        }