public void RememberMe(AccountDB account) { using (var dbConnection = new SQLiteConnection(_dbUnitAndroidPrinterAppCurrent)) { dbConnection.DeleteAll<AccountDB>(); dbConnection.Insert(new AccountDB() { Sid = account.Sid, CurUserAdSid = account.CurUserAdSid, Login = account.Login, Password = account.Password }); } }
void ButtonLogIn_Click(object sender, EventArgs e) { AccountDB account = new AccountDB() { CurUserAdSid = string.Empty, Password = m_pass.Text, Login = m_name.Text, Sid = string.Empty }; if (m_unitAPIShellAutorizator.LogIn(account)) { if (FindViewById<CheckBox>(Resource.Id.CheckRemember).Checked) { m_unitAPIShellAutorizator.RememberMe(account); } GoMainActivity(); } else Toast.MakeText(this, Resource.String.ErrorAuth, ToastLength.Long).Show(); }
public bool LogIn(AccountDB account) { using (var dbConnection = new SQLiteConnection(_dbUnitAndroidPrinterApp)) { try { dbConnection.Get<AccountDB>(x => x.Login == account.Login && x.Password == account.Password); return true; } catch(Exception) { return false; } } }
private void Initialize() { m_name = FindViewById<EditText>(Resource.Id.EnterName); m_pass = FindViewById<EditText>(Resource.Id.EnterPass); var buttonLogIn = FindViewById<Button>(Resource.Id.LogInButton); buttonLogIn.Click += ButtonLogIn_Click; var login = "******"; var pass = "******"; m_unitAPIShellAutorizator = new UnitAPIShellAuthorizator(login, pass); AccountDB remember = m_unitAPIShellAutorizator.GetRememberAccount(); if (remember != null) { m_name.Text = remember.Login; m_pass.Text = remember.Password; AccountDB account = new AccountDB() { CurUserAdSid = string.Empty, Password = m_pass.Text, Login = m_name.Text, Sid = string.Empty }; if (m_unitAPIShellAutorizator.LogIn(account)) GoMainActivity(); } }