private void BtnSignUp_Click(object sender, System.EventArgs e) { btnSignUp.Enabled = false; progressBar.Visibility = ViewStates.Visible; if (!Validate()) { } else { try { db.createDatabase(); //Create Database var data = db.selectallUser(); //Call Table string fName = iName.Text.Trim(); string fEmail = iEmail.Text.Trim(); string fPassword = iPassword.Text.Trim(); var data1 = data.Where(x => x.Email == fEmail).FirstOrDefault(); //Linq Query if (data1 != null) { Toast.MakeText(Application.Context, "Phone number already registered !", ToastLength.Short).Show(); } else { User person = new User() { Name = fName, Password = fPassword, Email = fEmail }; db.insertUser(person); Toast.MakeText(Application.Context, "Sign Up Successfully !", ToastLength.Short).Show(); ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); ISharedPreferencesEditor edit = pref.Edit(); edit.PutString("Usernam", fName); edit.PutString("Usermail", fEmail); edit.Apply(); Intent signin = new Intent(Application.Context, typeof(LoginActivity)); this.StartActivity(signin); } } catch (Exception ex) { Toast.MakeText(Application.Context, ex.ToString(), ToastLength.Short).Show(); } } progressBar.Visibility = ViewStates.Invisible; btnSignUp.Enabled = true; }
private void BtnSignIn_Click(object sender, System.EventArgs e) { btnSignIn.Enabled = false; progressBar.Visibility = ViewStates.Visible; if (!Validate()) { Toast.MakeText(Application.Context, "Login Failed", ToastLength.Short).Show(); } else { try { db.createDatabase(); //Create Database var data = db.selectallUser(); //Call Table string fEmail = iEmail.Text.Trim(); string fPassword = iPassword.Text.Trim(); var data1 = data.Where(x => x.Email == fEmail && x.Password == fPassword).FirstOrDefault(); //Linq Query if (data1 != null) { Toast.MakeText(Application.Context, "Login Success", ToastLength.Short).Show(); ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); ISharedPreferencesEditor edit = pref.Edit(); edit.PutString("Usernam", data1.Name.Trim()); edit.PutString("Usermail", data1.Email.Trim()); edit.Apply(); Intent home = new Intent(Application.Context, typeof(Home)); this.StartActivity(home); } else { Toast.MakeText(Application.Context, "Username or Password invalid", ToastLength.Short).Show(); } } catch (Exception ex) { Toast.MakeText(Application.Context, ex.ToString(), ToastLength.Short).Show(); } } progressBar.Visibility = ViewStates.Invisible; btnSignIn.Enabled = true; }