private void ReadMakros()
        {
            var makroList          = json.DeserializeMakros();
            var gegesseneMakroList = json.DeserializeGegesseneMakros();
            var helper             = gegesseneMakroList.Count - 1;

            if (makroList.Count == 0 || gegesseneMakroList.Count == 0)
            {
                return;
            }

            CaloryGoal.Text = Math.Round(makroList[0].CalGoal, MidpointRounding.AwayFromZero).ToString();

            if (gegesseneMakroList[helper].CurrentDay == DateTime.Today)
            {
                CarbsToday.Text    = Math.Round(gegesseneMakroList[0].EatenCarb, MidpointRounding.AwayFromZero).ToString();
                FatsToday.Text     = Math.Round(gegesseneMakroList[0].EatenFat, MidpointRounding.AwayFromZero).ToString();
                ProteinsToday.Text = Math.Round(gegesseneMakroList[0].EatenProtein, MidpointRounding.AwayFromZero).ToString();

                BerechneNaehrstoff(CarbsToday, null, makroList[0].CarbGoal, CarbBar);
                BerechneNaehrstoff(FatsToday, null, makroList[0].FatGoal, FatBar);
                BerechneNaehrstoff(ProteinsToday, null, makroList[0].ProteinGoal, ProteinBar);
            }
        }
Beispiel #2
0
        private void WriteMakros()
        {
            var makroList = json.DeserializeMakros();

            if (makroList.Count == 0)
            {
                makroList.Add(new ZielMakros()
                {
                    CalGoal     = double.Parse(Kcal.Text),
                    ProteinGoal = double.Parse(Protein.Text),
                    FatGoal     = double.Parse(Fat.Text),
                    CarbGoal    = double.Parse(Carbs.Text)
                });
            }

            makroList[0].CalGoal     = double.Parse(Kcal.Text);
            makroList[0].ProteinGoal = double.Parse(Protein.Text);
            makroList[0].FatGoal     = double.Parse(Fat.Text);
            makroList[0].CarbGoal    = double.Parse(Carbs.Text);
            json.Serializer(makroList);
        }