Ejemplo n.º 1
0
        public void SetAddress(int id = 0)
        {
            string target = Request.QueryString["target"];

            if (string.IsNullOrEmpty(target))
            {
                if (Request.UrlReferrer != null)
                {
                    target = Request.UrlReferrer.ToString();
                }
            }
            M.ShippingAddress address = M.ShippingAddress.GetById(DataSource, id, User.Identity.Id);
            int location;

            if (address == null)
            {
                City city;
                using (IPArea area = new IPArea())
                {
                    IPLocation local = area.Search(ClientIp);
                    using (Country country = Country.GetCountry())
                        city = local.GetCity(country);
                }
                location = city != null ? city.Id : 441900;
            }
            else
            {
                location = address.County;
            }
            this["Target"]   = target;
            this["Location"] = location;
            this["Address"]  = address;
            Render("set_address.html");
        }
Ejemplo n.º 2
0
 public AddressCacheInfo(Modules.ShippingAddress address)
 {
     Consignee = address.Consignee;
     Mobile    = address.Mobile;
     PostId    = address.PostId;
     using (Country c = Country.GetCountry())
     {
         Province = c.GetCity(address.Province).Name;
         City     = c.GetCity(address.City).Name;
         County   = c.GetCity(address.County).Name;
     }
     Address = address.Address;
 }
Ejemplo n.º 3
0
 public void Submit()
 {
     try
     {
         M.ShippingAddress sa = DbTable.Load <M.ShippingAddress>(Request.Form);
         sa.UserId   = User.Identity.Id;
         sa.Province = int.Parse(Request.Form["area_provinces"]);
         sa.City     = int.Parse(Request.Form["area_cities"]);
         sa.County   = int.Parse(Request.Form["area_counties"]);
         if (sa.Id != 0)
         {
             SetResult((int)sa.Modify(DataSource));
         }
         else
         {
             SetResult((int)sa.Insert(DataSource));
         }
     }
     catch (Exception)
     {
         SetResult(false);
     }
 }