public ActionResult Signup(Customer form)
        {
            if (ModelState.IsValid == false)
            {
                return View(form);
            }

            Customer newCustomer = new Customer
            {
                FirstName = form.FirstName,
                MiddleName = form.MiddleName,
                LastName = form.LastName,
                EmailAddress = form.EmailAddress,
                PhoneNumber = form.PhoneNumber,
                Password = form.Password,
                Address = form.Address,
                Role = "user"
            };
            var customer = _dataContext.Customers.FirstOrDefault(c => c.EmailAddress == form.EmailAddress);
            if (customer != null)
            {
                ModelState.AddModelError("Email", "Email address must be unique!");
                return View(form);
            }

            try
            {
                _dataContext.Customers.InsertOnSubmit(newCustomer);
                _dataContext.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return RedirectToRoute("Login");
        }
예제 #2
0
 partial void UpdateCustomer(Customer instance);
예제 #3
0
 partial void DeleteCustomer(Customer instance);
예제 #4
0
 partial void InsertCustomer(Customer instance);