Пример #1
0
        private void Handle()
        {
            String email = "";

            Email.Dispatcher.Invoke(new Action(() => email = Email.Text.ToLower()));
            String password = "";

            TPassword.Dispatcher.Invoke(new Action(() => password = TPassword.Password));
            if (SecureTravel.Signup.IsValidEmail(email) == false)
            {
                DisplayWarning("Not a valid Mail id!");
                this.Dispatcher.Invoke(new Action(() => Loginbt.IsEnabled  = true));
                this.Dispatcher.Invoke(new Action(() => forgotbt.IsEnabled = true));
                this.Dispatcher.Invoke(new Action(() => signupbt.IsEnabled = true));
                return;
            }
            if (password.Equals(""))
            {
                DisplayWarning("Password is empty!");
                this.Dispatcher.Invoke(new Action(() => Loginbt.IsEnabled  = true));
                this.Dispatcher.Invoke(new Action(() => forgotbt.IsEnabled = true));
                this.Dispatcher.Invoke(new Action(() => signupbt.IsEnabled = true));
                return;
            }
            Client     = new MongoClient("mongodb://*****:*****@ds016068.mlab.com:16068/securetravel");
            Database   = Client.GetDatabase("securetravel");
            Collection = Database.GetCollection <BsonDocument>("user");
            var builder = Builders <BsonDocument> .Filter;
            var filter  = builder.Eq("mailid", email) & builder.Eq("password", Hash(password));

            results = Collection.Find(filter).ToList();
            if (results.Count == 1)
            {
                this.Dispatcher.Invoke(new Action(() => afterlogin = new AfterLogin(email, password, results[0]["username"].ToString())));
                afterlogin.Dispatcher.Invoke(new Action(() => afterlogin.Show()));
                this.Dispatcher.Invoke(new Action(() => this.Close()));
            }
            else
            {
                DisplayWarning("Mail id or Password is wrong");
                this.Dispatcher.Invoke(new Action(() => Loginbt.IsEnabled  = true));
                this.Dispatcher.Invoke(new Action(() => forgotbt.IsEnabled = true));
                this.Dispatcher.Invoke(new Action(() => signupbt.IsEnabled = true));
            }
        }
Пример #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     this.Close();
     previouswindow.Show();
 }
Пример #3
0
 private void Return_Inbox(object sender, RoutedEventArgs e)
 {
     this.Close();
     previouswindow.Show();
 }