当前位置: 首页>>代码示例>>C#>>正文


C# Address.Save方法代码示例

本文整理汇总了C#中Address.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Address.Save方法的具体用法?C# Address.Save怎么用?C# Address.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Address的用法示例。


在下文中一共展示了Address.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddBillingAddress

        //[RequireHttps]
        public ActionResult AddBillingAddress()
        {
            try {
                // Create Customer
                Customer customer = new Customer();
                customer.GetFromStorage();
                if (!customer.LoggedIn()) {
                    return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
                }

                if (customer.Cart.payment_id == 0) {
                    Address billing = new Address();
                    // Build out our Billing object
                    billing = new Address {
                        first = Request.Form["bfirst"],
                        last = Request.Form["blast"],
                        street1 = Request.Form["bstreet1"],
                        street2 = Request.Form["bstreet2"],
                        city = Request.Form["bcity"],
                        postal_code = Request.Form["bzip"],
                        residential = (Request.Form["bresidential"] == null) ? false : true,
                        active = true
                    };
                    try {
                        billing.state = Convert.ToInt32(Request.Form["bstate"]);
                    } catch (Exception) {
                        throw new Exception("You must select a billing state/province.");
                    }
                    billing.Save(customer.ID);
                    if (customer.billingID == 0) {
                        customer.SetBillingDefaultAddress(billing.ID);
                    }
                    if (customer.shippingID == 0) {
                        customer.SetShippingDefaultAddress(billing.ID);
                    }

                    // Retrieve Customer from Sessions/Cookie

                    customer.Cart.SetBilling(billing.ID);
                    if (customer.Cart.ship_to == 0) {
                        customer.Cart.SetShipping(billing.ID);
                    }
                } else {
                    UDF.ExpireCart(customer.ID);
                    return RedirectToAction("index");
                }
            } catch { }

            return RedirectToAction("shipping");
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:51,代码来源:CartController.cs

示例2: AddBillingAddress

        public ActionResult AddBillingAddress()
        {
            int ID = Convert.ToInt32(Request.Form["customerID"]);
            try {
                Customer customer = new Customer { ID = ID };
                customer.Get();
                Cart currentCart = customer.Carts.Where(x => x.payment_id == 0).First<Cart>();

                Address billing = new Address();
                // Build out our Billing object
                billing = new Address {
                    first = Request.Form["bfirst"],
                    last = Request.Form["blast"],
                    street1 = Request.Form["bstreet1"],
                    street2 = Request.Form["bstreet2"],
                    city = Request.Form["bcity"],
                    postal_code = Request.Form["bzip"],
                    residential = (Request.Form["bresidential"] == null) ? false : true,
                    active = true
                };
                try {
                    billing.state = Convert.ToInt32(Request.Form["bstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a billing state/province.");
                }
                //shipping.GeoLocate();
                billing.Save(customer.ID);

                // Retrieve Customer from Sessions/Cookie
                currentCart.SetBilling(billing.ID);
            } catch (Exception e) {
                TempData["error"] = e.Message;
            }

            return RedirectToAction("Step4", new { id = ID });
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:36,代码来源:OrdersController.cs

示例3: AddAddress

        public ActionResult AddAddress()
        {
            try {
                // Create Customer
                Customer customer = new Customer();
                customer.GetFromStorage();
                if (!customer.LoggedIn()) {
                    return RedirectToAction("Index", "Authenticate");
                }

                Address address = new Address();
                // Build out our Billing object
                address = new Address {
                    first = Request.Form["first"],
                    last = Request.Form["last"],
                    street1 = Request.Form["street1"],
                    street2 = (Request.Form["street2"].Trim() == "") ? null : Request.Form["street2"].Trim(),
                    city = Request.Form["city"],
                    postal_code = Request.Form["zip"],
                    residential = (Request.Form["residential"] == null) ? false : true,
                    active = true
                };
                try {
                    address.state = Convert.ToInt32(Request.Form["state"]);
                } catch (Exception) {
                    throw new Exception("You must select a state/province.");
                }
                address.Save(customer.ID);

            } catch (Exception e) {
                if (e.Message.ToLower().Contains("a potentially dangerous")) {
                    throw new HttpException(403, "Forbidden");
                }
            }
            return RedirectToAction("Addresses");
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:36,代码来源:AccountController.cs

示例4: Signup

        public ActionResult Signup() {
            Customer cust = new Customer();
            Settings settings = ViewBag.settings;
            Address billing = new Address();
            Address shipping = new Address();
            bool loginAfterRegistration = false;
            bool sameAsBilling = (Request.Form["same"] != null) ? true : false;

            if (settings.Get("CustomerLoginAfterRegistration") == "true") {
                loginAfterRegistration = true;
            }
            try {
                #region Object Instantiation
                // Build out our Customer object
                cust = new Customer {
                    email = Request.Form["email"],
                    fname = Request.Form["fname"],
                    lname = Request.Form["lname"],
                    phone = Request.Form["phone"],
                    dateAdded = DateTime.UtcNow,
                    receiveNewsletter = (Request.Form["receiveNewsletter"] != null) ? 1 : 0,
                    receiveOffers = (Request.Form["receiveOffers"] != null) ? 1 : 0,
                    isSuspended = 0,
                    isValidated = 0,
                    validator = Guid.NewGuid()
                };

                // Build out our Billing object
                billing = new Address {
                    first = Request.Form["bfirst"],
                    last = Request.Form["blast"],
                    street1 = Request.Form["bstreet1"],
                    street2 = Request.Form["bstreet2"],
                    city = Request.Form["bcity"],
                    postal_code = Request.Form["bzip"],
                    residential = (Request.Form["bresidential"] == null) ? false : true,
                    active = true
                };
                
                // Build out our Shipping object
                shipping = new Address {
                    first = Request.Form["sfirst"],
                    last = Request.Form["slast"],
                    street1 = Request.Form["sstreet1"],
                    street2 = Request.Form["sstreet2"],
                    city = Request.Form["scity"],
                    postal_code = Request.Form["szip"],
                    residential = (Request.Form["sresidential"] == null) ? false : true,
                    active = true
                };
                #endregion

                cust.ValidatePasswords(Request.Form["password"], Request.Form["password2"]);
                cust.ValidateEmail(Request.Form["email"], Request.Form["email"]);

                #region Address state validation
                // Validate billing state
                try {
                    billing.state = Convert.ToInt32(Request.Form["bstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a billing state/province.");
                }
                // Validate shipping state
                if (!sameAsBilling || !billing.Equals(shipping)) {
                    try {
                        shipping.state = Convert.ToInt32(Request.Form["sstate"]);
                    } catch (Exception) {
                        throw new Exception("You must select a shipping state/province.");
                    }
                }
                #endregion

                string[] nullables = new string[] { "phone", "issuspended", "receivenewsletter", "receiveoffers", "isvalidated", "billingid", "shippingid", "Address", "Address1", "cart", "id", "orders" };
                UDF.Sanitize(cust, nullables);

                cust.Save();
                billing.Save(cust.ID);
                if (sameAsBilling || billing.Equals(shipping)) {
                    shipping = billing;
                } else {
                    shipping.Save(cust.ID);
                }
                cust.SaveAddresses(billing, shipping);
                cust.Address = billing;
                cust.Address1 = shipping;

                if (loginAfterRegistration) {
                    return RedirectToAction("login", new { email = cust.email, password = Request.Form["password"], remember = 0 });
                } else {
                    TempData["error"] = "You're account has been successfully created. Please check your e-mail to confirm your account.";
                    return RedirectToAction("Index");
                }
            } catch (Exception e) {
                if (e.Message.ToLower().Contains("a potentially dangerous")) {
                    throw new HttpException(403, "Forbidden");
                }
                TempData["customer"] = cust;
                TempData["billing"] = billing;
                TempData["shipping"] = shipping;
                TempData["same"] = sameAsBilling;
//.........这里部分代码省略.........
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:101,代码来源:AuthenticateController.cs

示例5: AddShippingAddress

        //[RequireHttps]
        public ActionResult AddShippingAddress() {
            string error = "";
            try {
                // Create Customer
                Customer customer = new Customer();
                HttpContext ctx = System.Web.HttpContext.Current;
                customer.GetFromStorage(ctx);

                Address shipping = new Address();
                // Build out our Billing object
                shipping = new Address {
                    first = Request.Form["sfirst"],
                    last = Request.Form["slast"],
                    street1 = Request.Form["sstreet1"],
                    street2 = Request.Form["sstreet2"],
                    city = Request.Form["scity"],
                    postal_code = Request.Form["szip"],
                    residential = (Request.Form["sresidential"] == null) ? false : true,
                    active = true
                };
                try {
                    shipping.state = Convert.ToInt32(Request.Form["sstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a shipping state/province.");
                }
                if (shipping.isPOBox()) {
                    throw new Exception("You cannot ship to a PO Box.");
                }
                //shipping.GeoLocate();
                shipping.Save(customer.ID);

                // Retrieve Customer from Sessions/Cookie
                customer.Cart.SetShipping(shipping.ID);
            } catch (Exception e) {
                error = e.Message;
            }

            return RedirectToAction("shipping", new { error = error });
        }
开发者ID:janiukjf,项目名称:CURTeCommerce,代码行数:40,代码来源:CartController.cs

示例6: AddBillingAddress

        //[RequireHttps]
        public ActionResult AddBillingAddress() {
            try {
                // Create Customer
                Customer customer = new Customer();
                HttpContext ctx = System.Web.HttpContext.Current;
                customer.GetFromStorage(ctx);

                if (customer.Cart.payment_id == 0) {
                    Address billing = new Address();
                    // Build out our Billing object
                    billing = new Address {
                        first = Request.Form["bfirst"],
                        last = Request.Form["blast"],
                        street1 = Request.Form["bstreet1"],
                        street2 = Request.Form["bstreet2"],
                        city = Request.Form["bcity"],
                        postal_code = Request.Form["bzip"],
                        residential = (Request.Form["bresidential"] == null) ? false : true,
                        active = true
                    };
                    try {
                        billing.state = Convert.ToInt32(Request.Form["bstate"]);
                    } catch (Exception) {
                        throw new Exception("You must select a billing state/province.");
                    }
                    billing.Save(customer.ID);
                    if (customer.billingID == 0) {
                        customer.SetBillingDefaultAddress(billing.ID);
                    }
                    if (customer.shippingID == 0 && !billing.isPOBox()) {
                        customer.SetShippingDefaultAddress(billing.ID);
                    }

                    // Retrieve Customer from Sessions/Cookie

                    customer.Cart.SetBilling(billing.ID);
                    if (customer.Cart.ship_to == 0 && !billing.isPOBox()) {
                        customer.Cart.SetShipping(billing.ID);
                    }
                } else {
                    UDF.ExpireCart(ctx, customer.ID);
                    return RedirectToAction("index");
                }
            } catch { }

            return RedirectToAction("shipping");
        }
开发者ID:janiukjf,项目名称:CURTeCommerce,代码行数:48,代码来源:CartController.cs

示例7: TestNHibernateValidationWhenSaving2

        public void TestNHibernateValidationWhenSaving2()
        {
            Address a = new Address();
            Assert.True(a.IsNull("Postcode"));
            a.Postcode = "1234";
            a.Address1 = "Address1";
            a.Suburb = "Suburb";
            a.State = "QLD";
            a.Save();

            a.Postcode = null;
            Assert.Throws<NHibernate.Classic.ValidationFailure>(() => { a.Save(SaveMode.Flush); });
        }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:13,代码来源:DataObjectTests.cs

示例8: TestNHibernateValidationWhenSaving

        public void TestNHibernateValidationWhenSaving()
        {
            Address a = new Address();
            Assert.True(a.IsNull("Postcode"));

            IDataErrorInfo error = a;
            Trace.WriteLine(error["Postcode"]);
            Assert.NotEmpty(error["Postcode"]);

            Assert.Throws<NHibernate.Classic.ValidationFailure>(() => {a.Save();});
        }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:11,代码来源:DataObjectTests.cs

示例9: TestNHibernateValidationWhenDeleting

        public void TestNHibernateValidationWhenDeleting()
        {
            Address a = new Address();
            Assert.True(a.IsNull("Postcode"));
            a.Postcode = "1234";
            a.Address1 = "Address1";
            a.Suburb = "Suburb";
            a.State = "QLD";
            a.Save();

            a.Postcode = null;
            a.Delete();
            a.Save();
        }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:14,代码来源:DataObjectTests.cs

示例10: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        AddressSearchCollection foundItems = Address.Search(TextBoxStreet.Text.Trim(),
            int.Parse(DropDownListCities.SelectedValue),
            int.Parse(TextBoxHouseNumber.Text),
            TextBoxApartmentNumber.Text);
        if (foundItems.Count == 1)
        {
            Address foundAddress = new Address(foundItems[0].AddressId);
            foundAddress.LanguageId = int.Parse(DropDownListLanguages.SelectedValue);
            if (foundAddress.LongX == string.Empty | foundAddress.LongX == "0")
            {
                string lat = string.Empty;
                string lng = string.Empty;
                Geocode(ref lng, ref lat);
                foundAddress.LongX = lng;
                foundAddress.Lat = lat;

            }
            foundAddress.FirstName = TextBoxFirstName.Text;
            foundAddress.LastName = TextBoxLastName.Text;
            foundAddress.PhoneNumber = TextBoxPhoneNumber.Text;

            foundAddress.Save();
            LabelMessage.Text = "Address updated";
            TextBoxLastName.Text = string.Empty;
            TextBoxFirstName.Text = string.Empty;
            TextBoxPhoneNumber.Text = string.Empty;
            TextBoxApartmentNumber.Text = string.Empty;
        }
        else if (foundItems.Count == 0)
        {
            bool geocoded = false;
            string lat = string.Empty;
            string lng = string.Empty;
            geocoded = Geocode(ref lng, ref lat);
            Address newAddress = new Address();
            newAddress.StreetName = TextBoxStreet.Text.Trim();
            newAddress.TerritoryId = CurrentUser.TerritoryId;
            newAddress.CityId = int.Parse(DropDownListCities.SelectedValue);
            newAddress.LanguageId = int.Parse(DropDownListLanguages.SelectedValue);
            newAddress.ApartmentNumber = TextBoxApartmentNumber.Text.Trim();
            newAddress.HouseNumber = int.Parse(TextBoxHouseNumber.Text);
            newAddress.LongX = lng;
            newAddress.Lat = lat;
            newAddress.FirstName = TextBoxFirstName.Text;
            newAddress.LastName = TextBoxLastName.Text;
            newAddress.PhoneNumber = TextBoxPhoneNumber.Text;
            newAddress.Save();
            LabelMessage.Text = "Address added";
            TextBoxLastName.Text = string.Empty;
            TextBoxFirstName.Text = string.Empty;
            TextBoxPhoneNumber.Text = string.Empty;
            TextBoxApartmentNumber.Text = string.Empty;
            if (!geocoded)
            {
                LabelMessage.Text = "Address was added but we were unable to map it";
            }
        }
        else
        {
            LabelMessage.Text = "There are multiple addresses matching your criteria: you must narrow it down to zero or one";
        }
    }
开发者ID:hondoslack,项目名称:territorysite,代码行数:64,代码来源:ManageTerritoryAddresses.aspx.cs

示例11: AddShippingAddress

        //[RequireHttps]
        public ActionResult AddShippingAddress()
        {
            try {
                // Create Customer
                Customer customer = new Customer();
                customer.GetFromStorage();
                if (!customer.LoggedIn()) {
                    return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
                }

                Address shipping = new Address();
                // Build out our Billing object
                shipping = new Address {
                    first = Request.Form["sfirst"],
                    last = Request.Form["slast"],
                    street1 = Request.Form["sstreet1"],
                    street2 = Request.Form["sstreet2"],
                    city = Request.Form["scity"],
                    postal_code = Request.Form["szip"],
                    residential = (Request.Form["sresidential"] == null) ? false : true,
                    active = true
                };
                try {
                    shipping.state = Convert.ToInt32(Request.Form["sstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a shipping state/province.");
                }
                //shipping.GeoLocate();
                shipping.Save(customer.ID);

                // Retrieve Customer from Sessions/Cookie
                customer.Cart.SetShipping(shipping.ID);
            } catch(Exception e) {
                TempData["error"] = e.Message;
            }

            return RedirectToAction("shipping");
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:39,代码来源:CartController.cs

示例12: UpdateAddress

 public void UpdateAddress(Address obj)
 {
     obj.Save();
 }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:4,代码来源:ContactContext.cs

示例13: DeleteAddress

 public void DeleteAddress(Address obj)
 {
     Address.Evict(obj.ID);
     obj.Delete();
     obj.Save();
 }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:6,代码来源:ContactContext.cs

示例14: CreateAddress

 public Address CreateAddress(Address obj)
 {
     obj.Save();
     return obj;
 }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:5,代码来源:ContactContext.cs

示例15: Step1New

        public ActionResult Step1New()
        {
            Customer cust = new Customer();
            Address billing = new Address();
            Address shipping = new Address();
            try {
                #region Object Instantiation
                // Build out our Customer object
                cust = new Customer {
                    email = Request.Form["email"],
                    fname = Request.Form["fname"],
                    lname = Request.Form["lname"],
                    phone = Request.Form["phone"],
                    dateAdded = DateTime.Now,
                    isSuspended = 0,
                    isValidated = 1,
                    validator = Guid.NewGuid()
                };

                cust.GeneratePassword();

                // Build out our Billing object
                billing = new Address {
                    first = Request.Form["bfirst"],
                    last = Request.Form["blast"],
                    street1 = Request.Form["bstreet1"],
                    street2 = Request.Form["bstreet2"],
                    city = Request.Form["bcity"],
                    postal_code = Request.Form["bzip"],
                    residential = (Request.Form["bresidential"] == null) ? false : true,
                    active = true
                };

                // Build out our Shipping object
                shipping = new Address {
                    first = Request.Form["sfirst"],
                    last = Request.Form["slast"],
                    street1 = Request.Form["sstreet1"],
                    street2 = Request.Form["sstreet2"],
                    city = Request.Form["scity"],
                    postal_code = Request.Form["szip"],
                    residential = (Request.Form["sresidential"] == null) ? false : true,
                    active = true
                };
                #endregion

                #region Address state validation
                // Validate billing state
                try {
                    billing.state = Convert.ToInt32(Request.Form["bstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a billing state/province.");
                }
                // Validate shipping state
                try {
                    shipping.state = Convert.ToInt32(Request.Form["sstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a shipping state/province.");
                }
                #endregion

                string[] nullables = new string[] { "phone", "address", "address1", "issuspended", "receivenewsletter", "receiveoffers", "isvalidated", "billingid", "shippingid", "cart", "id", "orders" };
                UDF.Sanitize(cust,nullables);

                cust.Save();
                billing.Save(cust.ID);
                if(billing.Equals(shipping)) {
                    shipping = billing;
                } else {
                    shipping.Save(cust.ID);
                }
                cust.SaveAddresses(billing, shipping);
                cust.Address = billing;
                cust.Address1 = shipping;
                return RedirectToAction("Step2", new { id = cust.ID });
            } catch (Exception e) {
                TempData["customer"] = cust;
                TempData["billing"] = billing;
                TempData["shipping"] = shipping;
                TempData["error"] = e.Message;
                return RedirectToAction("Add");
            }
        }
开发者ID:meganmcchesney,项目名称:CURTeCommerce,代码行数:83,代码来源:OrdersController.cs


注:本文中的Address.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。