//Update Existing Contact public void UpdateProblemHistory(ProblemHistory problemhistory) { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { var exisitProblemHistory = dbConn.Query<ProblemHistory>("Select * from ProblemHistory where Id =" + problemhistory.Id).FirstOrDefault(); if (exisitProblemHistory != null) { exisitProblemHistory.ImageName = problemhistory.ImageName; exisitProblemHistory.ImageSource = problemhistory.ImageSource; exisitProblemHistory.CreationDate = problemhistory.CreationDate; dbConn.RunInTransaction(() => { dbConn.Update(exisitProblemHistory); }); } } }
//Insert a Contact to Database Table public bool InsertProblemHistory(ProblemHistory newProblemHistory) { try { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { dbConn.RunInTransaction(() => { dbConn.Insert(newProblemHistory); }); return true; } } catch { return false; } }
//Delete a Contact public bool Delete(ProblemHistory deleteItem) { try { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { var existingProblemHistory = dbConn.Query<ProblemHistory>("Select * from ProblemHistory where Id =" + deleteItem.Id).FirstOrDefault(); if (existingProblemHistory != null) { dbConn.RunInTransaction(() => { dbConn.Delete(existingProblemHistory); System.IO.File.Delete(deleteItem.ImageSource); }); } return true; } } catch { return false; } }