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


C# Customer.Save方法代码示例

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


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

示例1: Main

 static void Main(string[] args)
 {
     Customer zhangchao = new Customer("220104198905121316", "Zhangchao");
     zhangchao.Register(zhangchao.Id, zhangchao.Name);
      zhangchao.Save(zhangchao.Id, 200);
     zhangchao.Save(zhangchao.Id, 40);
     zhangchao.closeAccount(zhangchao.Id, zhangchao.Name);
     Console.ReadKey();
 }
开发者ID:unclechao,项目名称:SmartBank,代码行数:9,代码来源:Program.cs

示例2: createBusinessCustomer

        protected Customer createBusinessCustomer()
        {
            Dictionary<string, string> meta = new Dictionary<string, string>();
            meta.Add("meta can store", "any flat key/value data you like");
            meta.Add("github", "https://github.com/balanced");
            meta.Add("more_additional_data", "54.8");

            Dictionary<string, string> address = new Dictionary<string, string>();
            address.Add("city", "San Francisco");
            address.Add("state", "CA");
            address.Add("postal_code", "94103");
            address.Add("line1", "965 Mission St");
            address.Add("country_code", "US");

            Customer customer = new Customer();
            customer.business_name = "Balanced";
            customer.ein = "123456789";
            customer.name = "John Lee Hooker";
            customer.phone = "(904) 555-1796";
            customer.meta = meta;
            customer.address = address;
            customer.Save();

            return customer;
        }
开发者ID:remear,项目名称:balanced-csharp,代码行数:25,代码来源:BaseTest.cs

示例3: Main

        static void Main()
        {
            Customer customer = new Customer();
            customer.Name = "John Doe";
            customer.Save();

            Console.WriteLine(customer.Trace());
        }
开发者ID:modulexcite,项目名称:CodeFluent-Entities,代码行数:8,代码来源:Program.cs

示例4: Main

        static void Main(string[] args)
        {
            Customer customer = new Customer();
            customer.Name = "John Doe";
            customer.CardNumber = "1234-1234-1234-1234";
            customer.Save();

            Console.WriteLine(Customer.Load(customer.Id).Trace());
        }
开发者ID:modulexcite,项目名称:CodeFluent-Entities,代码行数:9,代码来源:Program.cs

示例5: Main

        static void Main(string[] args)
        {
            Customer customer = new Customer();
            customer.Name = "John Doe";
            customer.Save();

            //customer.Reload(CodeFluentReloadOptions.Default);

            Console.WriteLine(customer.Trace());

            foreach (var c in CustomerCollection.LoadAll())
            {
                Console.WriteLine(c.Trace());
            }
        }
开发者ID:modulexcite,项目名称:CodeFluent-Entities,代码行数:15,代码来源:Program.cs

示例6: MapsOneToManyUsingConventions

        public void MapsOneToManyUsingConventions()
        {
            var cust = new Customer() { Name = "Jeremy" };
            var order = new Order() { Customer = cust };

            using(ContextScope.Begin()) {
                cust.Orders.Add(order);
                cust.Save();
            }

            using (ContextScope.Begin()) {
                cust = Customer.FindAll().Single();
                cust.Orders.Count().ShouldEqual(1);
            }
        }
开发者ID:JeremySkinner,项目名称:FluentLinqToSql,代码行数:15,代码来源:OneToManyTester.cs

示例7: MapsManyToOneUsingConventions

        public void MapsManyToOneUsingConventions()
        {
            var cust = new Customer() { Name = "Jeremy" };
            var order = new Order() { Customer = cust };

            using(ContextScope.Begin()) {
                cust.Save();
                order.Save();
            }

            using(ContextScope.Begin()) {
                order = Order.FindById(order.Id);
                order.Customer.Name.ShouldEqual("Jeremy");
            }
        }
开发者ID:JeremySkinner,项目名称:FluentLinqToSql,代码行数:15,代码来源:ManyToOneTester.cs

示例8: TestDebitBankAccountUnverifiedNoCustomer

        public void TestDebitBankAccountUnverifiedNoCustomer()
        {
            Customer customer = new Customer();
            customer.Save();

            BankAccount ba = createBankAccount();
            BankAccountVerification verification = ba.Verify();
            verification.Confirm(1, 1);

            Dictionary<string, object> payload = new Dictionary<string, object>();
            payload.Add("amount", 100000);

            Debit debit = ba.Debit(payload);

            Assert.AreEqual("succeeded", debit.status);
            Assert.AreEqual(100000, debit.amount);
        }
开发者ID:remear,项目名称:balanced-csharp,代码行数:17,代码来源:DebitTest.cs

示例9: SavesCustomer

        public void SavesCustomer()
        {
            Customer customer;

            using(new ContextScope()) {
                customer = new Customer {
                    Name = "Jeremy"
                };

                customer.Save();
            }

            using (new ContextScope()) {
                var customer2 = Customer.FindById(customer.Id);
                customer2.Name.ShouldEqual("Jeremy");
                customer.ShouldNotBeTheSameAs(customer2);
            }
        }
开发者ID:JeremySkinner,项目名称:FluentLinqToSql,代码行数:18,代码来源:SaveTester.cs

示例10: DoesNotInsertIfCommitVetoed

        public void DoesNotInsertIfCommitVetoed()
        {
            Customer customer;

            using (new ContextScope()) {
                ContextScope.Current.VetoCommit();

                customer = new Customer {
                    Name = "Jeremy"
                };

                customer.Save();
            }

            using (new ContextScope()) {
                var customer2 = Customer.FindById(customer.Id);
                customer2.ShouldBeNull();
            }
        }
