public ActionResult Register(RegistrationModel model) { LogManager logManager = new LogManager(db); if (ModelState.IsValid) { UserManager userManger = new UserManager(db); if (!userManger.IsLoginNameExist(model)) { userManger.createNewUser(model); //FormsAuthentication.SetAuthCookie(model.UserName, false); logManager.LogSuccessfulRegistration(model.UserName); InsertMessage message = new InsertMessage(); // passing message to control about seccussfull registration message.MessageText = "Registered user: "******" successfully. Now you can Log In."; TempData["message"] = message; return(RedirectToAction("Index", "Home")); } else { logManager.LogUnSuccessfulRegistration(model.UserName); ModelState.AddModelError("", "Username already exists"); } } logManager.LogUnSuccessfulRegistration(model.UserName); return(View()); }
public ActionResult Register(RegistrationModel model) { LogManager logManager = new LogManager(db); if (ModelState.IsValid) { UserManager userManger = new UserManager(db); if (!userManger.IsLoginNameExist(model)) { userManger.createNewUser(model); //FormsAuthentication.SetAuthCookie(model.UserName, false); logManager.LogSuccessfulRegistration(model.UserName); InsertMessage message = new InsertMessage(); // passing message to control about seccussfull registration message.MessageText = "Registered user: "******" successfully. Now you can Log In."; TempData["message"] = message; return RedirectToAction("Index", "Home"); } else { logManager.LogUnSuccessfulRegistration(model.UserName); ModelState.AddModelError("", "Username already exists"); } } logManager.LogUnSuccessfulRegistration(model.UserName); return View(); }
// GET: Home public ActionResult Index() { InsertMessage message = TempData["message"] as InsertMessage; if (message != null) { ViewData["MessageText"] = message.MessageText; } return(View()); }