Esempio n. 1
0
        /// <summary>
        /// 修改地址 View
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult ModifyAddress(int id)
        {
            var trade = YunClient.Instance.Execute(new GetTradeRequest {
                Id = id
            }).Trade;

            if (trade != null)
            {
                var splitAddress = trade.Address.Split(' ');

                //获取省的数据
                var provinces = SystemCity.GetCities(0);
                ViewData["Provinces"] = provinces.Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(splitAddress[0], StringComparison.Ordinal) >= 0
                });

                //获取市的数据
                var cities = SystemCity.GetCities(provinces.Single(e => e.Name.IndexOf(splitAddress[0], StringComparison.Ordinal) >= 0).Id);
                ViewData["Cities"] = cities.Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(splitAddress[1], StringComparison.Ordinal) >= 0
                });

                //获取区的数据
                var areas = SystemCity.GetCities(cities.Single(e => e.Name.IndexOf(splitAddress[1], StringComparison.Ordinal) >= 0).Id);
                ViewData["Areas"] = areas.Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(splitAddress[2], StringComparison.Ordinal) >= 0
                });

                return(View(trade));
            }

            return(Content("订单不存在"));
        }
Esempio n. 2
0
        private void SetUserLocationData(string province, string city, string area)
        {
            //获取省的数据
            var provinces = SystemCity.GetCities(0);

            ViewData["Provinces"] = provinces.Select(e => new SelectListItem
            {
                Text     = e.Name,
                Value    = e.Name + "-" + e.Id,
                Selected = !string.IsNullOrEmpty(province) && e.Name.IndexOf(province, StringComparison.Ordinal) >= 0
            });

            //获取市的数据
            if (string.IsNullOrEmpty(province))
            {
                var t = ((IEnumerable <SelectListItem>)ViewData["Provinces"]).ToList();
                t.Insert(0, new SelectListItem
                {
                    Text  = "-请选择省-",
                    Value = ""
                });
                ViewData["Provinces"] = t;


                ViewData["Cities"] = new List <SelectListItem>
                {
                    new SelectListItem
                    {
                        Text  = "-请选择城市-",
                        Value = ""
                    }
                };
                ViewData["Areas"] = new List <SelectListItem>
                {
                    new SelectListItem
                    {
                        Text  = "-请选择地区-",
                        Value = ""
                    }
                };
            }
            else
            {
                var cities =
                    SystemCity.GetCities(
                        provinces.Single(e => e.Name.IndexOf(province, StringComparison.Ordinal) >= 0).Id);
                ViewData["Cities"] = cities.Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected =
                        !string.IsNullOrEmpty(city) && e.Name.IndexOf(city, StringComparison.Ordinal) >= 0
                });

                if (string.IsNullOrEmpty(city))
                {
                    ViewData["Areas"] = new List <SelectListItem>
                    {
                        new SelectListItem
                        {
                            Text  = "-请选择地区-",
                            Value = ""
                        }
                    };
                }
                else
                {
                    //获取区的数据
                    var areas =
                        SystemCity.GetCities(
                            cities.Single(e => e.Name.IndexOf(city, StringComparison.Ordinal) >= 0).Id);
                    ViewData["Areas"] = areas.Select(e => new SelectListItem
                    {
                        Text     = e.Name,
                        Value    = e.Name + "-" + e.Id,
                        Selected =
                            !string.IsNullOrEmpty(area) && e.Name.IndexOf(area, StringComparison.Ordinal) >= 0
                    });
                }
            }
        }
Esempio n. 3
0
        public ActionResult AdderssEdit(int id = 0)
        {
            var provinces = SystemCity.GetCities(0);

            var dataProvinces = new List <SelectListItem>();
            var dataCities    = new List <SelectListItem>();
            var dataAreas     = new List <SelectListItem>();

            UserAddress address = null;

            if (id > 0)
            {
                address = YunClient.Instance.Execute(new GetAddressRequest {
                    Id = id
                }, Member.Token).Result;

                dataProvinces.AddRange(provinces.Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(address.Province, StringComparison.CurrentCultureIgnoreCase) >= 0
                }));


                var cities = SystemCity.GetCities(
                    provinces.Single(
                        e => e.Name.IndexOf(address.Province, StringComparison.CurrentCultureIgnoreCase) >= 0).Id);
                dataCities.AddRange(cities.Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(address.City, StringComparison.CurrentCultureIgnoreCase) >= 0
                }));

                dataAreas.AddRange(SystemCity.GetCities(
                                       cities.Single(e => e.Name.IndexOf(address.City, StringComparison.CurrentCultureIgnoreCase) >= 0).Id)
                                   .Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(address.Area, StringComparison.CurrentCultureIgnoreCase) >= 0
                }));
            }
            else
            {
                dataProvinces.Add(new SelectListItem {
                    Text = "-请选择省-"
                });
                dataCities.Add(new SelectListItem {
                    Text = "-请选择城市-"
                });
                dataAreas.Add(new SelectListItem {
                    Text = "-请选择地区-"
                });

                dataProvinces.AddRange(provinces.Select(e => new SelectListItem
                {
                    Text  = e.Name,
                    Value = e.Name + "-" + e.Id,
                }));
            }

            ViewData["ProvincesList"] = dataProvinces;
            ViewData["CitiesList"]    = dataCities;
            ViewData["AreasList"]     = dataAreas;

            return(View(address));
        }
Esempio n. 4
0
        public ActionResult MyAccount()
        {
            var banks = YunClient.Instance.Execute(new GetBandBanksRequest(), Member.Token).Banks;


            var provinces = SystemCity.GetCities(0);

            var dataProvinces = new List <SelectListItem>();
            var dataCities    = new List <SelectListItem>();
            var dataAreas     = new List <SelectListItem>();

            if (banks != null && banks.Any())
            {
                var location = banks[0].Location.Split(',');

                dataProvinces.AddRange(provinces.Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(location[0], StringComparison.CurrentCultureIgnoreCase) >= 0
                }));


                var cities = SystemCity.GetCities(
                    provinces.Single(
                        e => e.Name.IndexOf(location[0], StringComparison.CurrentCultureIgnoreCase) >= 0).Id);
                dataCities.AddRange(cities.Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(location[1], StringComparison.CurrentCultureIgnoreCase) >= 0
                }));

                dataAreas.AddRange(SystemCity.GetCities(
                                       cities.Single(e => e.Name.IndexOf(location[1], StringComparison.CurrentCultureIgnoreCase) >= 0).Id)
                                   .Select(e => new SelectListItem
                {
                    Text     = e.Name,
                    Value    = e.Name + "-" + e.Id,
                    Selected = e.Name.IndexOf(location[2], StringComparison.CurrentCultureIgnoreCase) >= 0
                }));
            }
            else
            {
                dataProvinces.Add(new SelectListItem {
                    Text = "-请选择省-"
                });
                dataCities.Add(new SelectListItem {
                    Text = "-请选择城市-"
                });
                dataAreas.Add(new SelectListItem {
                    Text = "-请选择地区-"
                });

                dataProvinces.AddRange(provinces.Select(e => new SelectListItem
                {
                    Text  = e.Name,
                    Value = e.Name + "-" + e.Id,
                }));
            }

            ViewData["ProvincesList"] = dataProvinces;
            ViewData["CitiesList"]    = dataCities;
            ViewData["AreasList"]     = dataAreas;

            return(View(banks != null && banks.Any()?banks[0]:null));
        }
Esempio n. 5
0
 public ActionResult CiyiesData(int parentId)
 {
     return(Json(new { data = SystemCity.GetCities(parentId) }, JsonRequestBehavior.AllowGet));
 }