async void LogoutClick(object Sender, EventArgs e) { Data.AccountDataAccessService adas = new Data.AccountDataAccessService(); adas.DBConnection.DeleteAll <Model.Login>(); Navigation.InsertPageBefore(new Login(), this); await Navigation.PopAsync().ConfigureAwait(false); //(Ford,2016) }
async void AddToDb(object sender, EventArgs e) { bool InvalidCredentials = false; bool error = false; Regex AccountUser = new Regex("^[a-zA-Z0-9]*$"); Match test = AccountUser.Match(txtAccountName.Text); if (!test.Success) { InvalidCredentials = true; error = true; } test = AccountUser.Match(txtUsername.Text); if (!test.Success) { InvalidCredentials = true; error = true; } Regex UserPass = new Regex("^[a-zA-Z0-9]*$"); test = UserPass.Match(txtPassword.Text); if (!test.Success) { InvalidCredentials = true; error = true; } if (InvalidCredentials == false) { Data.Database db = new Data.Database(); error = await db.AddPasswordToDb(txtUsername.Text, txtPassword.Text, txtAccountName.Text, _UserAccount); } if (error == false) { //notify user the account was added Data.AccountDataAccessService adas = new Data.AccountDataAccessService(); adas.AddAccount(new Model.Account { AccountName = Crypto.EncryptToBytes(txtAccountName.Text), Username = Crypto.EncryptToBytes(txtUsername.Text), Password = Crypto.EncryptToBytes(txtPassword.Text) }); //Seridonio,2016 txtUsername.Text = ""; txtPassword.Text = ""; txtAccountName.Text = ""; lblResult.Text = "Account details saved"; } else { //notify some error occured lblResult.Text = "Error adding account"; } }
public void FetchDataAsync() { Data.AccountDataAccessService adas = new Data.AccountDataAccessService(); List <Account> list = adas.GetAllAccounts(); List <DecryptedAccount> decryptedList = DecryptList(list); Accounts = new ObservableCollection <DecryptedAccount>(decryptedList); }
/// <summary> /// Button click to update account /// </summary> /// <param name="sender"></param> /// <param name="e"></param> async void BtnUpdate(object sender, EventArgs e) { bool error = false; Regex UserPass = new Regex("^[a-zA-Z0-9]*$+"); Regex AccountUser = new Regex("^[a-zA-Z0-9]*$+"); bool InvalidCredentials = false; Match test = AccountUser.Match(txtUsername.Text); if (!test.Success) { InvalidCredentials = true; error = true; } test = UserPass.Match(txtPassword.Text); if (!test.Success) { InvalidCredentials = true; error = true; } if (InvalidCredentials == false) { Data.Database db = new Data.Database(); error = await db.UpdateAccount(_UserName, lblAccountName.Text, txtUsername.Text, txtPassword.Text); } //connect to DB and send query if (error == false) { //notify user the account was Updated Data.AccountDataAccessService adas = new Data.AccountDataAccessService(); //resync database adas.Resync(_UserName); //go back to main menu Navigation.InsertPageBefore(new MainPage(_UserName), this); await Navigation.PopToRootAsync(); } else { //notify some error occured lblResult.Text = "Error updating account"; } }
/// <summary> /// Button click to delete account /// </summary> /// <param name="sender"></param> /// <param name="e"></param> async void BtnDelete(object sender, EventArgs e) { Data.Database db = new Data.Database(); bool error = await db.DeleteAccount(_UserName, lblAccountName.Text); if (error == false) { //notify user the account was added Data.AccountDataAccessService adas = new Data.AccountDataAccessService(); //resync with the database adas.Resync(_UserName); //go back to main menu Navigation.InsertPageBefore(new MainPage(_UserName), this); await Navigation.PopToRootAsync(); } else { //notify some error occured lblResult.Text = "Error deleting account"; } }