コード例 #1
0
        public ActionResult Login(Login model)
        {
            if (UsersList.IsUserExist(model.UserName))
            {
                @ViewBag.Name        = model.UserName;
                TempData["UserName"] = model.UserName;

                return(RedirectToAction("Index", "Home"));
            }

            @ViewBag.ErrorMessage = "User doesn't exist. Please register.";
            return(View("Index"));
        }
コード例 #2
0
        public ActionResult Register(Register model)
        {
            /*if (users.IsUserExist(model.UserName))*/
            if (UsersList.IsUserExist(model.UserName))
            {
                TempData["ErrorMessage"] = "The same name already exists.";
                TempData["CurrentName"]  = model.UserName;
                return(RedirectToAction("Index", "Register"));
            }
            var user = new User();

            user.Name     = model.UserName;
            user.Password = model.Password;
            UsersList.ListOfUser.Add(user);

            return(RedirectToAction("Index", "Login"));
        }