コード例 #1
0
        protected void OkButton_Click(object sender, EventArgs e)
        {
            if (password.Text == "" || email.Text == "")
            {
                RegOut.Text = "Введите данные";
            }
            else if (!Repository.Users.Where(p => p.email == email.Text).Any() && password.Text == pass2.Text)
            {
                User reg = new User();
                reg.FirstName = FirstName.Text;
                reg.LastName  = LastName.Text;
                reg.email     = email.Text;
                reg.Adress    = Adress.Text;
                reg.Telephone = Telephone.Text;
                reg.password  = password.Text;
                reg.Status    = "user";

                Repository.CreateUser(reg);

                RegOut.Text = "Успешная регистрация";
            }
            else
            {
                RegOut.Text = "Такой пользователь есть";
            }
        }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: algowe/algowe
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the

                /*MembershipCreateStatus createStatus;
                 * Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
                 *
                 * if (createStatus == MembershipCreateStatus.Success)
                 * {
                 *  FormsAuthentication.SetAuthCookie(model.UserName, false);
                 *  return RedirectToAction("Index", "Home");
                 * }
                 * else
                 * {
                 *  ModelState.AddModelError("", ErrorCodeToString(createStatus));
                 * }*/
                /*var anyUser = Repository.Users.Any(p => string.Compare(p.Email, userView.Email) == 0);
                 * if (anyUser)
                 * {
                 *      ModelState.AddModelError("Email", "Пользователь с таким email уже зарегистрирован");
                 * }*/

                if (ModelState.IsValid)
                {
                    //var user = (User)ModelMapper.Map(userView, typeof(UserView), typeof(User));
                    Repository = new SqlRepository();
                    Auth       = new CustomAuthentication()
                    {
                        Repository = Repository
                    };
                    Repository.CreateUser(new Entities.GlUser()
                    {
                        Name = model.UserName, Password = model.Password
                    });

                    //Repository.CreateUser(user);
                    return(RedirectToAction("Index", "Home"));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }