Esempio n. 1
0
 public ActionResult Register(UserRegister customerModel)
 {
     if (ModelState.IsValid)
     {
         Customer cus = new Customer();
         if (db.Customers.Any(x => x.CustomerName == customerModel.CustomerName) || db.Admins.Any(x => x.AdminName == customerModel.CustomerName))
         {
             ViewBag.DuplicateMessage = "Customer name is already exist. Please choose another name";
             return(View("Register", customerModel));
         }
         customerModel.UpdateCustomer(cus);
         db.Customers.Add(cus);
         db.SaveChanges();
         ModelState.Clear();
         ViewBag.SuccessMessage = "Registration successfully";
     }
     return(View("Register", new UserRegister()));
 }