Esempio n. 1
0
        private void ForgotPasswordConfirm(object sender, RoutedEventArgs e)
        {
            var login = ForgotPasswordTextBox.Text;

            using (EarthquakeContext context = new EarthquakeContext())
            {
                try
                {
                    var clientForgotPassword = context.Clients.Where(client => client.Login == login).ToList()[0];
                    var password             = clientForgotPassword.Password;
                    var phoneNumber          = clientForgotPassword.Phone;
                    PasswordSender(phoneNumber, password);
                }
                catch (ArgumentOutOfRangeException)
                {
                    MessageBox.Show("Пустое поле");
                }
                catch (TwilioException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                ForgotPasswordTextBox.Text      = "";
                ForgotPasswordWindow.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 2
0
        private void LoginUser(object sender, RoutedEventArgs e)
        {
            using (var context = new EarthquakeContext())
            {
                var users = context.Clients.Where(client => client.Login == UserLogin.Text.ToString() && client.Password == UserPassword.Password.ToString()).ToList();
                if (!users.Any())
                {
                    MessageBox.Show("Направильно введен логин или пароль");
                }
                else
                {
                    LoginIfLogged.Text = users[0].Name;

                    CloseLoginPanel(sender, e);

                    Registrate.Visibility = Visibility.Collapsed;
                    Login.Visibility      = Visibility.Collapsed;
                    Logout.Visibility     = Visibility.Visible;

                    UserLogin.Text        = "";
                    UserPassword.Password = "";
                    CurrentClientId.Text  = users[0].Id.ToString();
                }
            }
        }
Esempio n. 3
0
        private void RegistrateUser(object sender, RoutedEventArgs e)
        {
            using (var context = new EarthquakeContext())
            {
                var users = context.Clients.Where(client => client.Login == ClientLoginRegistrate.Text.ToString());
                if (users.Count() > 0)
                {
                    MessageBox.Show("Пользователь с такими логином уже зарегестрирован!");
                    return;
                }
                else if (ClientFullNameRegistrate.Text.ToString() == "")
                {
                    MessageBox.Show("Не заполнено поле ФИО");
                    return;
                }
                else if (ClientLoginRegistrate.Text.ToString() == "")
                {
                    MessageBox.Show("Не заполнено поле Логин");
                    return;
                }
                else if ((ClientPasswordRegistrate.Password.ToString() != ClientPasswordConfirm.Password.ToString()) || (ClientPasswordRegistrate.Password.ToString() == ""))
                {
                    MessageBox.Show("Пароли не совпадают");
                    return;
                }
                else if (ClientNumberRegistrate.Text.ToString() == "" || Regex.IsMatch(ClientNumberRegistrate.Text.ToString(), ".*?[a-zA-Z].*?"))
                {
                    MessageBox.Show("Неправильно заполнено поле Номер телефона");
                    return;
                }
                else
                {
                    try
                    {
                        var number = PasswordGenerate(4);
                        CodeSender(ClientNumberRegistrate.Text.ToString(), number);
                    }
                    catch (TwilioException error)
                    {
                        MessageBox.Show("Неправильный формат строки ");
                        return;
                    }

                    CloseRegistratePanel(sender, e);

                    RegistrateFormConfirm.Visibility = Visibility.Visible;
                }
            }
        }
Esempio n. 4
0
        private void RegisterUserConfirm(object sender, RoutedEventArgs e)
        {
            while (true)
            {
                using (var context = new EarthquakeContext())
                {
                    if (ClientRegisterConfirm.Text.ToString() == code)
                    {
                        var clients = context.Set <Client>();
                        clients.Add(new Client
                        {
                            Name     = ClientFullNameRegistrate.Text.ToString(),
                            Login    = ClientLoginRegistrate.Text.ToString(),
                            Password = ClientPasswordRegistrate.Password.ToString(),
                            Phone    = ClientNumberRegistrate.Text.ToString(),
                            Rights   = Rights.Client
                        });
                        context.SaveChanges();

                        ClientNumberRegistrate.Text       = "+";
                        ClientLoginRegistrate.Text        = "";
                        ClientPasswordRegistrate.Password = "";
                        ClientPasswordConfirm.Password    = "";
                        ClientFullNameRegistrate.Text     = "";

                        RegistrateFormConfirm.Visibility = Visibility.Collapsed;
                        CurrentClientId.Text             = clients.ToList()[clients.Count() - 1].Id.ToString();
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }