Beispiel #1
0
        public async Task <long> NetCaloriesForUser(string id)
        {
            var workouts = await workoutsService.GetExercisesByUser(id);

            var meals = await mealsService.GetMealsByUser(id);

            var workoutCalories = workouts.Select(x => new { x.Sets, x.Reps, x.CaloriesPerRep }).ToList();
            var caloricIntake   = meals.Select(x => x.Calories).ToList();

            var calories = 0;

            foreach (var foodCal in caloricIntake)
            {
                calories += foodCal;
            }

            foreach (var workCal in workoutCalories)
            {
                calories -= (workCal.Sets * workCal.Reps * workCal.CaloriesPerRep);
            }

            return(calories);
        }