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); }
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); }
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); }
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); } }
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); } }