コード例 #1
0
 public ActionResult Create(CustomerInformation account)
 {
     var newAccount = CustomerInformation.CreateCustomerInformation(account.CustomerName, User.Identity.GetUserName(), account.Address);
     if (newAccount != null)
     {
         return RedirectToAction("Detail", new { id = newAccount.EmailAddress.Replace(".", "~") });
     }
     return View();
 }
コード例 #2
0
        public static CustomerInformation CreateCustomerInformation(string customerName, string customerEmailAddress, string customerAddress)
        {
            using (var db = new CustomerModel())
            {
                if (!accountsLoaded)
                {
                    //This increments based on the count of rows.
                    lastAccountNumber = db.CustomerInformations.Count();
                    accountsLoaded    = true;
                }

                CustomerInformation customerAccount = new CustomerInformation();
                customerAccount.CustomerName = customerName;
                customerAccount.EmailAddress = customerEmailAddress;
                customerAccount.Address      = customerAddress;

                customerInformations.Add(customerAccount);
                db.CustomerInformations.Add(customerAccount);
                db.SaveChanges();

                return(customerAccount);
            }
        }
コード例 #3
0
        public static CustomerInformation CreateCustomerInformation(string customerName, string customerEmailAddress, string customerAddress)
        {
            using (var db = new CustomerModel())
            {
                if (!accountsLoaded)
                {
                    //This increments based on the count of rows.
                    lastAccountNumber = db.CustomerInformations.Count();
                    accountsLoaded = true;
                }

                CustomerInformation customerAccount = new CustomerInformation();
                customerAccount.CustomerName = customerName;
                customerAccount.EmailAddress = customerEmailAddress;
                customerAccount.Address = customerAddress;

                customerInformations.Add(customerAccount);
                db.CustomerInformations.Add(customerAccount);
                db.SaveChanges();

                return customerAccount;
            }
        }