public void Initialize() { _signalBus.Subscribe <RegionUpdatedEvt>(OnRegionUpdatedEvt); if (_regionProvider.GetRegions() != null) { reset_rDDN(new List <string>(_regionProvider.GetRegions().Keys)); } }
private async Task <DealModifyModel> CreateDealModifyModel(DealType dealType) { var freeObjectsTask = _dealObjectProvider.GetUserObjects(true, dealType); var userTask = _userProvider.GetUser(); var regionsTask = _regionProvider.GetRegions(); var deliveryTypesTask = _dealProvider.GetDeleveryTypes(); await Task.WhenAll(freeObjectsTask, userTask, regionsTask, deliveryTypesTask); var user = userTask.Result.Model; string regionCode = String.IsNullOrEmpty(user.RegionCode) ? Constants.MOSCOW_KLADR : user.RegionCode; var locationTask = _regionProvider.GetLocalities(regionCode); var cityTask = _regionProvider.GetLocationsByRegion(regionCode); await Task.WhenAll(locationTask, cityTask); var freeObjects = freeObjectsTask.Result.Model; var locations = locationTask.Result.Model; var cities = cityTask.Result.Model; var regions = regionsTask.Result.Model; var deliveryTypes = deliveryTypesTask.Result.Model; var deleveryType = AddressType.City; if (user.DeleveryLocationType.HasValue) { deleveryType = (AddressType)user.DeleveryLocationType; } string cityCode = String.IsNullOrEmpty(user.CityCode) ? cities.First().Code : user.CityCode; string localityCode = String.IsNullOrEmpty(user.LocalityCode) ? locations.First().Code : user.LocalityCode; string locationCode = String.IsNullOrEmpty(user.CityCode) ? locations.First().Code : user.CityCode; return(new DealModifyModel { AddressModel = new AddressViewModel(nameof(SellDealModifyViewModel.AddressModel)) { Address = user.Address, DeliveryLocationType = deleveryType, City = new CityViewModel { CityCode = cityCode, CityList = new SelectList(cities.OrderBy(l => l.Name), "Code", "Name", cityCode) }, Locality = new LocalityViewModel { LocalityList = new SelectList(locations.OrderBy(l => l.Name), "Code", "Name", localityCode), LocalityCode = user.LocalityCode, LocationList = new SelectList(locations.OrderBy(l => l.Name), "Code", "Name", locationCode), LocationCode = user.CityCode }, RegionCode = regionCode, RegionList = new SelectList(regions.OrderBy(l => l.Name), "Code", "Name", regionCode), }, DeleveryTypes = new SelectList(deliveryTypes, "DeliveryId", "Name"), FreeDealObjects = new SelectList(freeObjects, "ObjectId", "Name") }); }
public async Task <IActionResult> Manage() { var model = new ManageUserViewModel(); var userTask = _userProvider.GetUser(); var regionsTask = _regionProvider.GetRegions(); var userPhonesTask = _userProvider.GetUserPhones(); var user = (await userTask).Model; var deleveryType = AddressType.City; if (user.DeleveryLocationType.HasValue) { deleveryType = (AddressType)user.DeleveryLocationType; } string regionCode = String.IsNullOrEmpty(user.RegionCode) ? Constants.MOSCOW_KLADR : user.RegionCode; var locationTask = _regionProvider.GetLocalities(regionCode); var cityTask = _regionProvider.GetLocationsByRegion(regionCode); var cityRequest = await cityTask; string cityCode = String.IsNullOrEmpty(user.CityCode) ? cityRequest.Model.First().Code : user.CityCode; var localitiesRequest = await locationTask; string localityCode = String.IsNullOrEmpty(user.LocalityCode) ? localitiesRequest.Model.First().Code : user.LocalityCode; var locationRequest = await _regionProvider.GetLocationsByLocality(localityCode); string locationCode = String.IsNullOrEmpty(user.CityCode) ? locationRequest.Model.First().Code : user.CityCode; model.AddressModel = new AddressViewModel(nameof(model.AddressModel)) { RegionCode = regionCode, RegionList = new SelectList((await regionsTask).Model.OrderBy(l => l.Name), "Code", "Name", regionCode), DeliveryLocationType = deleveryType, City = new CityViewModel { CityCode = cityCode, CityList = new SelectList(cityRequest.Model.OrderBy(l => l.Name), "Code", "Name", cityCode) }, Locality = new LocalityViewModel { LocalityList = new SelectList(localitiesRequest.Model.OrderBy(l => l.Name), "Code", "Name", localityCode), LocalityCode = user.LocalityCode, LocationList = new SelectList(locationRequest.Model.OrderBy(l => l.Name), "Code", "Name", locationCode), LocationCode = user.CityCode }, Address = user.Address }; var userPhones = (await userPhonesTask).Model; model.PhoneMobile = _mapper.Map <PhoneViewModel>(userPhones.Mobile); model.PhoneWork = _mapper.Map <PhoneViewModel>(userPhones.Work); model.PhoneHome = _mapper.Map <PhoneViewModel>(userPhones.Home); model.PhoneAdditional = _mapper.Map <PhoneViewModel>(userPhones.Additional); return(View(model)); }