Exemplo n.º 1
0
        private async void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!UserValidator.CheckEmail(emailBox.Text))
            {
                MessageBox.Show(UserValidator.CheckEmailMessage());
                return;
            }

            if (!UserValidator.CheckName(nameBox.Text))
            {
                MessageBox.Show(UserValidator.CheckNameMessage());
                return;
            }

            if (!UserValidator.CheckSurname(surnameBox.Text))
            {
                MessageBox.Show(UserValidator.CheckSurnameMessage());
                return;
            }

            bool res = await service.EditProfileAsync(token, nameBox.Text, surnameBox.Text, emailBox.Text);

            if (res)
            {
                MessageBox.Show("Профіль змінено!");

                this.DialogResult = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("Щось не так :(");
            }
        }
        /// <summary>
        /// Method for validate input data user
        /// </summary>
        /// <param name="firstName">first name</param>
        /// <param name="lastName">last name</param>
        /// <param name="passport">number passport</param>
        /// <param name="email">email</param>
        private void IsVerify(string firstName, string lastName, string passport, string email)
        {
            Check.NotNull(firstName);
            Check.NotNull(lastName);
            Check.NotNull(passport);
            Check.NotNull(email);

            Check.CheckString(firstName);
            Check.CheckString(lastName);
            Check.CheckString(passport);
            Check.CheckString(email);

            UserValidator.CheckFirstName(firstName);
            UserValidator.CheckLastName(lastName);
            UserValidator.CheckPassport(passport);
            UserValidator.CheckEmail(email);
        }