开发者ID:JeremySkinner,项目名称:FluentLinqToSql,代码行数:19,代码来源:SaveTester.cs

示例11: ProgrammerTest

        public void ProgrammerTest()
        {
            var address = new Address("56 Main St", "Mesa", "AZ", "85225");
            var customer = new Customer("John", "Doe", address);
            var company = new Company("Alliance Reservations Network", address);

            Assert.IsNullOrEmpty(customer.Id);
            customer.Save();
            Assert.IsNotNullOrEmpty(customer.Id);

            Assert.IsNullOrEmpty(company.Id);
            company.Save();
            Assert.IsNotNullOrEmpty(company.Id);

            Customer savedCustomer = Customer.Find(customer.Id);
            Assert.IsNotNull(savedCustomer);
            Assert.AreSame(customer.Address, address);
            Assert.AreEqual(savedCustomer.Address, address);
            Assert.AreEqual(customer.Id, savedCustomer.Id);
            Assert.AreEqual(customer.FirstName, savedCustomer.FirstName);
            Assert.AreEqual(customer.LastName, savedCustomer.LastName);
            Assert.AreEqual(customer, savedCustomer);
            Assert.AreNotSame(customer, savedCustomer);

            Company savedCompany = Company.Find(company.Id);
            Assert.IsNotNull(savedCompany);
            Assert.AreSame(company.Address, address);
            Assert.AreEqual(savedCompany.Address, address);
            Assert.AreEqual(company.Id, savedCompany.Id);
            Assert.AreEqual(company.Name, savedCompany.Name);
            Assert.AreEqual(company, savedCompany);
            Assert.AreNotSame(company, savedCompany);

            customer.Delete();
            Assert.IsNullOrEmpty(customer.Id);
            Assert.IsNull(Customer.Find(customer.Id));

            company.Delete();
            Assert.IsNullOrEmpty(company.Id);
            Assert.IsNull(Company.Find(company.Id));
        }
开发者ID:mferster,项目名称:AddressBook,代码行数:41,代码来源:Program.cs

示例12: 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

示例13: Proceed

        public ActionResult Proceed() {
            HttpContext ctx = System.Web.HttpContext.Current;
            Customer cust = ViewBag.customer;
            cust.GetFromStorage(ctx);
            Cart cart = cust.Cart;

            Settings settings = ViewBag.settings;
            Address billing = new Address();
            Address shipping = new Address();
            bool sameAsBilling = (Request.Form["same"] != null) ? true : false;
            string email = Request.Form["email"] ?? "";
            try {
                #region Get Or Create Customer
                // Build out our Customer object
                cust = cust.GetCustomerByEmail(email);
                if (cust == null || cust.ID == 0) {
                    cust = new Customer {
                        email = Request.Form["email"],
                        fname = Request.Form["fname"],
                        lname = Request.Form["lname"],
                        phone = Request.Form["phone"],
                        password = UDF.EncryptString(new PasswordGenerator().Generate()),
                        dateAdded = DateTime.UtcNow,
                        isSuspended = 0,
                        isValidated = 0,
                        receiveNewsletter = (Request.Form["receiveNewsletter"] != null) ? 1 : 0,
                        receiveOffers = (Request.Form["receiveOffers"] != null) ? 1 : 0,
                        validator = Guid.NewGuid()
                    };
                    cust.ValidateEmail(Request.Form["email"], Request.Form["email"]);
                    string[] nullables = new string[] { "phone", "issuspended", "receivenewsletter", "receiveoffers", "isvalidated", "billingid", "shippingid", "Address", "Address1", "cart", "id", "orders" };
                    UDF.Sanitize(cust, nullables);
                    cust.Save();
                }
                cart.UpdateCart(ctx, cust.ID);
                #endregion

                #region Address Initialization
                // 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,
                    cust_id = cust.ID,
                    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,
                    cust_id = cust.ID,
                    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
                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

                #region Get Or Create Address in Database
                billing.cust_id = cust.ID;
                shipping.cust_id = cust.ID;
                billing.MatchOrSave();
                if (sameAsBilling || billing.Equals(shipping)) {
                    shipping = billing;
                } else {
                    shipping.MatchOrSave();
                }
                if (cust.billingID == 0 || cust.shippingID == 0) {
                    cust.SaveAddresses(billing, shipping);
                }
                #endregion
                cart.SetBilling(billing.ID);
                cart.SetShipping(shipping.ID);
                cart.BindAddresses();
                if (cart.Shipping.isPOBox()) {
//.........这里部分代码省略.........
开发者ID:janiukjf,项目名称:CURTeCommerce,代码行数:101,代码来源:CartController.cs

示例14: StoresFakeInstance

        public void StoresFakeInstance()
        {
            using (Fake.Data()) {
                var customer = new Customer {Name = "Jeremy", Id = 4};
                customer.Save();

                var customer2 = Customer.FindById(4);
                customer2.ShouldBeTheSameAs(customer);
            }
        }
开发者ID:JeremySkinner,项目名称:FluentLinqToSql,代码行数:10,代码来源:FakeDataTester.cs

示例15: GivenAModelWithValidation_Save_ShouldNotPersistTheEntity

        public void GivenAModelWithValidation_Save_ShouldNotPersistTheEntity()
        {
            Customer.DropBehaviors();

            var customer = new Customer();
            customer.Save();

            Assert.IsNull(customer.Id);
            Assert.AreEqual(2, customer.Errors.Count);
        }
开发者ID:efbenson,项目名称:NoRMatic,代码行数:10,代码来源:BasicTests.cs


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