示例#1
0
        /// <summary>
        /// Neuen Eintrag in Json schreiben
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddGrocery_Click(object sender, RoutedEventArgs e)
        {
            var groceryList = json.DeserializeLebensmittel();

            if (ValidateDataGridInput())
            {
                groceryList.Add(new Groceries()
                {
                    Uid      = GetFreeUid(groceryList),
                    Name     = NameBox.Text,
                    Carbs    = CarbsBox.Text,
                    Calories = CaloriesBox.Text,
                    Fats     = FatBox.Text,
                    Protein  = ProteinBox.Text
                });
                json.Serializer(groceryList);
                ResetTextBoxes();
                EntrySuccessful.Text = "Essen erfolgreich eingetragen";
                ReadJson();
            }
        }
        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);
        }
示例#3
0
        private void WriteWeight()
        {
            var weightList = json.DeserializeGewichtTag();
            int counter    = 0;

            foreach (var item in weightList)
            {
                if (item.Day == DateTime.Today)
                {
                    weightList[counter].TodaysWeight = double.Parse(Gewicht.Text);
                    json.Serializer(weightList);
                    return;
                }
                counter++;
            }
            weightList.Add(new GewichtTag()
            {
                Day          = DateTime.Today,
                TodaysWeight = double.Parse(Gewicht.Text)
            });
            json.Serializer(weightList);
        }