Esempio n. 1
0
        private void RegButton_Click(object sender, RoutedEventArgs e)
        {
            var newUser = new User();

            if (!String.IsNullOrEmpty(NameBox.Text) && !String.IsNullOrEmpty(PasswordBox1.Password) &&
                PasswordBox1.Password == PasswordBox2.Password)
            {
                if (!_repo.FindUser(NameBox.Text, PasswordBox1.Password, out newUser))
                {
                    newUser          = new User();
                    newUser.Name     = NameBox.Text;
                    newUser.Password = PasswordBox1.Password;
                    _repo.AddUser(newUser);
                    var packpage = new PackPage(newUser);
                    NavigationService.Navigate(packpage);
                }
                else
                {
                    MessageBlock.Text = "Юзер с такими данным уже существует";
                }
            }
            else
            {
                MessageBlock.Text = "Введены некорректные данные";
            }
        }
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified, ActivationCode")] StudentModel student)
        {
            bool   status  = false;
            string message = " ";

            #region // Model Validation
            if (ModelState.IsValid)
            {
                #region    //Email is already exist
                var isexist = IsEmailExist(student.EmailId);
                if (isexist)
                {
                    ModelState.AddModelError("EmailExist", "That Email Aleady Exist!");
                    return(View(student));
                }
                #endregion

                #region //Activation Code
                student.ActivationCode = Guid.NewGuid();
                #endregion


                #region //Password Hashing
                student.Password        = PasswordHashing.PasswordConvert(student.Password);
                student.ConfirmPassword = PasswordHashing.PasswordConvert(student.ConfirmPassword);
                #endregion

                int id = repository.AddUser(student);
                if (id > 0)
                {
                    ModelState.Clear();
                    message = "Registration Successfully Done!";
                    status  = true;
                }
            }
            else
            {
                message = "Invalid Request";
            }
            #endregion

            ViewBag.Message = message;
            ViewBag.Status  = status;
            return(View(student));
        }