示例#1
0
        public async void InsertExerciseEntry(int exerciseId, int cal, int goal)
        {
            try
            {
                var ehEntry = new ExercisesHistory()
                {
                    EntryDate  = DateTime.Today,
                    ExerciseFK = exerciseId
                };

                await ehData.Insert(ehEntry);

                var tEntry = await thData.Get(x => x.EntryDate == DateTime.Today);

                if (tEntry == null)
                {
                    tEntry = new TotalHistory()
                    {
                        EntryDate     = DateTime.Today,
                        CaloriesTotal = 0 - cal,
                        CaloriesGoal  = goal
                    };

                    await thData.Insert(tEntry);
                }
                else
                {
                    tEntry.CaloriesTotal -= cal;

                    await thData.Update(tEntry);
                }
            }
            catch
            {
                Debug.WriteLine("InsertExerciseEntry Failed.");
            }
        }
示例#2
0
        public async void InsertMealEntry(int mealId, int cal, int goal)
        {
            try
            {
                var mhEntry = new MealsHistory()
                {
                    EntryDate = DateTime.Today,
                    MealsFK   = mealId
                };
                await mhData.Insert(mhEntry);

                var tEntry = await thData.Get(x => x.EntryDate == DateTime.Today);

                if (tEntry == null)
                {
                    tEntry = new TotalHistory()
                    {
                        EntryDate     = DateTime.Today,
                        CaloriesTotal = cal,
                        CaloriesGoal  = goal
                    };

                    await thData.Insert(tEntry);
                }
                else
                {
                    tEntry.CaloriesTotal += cal;

                    await thData.Update(tEntry);
                }
            }
            catch
            {
                Debug.WriteLine("InsertMealEntry Failed.");
            }
        }