Example #1
0
 private void LoadMoods(int id, SQLiteDatabase sqLiteDatabase)
 {
     try
     {
         Mood   mood        = null;
         string commandText = "SELECT [MoodsID], [MoodListID], [MoodRating] FROM Mood WHERE [ThoughtRecordID] = " + id;
         if (sqLiteDatabase.IsOpen)
         {
             var data = sqLiteDatabase.RawQuery(commandText, null);
             if (data != null)
             {
                 if (data.MoveToNext())
                 {
                     do
                     {
                         mood                 = new Mood();
                         mood.MoodsId         = data.GetInt(0);
                         mood.ThoughtRecordId = id;
                         mood.MoodListId      = data.GetInt(1);
                         mood.MoodRating      = data.GetInt(2);
                         mood.IsNew           = false;
                         mood.IsDirty         = false;
                         Moods.Add(mood);
                     }while (data.MoveToNext());
                 }
             }
             data.Close();
         }
     }
     catch (Exception e)
     {
         throw new Exception("Load of Moods failed - " + e.Message);
     }
 }
Example #2
0
 public usrMood()
 {
     InitializeComponent();
     DataContext = this;
     Moods.Add(new ImageListItem <Mood>(EnumLocalizer.Default.Translate(Mood.Normal), "Mood_Normal32.png".ToResourceString(), Mood.Normal));
     Moods.Add(new ImageListItem <Mood>(EnumLocalizer.Default.Translate(Mood.Good), "Mood_Good32.png".ToResourceString(), Mood.Good));
     Moods.Add(new ImageListItem <Mood>(EnumLocalizer.Default.Translate(Mood.Bad), "Mood_Bad32.png".ToResourceString(), Mood.Bad));
 }
Example #3
0
 public void AddMood(Mood newMood)
 {
     try
     {
         if (newMood != null)
         {
             Moods.Add(newMood);
             IsDirty = true;
         }
     }
     catch (Exception e)
     {
         throw new Exception("Attempt to add Mood failed - " + e.Message);
     }
 }
Example #4
0
        private async void LoadMoods()
        {
            var response = await _apiManager.GetMoods(Config.Token);

            if (response.IsSuccessStatusCode)
            {
                Moods.Clear();
                var json = await response.Content.ReadAsStringAsync();

                PaginatedResponse <Mood> moods = await Task.Run(() => JsonConvert.DeserializeObject <PaginatedResponse <Mood> >(json));

                moods.Results.Reverse();
                foreach (var mood in moods.Results)
                {
                    mood.mood = $"{mood.Date} - {_moodDict[mood.mood]}";
                    Moods.Add(mood);
                }
            }
        }