public async Task <LoginResponce> LogInOffline(string name, string password) { string result = String.Empty; bool success = false; try { if (sqliteService == null) { sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName)); } } catch (Exception exp) { sqliteService = null; } try { if (sqliteService != null) { LoginInfoDTO currentLoginInfo = new LoginInfoDTO(); currentLoginInfo.UserName = name; currentLoginInfo.Password = SecurytyHash.CalculateSha1Hash(password); result = _localizservice.Localize("NotSavedDataOffline"); List <LoginInfoDTO> listlogins = await sqliteService.Get <LoginInfoDTO>(); if (listlogins != null && listlogins.Count != 0) { foreach (LoginInfoDTO login in listlogins) { if (login.UserName == currentLoginInfo.UserName) { result = string.Empty; if (login.Password == currentLoginInfo.Password) { success = true; result = string.Empty; } else { result = _localizservice.Localize("IncorrectLoginOrPassword"); } } } } } } catch (Exception e) { result = String.Format("Error = " + e.Message); success = false; } return(await Helper.Complete(new LoginResponce(success, result))); }
public async Task SaveLoginModelToSQLite(string name, string password) { try { if (sqliteService == null) { sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName)); } } catch (Exception exp) { sqliteService = null; } if (sqliteService != null) { try { LoginInfoDTO currentLoginInfo = new LoginInfoDTO(); currentLoginInfo.UserName = name; currentLoginInfo.Password = SecurytyHash.CalculateSha1Hash(password); List <LoginInfoDTO> listlogins = await sqliteService.Get <LoginInfoDTO>(); if (listlogins != null && listlogins.Count != 0) { foreach (LoginInfoDTO login in listlogins) { if (login.UserName == currentLoginInfo.UserName) { await sqliteService.Delete <LoginInfoDTO>(login.Id.ToString()); } } } await sqliteService.Insert <LoginInfoDTO>(currentLoginInfo); } catch (Exception ex) { } } }