private void CreateCaloriesGraph(int numberOfEntries) { var calories = json.DeserializeKalorienTag(); var jsonLenght = calories.Count; MyValues.Clear(); TypeOfGraph.Title = "Kalorien"; if (calories.Count == 0) { return; } var helper = jsonLenght - numberOfEntries - 1; for (int i = 0; i <= numberOfEntries - 1; i++) { if (i >= jsonLenght) { break; } if (jsonLenght <= numberOfEntries) { MyValues.Add(new ObservableValue(calories[i].CaloriesDay)); } else { MyValues.Add(new ObservableValue(calories[helper + i].CaloriesDay)); } } }
private void WriteCaloryDayInJson() { var kalorienTag = json.DeserializeKalorienTag(); var currentDay = DateTime.Today; foreach (var itemDay in kalorienTag) { if (currentDay == itemDay.Day) { itemDay.CaloriesDay = double.Parse(ConsumedCalories.Text); json.Serializer(kalorienTag); return; } } kalorienTag.Add(new KalorienTag() { Day = currentDay, CaloriesDay = double.Parse(ConsumedCalories.Text) }); json.Serializer(kalorienTag); }