Exemple #1
0
 public CitiesController()
 {
     Model             = new CitiesModel();
     CityAddCommand    = new DelegateCommand(Model.CityToAdd, (_) => Model.AddCity(), e => 0 == 0);
     CityDeleteCommand = new DelegateCommand(Model.SelectedCity, (_) => Model.DeleteCity(), e => 0 == 0);
     CityEditCommand   = new DelegateCommand(Model.SelectedCity, (_) => Model.EditCity(), e => 0 == 0);
 }
        private async void LoadCityList()
        {
            var CitiesModel = new CitiesModel(CityText, this);

            CitiesResponseModel cities = await SL.Manager.GetCityList();

            if (cities.result == null)
            {
                CitiesModel.Items = new List <string> {
                    "Philadelphia", "New York City", "Chicago", "Washington D.C.", "London", "Jakarta", "Ibiza", "Las Vegas", "Amsterdam", "Miami", "Istanbul", "Rio de Janeiro", "Austin", "Bucharest", "Tallahassee", "Ft. Lauderdale", "Atlanta", "Sheffield", "Leeds", "Birmingham", "Manchester", "Antwerp", "Cochabamba", "Buenos Aires", "La Paz", "Santa Cruz", "Los Angeles", "Johannesburg", "Sydney", "Brighton", "Reading", "Charleston", "Buffalo", "Portland", "Raleigh"
                };
            }

            if (cities.result != null)
            {
                CitiesModel.Items = cities.result;
                CitiesModel.Items.Sort();
            }

            ListOfCities = CitiesModel.Items;

            var PickerView = new UIPickerView {
                DataSource = CitiesModel, Delegate = CitiesModel
            };

            CityText.InputView = PickerView;
        }
Exemple #3
0
        public CitiesModel GetAddressByPostCode(OrderModel order, List <CitiesModel> cityModels)
        {
            var cityModel = new CitiesModel();
            var address   = order.AddressDetails;

            if (!string.IsNullOrEmpty(order.PostCode) && order.PostCode.Length == 6 && order.PostCode != "000000")
            {
                string pchead         = order.PostCode.Substring(0, ConfigHelper.GetPostCodeHeadCount());
                var    citiesEntities =
                    cityModels.Where(c => c.PostCode.IndexOf(pchead, StringComparison.Ordinal) == 0).ToList();
                if (citiesEntities.Count() > 0)
                {
                    cityModel = citiesEntities.FirstOrDefault(c => address.Contains(c.Cityc.Trim()) &&
                                                              address.Contains(c.Pc.Trim()));
                }
            }

            if (cityModel == null || string.IsNullOrEmpty(cityModel.Pc))
            {
                cityModel = cityModels.FirstOrDefault(c => address.Contains(c.Cityc.Trim()) &&
                                                      address.Contains(c.Pc.Trim()));
                order.PostCode = cityModel != null?string.Format("{0}0000", cityModel.PostCode.Substring(0, 2)) : order.PostCode;
            }
            if (cityModel == null)
            {
                cityModel = new CitiesModel();
            }
            return(cityModel);
        }
