Exemplo n.º 1
0
        private void Button_UserUpdate_Click(object sender, RoutedEventArgs e)
        {
            User UserEntity = new User();

            UserEntity.Id         = User.Id;
            UserEntity.Email      = TextBox_Email.Text;
            UserEntity.Login      = TextBox_Login.Text;
            UserEntity.Name       = TextBox_Name.Text;
            UserEntity.Surname    = TextBox_Surname.Text;
            UserEntity.Patronymic = TextBox_Patronymic.Text;

            if (!UserValid.Email(UserEntity.Email))
            {
                return;
            }

            if (!UserValid.Login(UserEntity.Login))
            {
                return;
            }

            if (PasswordBox_Password.Password.Length != 0 && PasswordBox_Password.Password.Trim() != string.Empty)
            {
                if (!UserValid.Password(PasswordBox_Password.Password, PasswordBox_ConfirmPassword.Password))
                {
                    return;
                }
                else
                {
                    UserEntity.Password = PasswordBox_Password.Password;
                }
            }

            if (!UserValid.Name(UserEntity.Name))
            {
                return;
            }

            if (!UserValid.Surname(UserEntity.Surname))
            {
                return;
            }

            if (!UserValid.Patronymic(UserEntity.Patronymic))
            {
                return;
            }

            if (!Sender.SendToServer("Users.Update", UserEntity))
            {
                new AlertWindow("Ошибка", AlertWindow.AlertCode.SendToServer);
            }
        }
        private void Button_Register_Click(object sender, RoutedEventArgs e)
        {
            RegisterElements_Block();

            User UserEntity = new User();

            UserEntity.Email      = TextBox_Email.Text;
            UserEntity.Login      = TextBox_Login.Text;
            UserEntity.Name       = TextBox_Name.Text;
            UserEntity.Surname    = TextBox_Surname.Text;
            UserEntity.Patronymic = TextBox_Patronymic.Text;

            if (!UserValid.Email(UserEntity.Email, RegisterElements_Unblock))
            {
                return;
            }

            if (!UserValid.Login(UserEntity.Login, RegisterElements_Unblock))
            {
                return;
            }

            if (!UserValid.Password(PasswordBox_Password.Password, PasswordBox_PasswordConfim.Password, RegisterElements_Unblock))
            {
                return;
            }
            else
            {
                UserEntity.Password = PasswordBox_Password.Password;
            }

            if (!UserValid.Name(UserEntity.Name, RegisterElements_Unblock))
            {
                return;
            }

            if (!UserValid.Surname(UserEntity.Surname, RegisterElements_Unblock))
            {
                return;
            }

            if (!UserValid.Patronymic(UserEntity.Patronymic, RegisterElements_Unblock))
            {
                return;
            }

            WindowLogic.RegisterAccount(UserEntity);
        }