public ActionResult Register(Customer newcus, string checkregis, string duration) { string email = newcus.CustomerEmail; newcus.CustomerRole = 0; newcus.DateRegister = DateTime.Today; if (ModelState.IsValid) { if (checkregis == "checked") { if (duration == "month") { newcus.CustomerRole = 1; } if (duration == "year") { newcus.CustomerRole = 2; } } else { newcus.CustomerRole = 0; } if (CustomerModel.AddCus(newcus)) { Session["email"] = newcus.CustomerEmail; Session["password"] = newcus.CustomerPassword; Session["role"] = newcus.CustomerRole; Session["id"] = newcus.CustomerId; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Email already existed!!"); } return(View()); }