Exemple #4
0
 private CityDTOViewModel RemapCityView(CitiesModel city)
 {
     if (city == null)
     {
         return(null);
     }
     return(new CityDTOViewModel()
     {
         Id = city.Key,
         Name = city.LocalizedName
     });
 }
        public JsonResult GetCitiesbyState(CitiesModel cm)
        {
            var res = "";

            try
            {
                string jsr = mps.GetCitiesbyState(cm);
                return(Json((new JavaScriptSerializer()).DeserializeObject(jsr), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                res = ex.Message.ToString();
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
        }
        public async Task <IActionResult> CitiesMemcached()
        {
            Func <Task <List <string> > > queryGetCitiesAsync = () => GetData.QueryGetCitiesAsync();
            Stopwatch     stopWatch = Stopwatch.StartNew();
            List <string> cities    = await _memcacheCacheService.GetOrCreateCitiesWaitAndPolicyMemcached(
                queryGetCitiesAsync, CacheKeys.CityListWaitAndPolicyMemcache);

            stopWatch.Stop();
            TimeSpan ts1          = stopWatch.Elapsed;
            string   ellapsedTime = TimeUtils.showEllapsedTime(ts1);

            CitiesModel citiesModel = new CitiesModel(cities, ellapsedTime);

            return(View(citiesModel));
        }
        public string GetCitiesbyState(CitiesModel cm)
        {
            var res = "";

            try
            {
                string inputJson = (new JavaScriptSerializer()).Serialize(cm);
                string jsr       = GetjsonInfo("/ManPowers/GetCityList", inputJson);
                return(jsr);
            }
            catch (Exception ex)
            {
                ErrorWriter.WriteLog(ex.GetType().ToString(), ex.GetType().Name.ToString(), ex.InnerException.ToString(), "GetCitiesbyState", "MainRepository");
                res = ex.Message.ToString();
                return(res);
            }
        }
        public static async Task <CitiesModel> Request(string term)
        {
            HttpClient request =
                new HttpClient();

            return(await await request
                   .GetAsync("https://kladr-api.ru/api.php?query=" + term + "&contentType=city&withParent=0&limit=5")
                   .ContinueWith(async r =>
            {
                if (r.IsFaulted)
                {
                    return null;
                }
                CitiesModel x =
                    JsonConvert.DeserializeObject <CitiesModel>(await r.Result.Content.ReadAsStringAsync());
                return x;
            }));
        }
Exemple #9
0
        public ActionResult Index(int?id = null)
        {
            var cities = Mapper.Map <IList <City>, List <CityModel> >(_citiesService.GetCities());

            var model = new CitiesModel
            {
                Cities    = cities,
                Forecasts = new List <ForecastModel>()
            };

            if (id.HasValue)
            {
                model.SelectedCity = cities.Single(x => x.Id == id).Name;
                var forecasts = Mapper.Map <IList <AvgForecastDto>, List <ForecastModel> >(_averageDataService.GetAverageDataForOneCity(id.Value));
                model.Forecasts = forecasts;
            }

            return(View(model));
        }
Exemple #10
0
        //[ActionName("ListBox")]
        public ActionResult ListBox()
        {
            EmployeeContext       empctx         = new EmployeeContext();
            List <SelectListItem> selectListItem = new List <SelectListItem>();

            foreach (City emp in empctx.Cities)
            {
                SelectListItem item = new SelectListItem()
                {
                    Text     = emp.Name,
                    Value    = emp.Id.ToString(),
                    Selected = emp.IsSelected
                };
                selectListItem.Add(item);
            }

            CitiesModel citiesModel = new CitiesModel();

            citiesModel.Cities = selectListItem;
            return(View(citiesModel));
        }
Exemple #11
0
        public CitiesModel GetCityByPostCode(OrderModel order, List <CitiesModel> cityModels)
        {
            #region 检验邮编
            var cityModel = new CitiesModel();
            if (!string.IsNullOrEmpty(order.PostCode) && order.PostCode.Length == 6 && order.PostCode != "000000")
            {
                string pchead         = order.PostCode.Substring(0, ConfigHelper.GetPostCodeHeadCount()); //如果第三位是0则获取前四位,否则获取前三位
                var    citiesEntities =
                    cityModels.Where(c => c.PostCode.IndexOf(pchead, StringComparison.Ordinal) == 0).ToList();
                if (citiesEntities.Count() > 0)
                {
                    cityModel = citiesEntities.FirstOrDefault(c => (order.CCity.Contains(c.Cityc.Trim()) || order.CCountyDistrict.Contains(c.Cityc.Trim())) &&
                                                              order.CProvinceAutonomousRegion.Contains(c.Pc.Trim())) ??
                                cityModels.FirstOrDefault(c => (order.CCity.Contains(c.Cityc.Trim()) ||
                                                                order.CCountyDistrict.Contains(c.Cityc.Trim())) &&
                                                          order.CProvinceAutonomousRegion.Contains(c.Pc.Trim()));
                    if (cityModel == null)
                    {
                        cityModel = citiesEntities.FirstOrDefault();
                    }
                }
            }
            else
            {
                cityModel =
                    cityModels.FirstOrDefault(
                        c => (order.CCity.Contains(c.Cityc.Trim()) || order.CCountyDistrict.Contains(c.Cityc.Trim())) && order.CProvinceAutonomousRegion.Contains(c.Pc.Trim()));
                order.PostCode = cityModel != null?string.Format("{0}0000", cityModel.PostCode.Substring(0, 2)) : order.PostCode;
            }
            if (cityModel == null)
            {
                cityModel = new CitiesModel();
            }
            #endregion

            return(cityModel);
        }
Exemple #12
0
 public int UpdateCity(CitiesModel Model)
 {
     return(_Ser.UpdateCity(Model));
 }
Exemple #13
0
 public int CreateCity(CitiesModel Model)
 {
     return(_Ser.CreateCity(Model));
 }
        public ActionResult _CitiesPartial()
        {
            var model = new CitiesModel();

            return(PartialView("Partial/_CitiesPartial", model));
        }
 public HttpResponseMessage Put(Guid id, [FromBody] CitiesModel item)
 {
     _process.Save(item.Token, item.CountryId, item.IsActive, item.City, UpdatedId);
     return(new HttpResponseMessage(HttpStatusCode.OK));
 }