コード例 #1
0
        public ActionResult Register(User userRegister)
        {
            using (TaskUploaderEntities dbModel = new TaskUploaderEntities())
            {
                if (dbModel.Users.Any(x => x.UserName == userRegister.UserName))
                {
                    ViewBag.UserExist = "Username already exist";
                    return(View("Register", userRegister));
                }

                dbModel.Users.Add(userRegister);
                dbModel.SaveChanges();

                ViewBag.RegisterSuccess = "Your registration is successful.";
            }

            ModelState.Clear();

            return(View("Register", new User()));
        }