private void LoadReratedMoods(int id, SQLiteDatabase sqLiteDatabase) { try { RerateMood reratedMood = new RerateMood(); string commandText = "SELECT [RerateMoodID], [MoodsID], [MoodListID], [MoodRating] FROM RerateMood WHERE [ThoughtRecordID] = " + id; if (sqLiteDatabase.IsOpen) { var data = sqLiteDatabase.RawQuery(commandText, null); if (data != null) { if (data.MoveToFirst()) { do { reratedMood = new RerateMood(); reratedMood.RerateMoodId = data.GetInt(0); reratedMood.ThoughtRecordId = id; reratedMood.MoodsId = data.GetInt(1); reratedMood.MoodListId = data.GetInt(2); reratedMood.MoodRating = data.GetInt(3); reratedMood.IsNew = false; reratedMood.IsDirty = false; RerateMoodList.Add(reratedMood); }while (data.MoveToNext()); } } data.Close(); } } catch (Exception e) { throw new Exception("Load of Rerate Moods failed - " + e.Message); } }
public void RemoveMood(Mood mood, SQLiteDatabase sqlDatabase) { try { //caller will have to warn User that any Rerated mood based on this will also be deleted if (mood != null) { //Find and Remove any re-rated mood foreach (var reRatedMood in RerateMoodList) { if (reRatedMood.MoodsId == mood.MoodsId) { RerateMoodList.Remove(reRatedMood); break; } } mood.Remove(sqlDatabase); Moods.Remove(mood); } } catch (Exception e) { throw new Exception("Attempt to Remove Mood failed - " + e.Message); } }
public void RemoveRerateMood(RerateMood reratedMood) { try { if (reratedMood != null) { RerateMoodList.Remove(reratedMood); } } catch (Exception e) { throw new Exception("Attempt to remove Rerate Mood failed - " + e.Message); } }
public void AddRerateMood(RerateMood newRerateMood) { try { if (newRerateMood != null) { RerateMoodList.Add(newRerateMood); IsDirty = true; } } catch (Exception e) { throw new Exception("Attempt to add Rerate Mood failed - " + e.Message); } }
private void ClearReratedMoods(SQLiteDatabase sqLiteDatabase) { try { if (RerateMoodList.Count > 0) { foreach (var reratedMood in RerateMoodList) { if (!reratedMood.IsNew) { reratedMood.Remove(sqLiteDatabase); } } RerateMoodList.Clear(); } } catch (Exception e) { throw new Exception("Attempt to clear Rerate Moods failed - " + e.Message); } }