public async Task DeleteVacationsInfoInSqlById(int id) { try { if (sqliteService == null) { sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName)); } } catch (Exception exp) { sqliteService = null; } if (sqliteService != null) { try { await sqliteService.Delete <VacationInfoModelDTO>(id.ToString()); } catch (Exception ex) { throw ex; } } }
public async void TestSQLiteService(){ SQLiteService sqliteService = new SQLiteService (new SQLitePlatformWin32(), await GetPath("VTSTest")); VacationInfoDTO person = new VacationInfoDTO { Date="", ImageSRC="test", Id=12, Status="qwe", VacationType = "asd" }; await sqliteService.Insert<VacationInfoDTO> (person); var personTest =await sqliteService.Get<VacationInfoDTO>(person.Id.ToString()); Assert.AreNotEqual (person, personTest,"Message Insert or Get error"); person.ImageSRC="https://ru.wikipedia.org/wiki"; await sqliteService.Update<VacationInfoDTO> (person); personTest =await sqliteService.Get<VacationInfoDTO>(person.Id.ToString()); Assert.IsTrue(person.ImageSRC == personTest.ImageSRC,"Message Update or Get error"); await sqliteService.Delete<VacationInfoDTO>(person.Id.ToString()); personTest =await sqliteService.Get<VacationInfoDTO>(person.Id.ToString()); Assert.IsNull (personTest,"Message Delete error"); }
public async Task ClearPreference() { try { if (sqliteService == null) { sqliteService = new SQLiteService <PrefSql>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName)); } } catch (Exception exp) { var err = exp.Message; sqliteService = null; } if (sqliteService != null) { try { List <PrefSql> list = await sqliteService.Get(); if (list != null && list.Count != 0) { foreach (var item in list) { await sqliteService.Delete(item.Id.ToString()); } } } catch (Exception ex) { var err = ex.Message; throw ex; } } }
public async Task DeletePair() { try { if (sqliteService == null) { sqliteService = new SQLiteService <CodeResponceSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName)); } } catch (Exception exp) { sqliteService = null; } if (sqliteService != null) { try { await sqliteService.Delete("1"); } catch (Exception ex) { throw ex; } } }
/// <summary> /// Clear all data in SQLite local DB /// </summary> /// <returns></returns> public async Task ClearMasterPair() { try { if (sqliteService == null) { sqliteService = new SQLiteService <MasterSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName)); } } catch (Exception exp) { sqliteService = null; } if (sqliteService != null) { try { List <MasterSQL> oldmasters = await sqliteService.Get(); if (oldmasters != null && oldmasters.Count != 0) { foreach (var master in oldmasters) { await sqliteService.Delete(master.Id.ToString()); } } } catch (Exception ex) { var err = ex.Message; throw ex; } } }
/// <summary> /// Save Masters to local SQLite for buffer for slow rest internet connections /// </summary> /// <param name="responce"></param> /// <returns></returns> public async Task SaveMastersToSql(IEnumerable <Master> responce) { if (responce == null) { await ClearMasterPair(); return; } try { if (sqliteService == null) { sqliteService = new SQLiteService <MasterSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName)); } } catch (Exception exp) { sqliteService = null; } if (sqliteService != null) { try { List <MasterSQL> oldmasters = await sqliteService.Get(); if (oldmasters != null && oldmasters.Count != 0) { foreach (var master in oldmasters) { await sqliteService.Delete(master.Id.ToString()); } } foreach (var master in responce) { await sqliteService.Insert(converter.ConvertToMasterSQL(master)); } } catch (Exception ex) { var err = ex.Message; throw ex; } } }
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) { } } }
public async Task DeleteMasterPairSql(long masterId) { try { if (sqliteService == null) { sqliteService = new SQLiteService <MasterSQL>(sqlitePlatform, await fileSystemService.GetPath(configuration.SqlDatabaseName)); } } catch (Exception exp) { sqliteService = null; } if (sqliteService != null) { try { List <MasterSQL> listMasterSql = await sqliteService.Get(); if (listMasterSql != null && listMasterSql.Count != 0) { foreach (var masterSql in listMasterSql) { if (masterSql.MasterId.Equals(masterId)) { await sqliteService.Delete(masterSql.Id.ToString()); break; } } } } catch (Exception ex) { var err = ex.Message; throw ex; } } }
public async Task SaveVacationsToSql(List <VTSModel> listVTSModel) { try { if (sqliteService == null) { sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName)); } } catch (Exception exp) { sqliteService = null; } if (sqliteService != null) { try { var vacationInfoList = await sqliteService.Get <VacationInfoDTO>(); if (vacationInfoList != null) { foreach (VacationInfoDTO old in vacationInfoList) { await sqliteService.Delete <VacationInfoDTO>(old.Id.ToString()); } } foreach (VTSModel info in listVTSModel) { await sqliteService.Insert(_converter.ConvertToVacationInfoDTO((info))); } } catch (Exception ex) { throw ex; } } }
public async Task DeleteVacationInfo (string id) { ModelConverter converter = new ModelConverter (); SQLiteService sqliteService; try { sqliteService = new SQLiteService (_sqlitePlatform, await _fileSystem.GetPath ("VTS")); } catch { sqliteService = null; } await sqliteService.Delete<VacationInfoDTO> (id); RestService restService = new RestService ("/api/Vacations", Server); var req = await restService.Delete(id); }