public ActionResult SignUp(Client user) { Session["Email"] = user.Email; Session["ClientId"] = user.ClientId; user.DateRegistered = DateTime.Now; if (ModelState.IsValid) { var isEmailAlreadyExists = db.Clients.Any(x => x.Email == user.Email); var isUserEmailAlreadyExists = db.Users.Any(x => x.Username == user.Email); if (isEmailAlreadyExists) { ViewBag.MessageError = "User with this email already exists!!"; return(View(user)); } if (isUserEmailAlreadyExists) { ViewBag.MessageError = "User with this email already exists!!"; return(View(user)); } EmployeeDBHandler sdb = new EmployeeDBHandler(); if (sdb.AddClient(user)) { ModelState.Clear(); string message = string.Empty; switch (user.ClientId) { case -1: message = ""; break; case -2: message = ""; break; default: message = "Registration successful.\\nUser Id: " + user.ClientId.ToString(); SendActivationEmail(user); break; } } } return(RedirectToAction("OTP")); }
public ActionResult SignUp(Client client) { try { if (ModelState.IsValid) { EmployeeDBHandler sdb = new EmployeeDBHandler(); if (sdb.AddClient(client)) { ViewBag.Message = "Client Details Added Successfully"; ModelState.Clear(); } } return(RedirectToAction("Login")); } catch { return(View()); } }