Example #1
0
        public string Menu(int burger, int drink, int side, int dessert)
        {
            int    calories     = CalorieCalculator.getCalories(burger, drink, side, dessert);
            string outputString = OutputStringCreator.getOutputString(calories);

            return(outputString);
        }
Example #2
0
        public ActionResult Calculator(CalorieCalculator calorieCalculator, ViewInfo viewInfo)
        {
            if (ModelState.IsValid)
            {
                CalorieCalculation hsb     = new CalorieCalculation();
                ViewInfo           results = hsb.Calculator(calorieCalculator, viewInfo);

                return(RedirectToAction("ViewInfo", results));
            }

            return(View());
        }
Example #3
0
        public void reportContainsNameAndCalories()
        {
            CalorieCalculator calorieCalculator = new CalorieCalculator();

            calorieCalculator.UseMetric     = true;
            calorieCalculator.Age           = 37;
            calorieCalculator.Height        = 165;
            calorieCalculator.Weight        = 69;
            calorieCalculator.ActivityLevel = 1;
            calorieCalculator.IsFemale      = true;


            // Assert.AreEqual("BMR RESULTS", calorieCalculator.Report("NONAME"));
            Assert.IsTrue(calorieCalculator.Report("Helge").StartsWith("BMR RESULTS FOR HELGE"));
            Assert.IsTrue(calorieCalculator.Report("Nisse").Contains("NISSE"));
            Assert.IsTrue(calorieCalculator.Report("").Contains("1375.3"));
            Assert.IsTrue(calorieCalculator.Report("").Contains("1891."));
        }
Example #4
0
        public void reportContainsNameAndCalories_US()
        {
            CalorieCalculator calorieCalculator = new CalorieCalculator();

            calorieCalculator.UseMetric     = false;
            calorieCalculator.Age           = 37;
            calorieCalculator.Height        = 65;  // approx 165 cm
            calorieCalculator.Weight        = 152; // APprox 69 kg
            calorieCalculator.ActivityLevel = 1;
            calorieCalculator.IsFemale      = true;


            // Assert.AreEqual("BMR RESULTS", calorieCalculator.Report("NONAME"));
            Assert.IsTrue(calorieCalculator.Report("Helge").StartsWith("BMR RESULTS FOR HELGE"));
            Assert.IsTrue(calorieCalculator.Report("Nisse").Contains("NISSE"));
            Assert.IsTrue(calorieCalculator.Report("").Contains("137"));
            Assert.IsTrue(calorieCalculator.Report("").Contains("189"));
        }
Example #5
0
        public bool CreateExercise(ExerciseCreate model)
        {
            var entity =
                new Workout()
            {
                OwnerId        = _userId,
                OwnerWeight    = _userWeightInPounds,
                Type           = model.Type,
                Intensity      = model.Intensity,
                Duration       = model.Duration,
                CaloriesBurned = 0,
                CreatedUtc     = DateTimeOffset.UtcNow,
            };


            CalorieCalculator.GetCalories(entity);

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Workouts.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #6
0
 public IActionResult Index(CalorieCalculator calc)
 {
     return(View(calc));
 }
Example #7
0
        public ViewInfo Calculator(CalorieCalculator calorieCalculator, ViewInfo viewInfo)
        {
            double computation;

            if (calorieCalculator.CalorieCalculatorGender == CalorieCalculatorGender.Male)
            {
                computation        = Convert.ToDouble(700 + (9.6 * calorieCalculator.CalorieCalculatorWeight) + (1.7 * calorieCalculator.CalorieCalculatorHeight) - (4.7 * calorieCalculator.CalorieCalculatorAge));
                viewInfo.FHamwi    = Math.Ceiling(48 + 2.7 * ((calorieCalculator.CalorieCalculatorHeight / 2.54) - 60));
                viewInfo.FDevine   = Math.Floor(50 + 2.3 * ((calorieCalculator.CalorieCalculatorHeight / 2.54) - 60));
                viewInfo.FRobinson = Math.Ceiling(52 + 1.9 * ((calorieCalculator.CalorieCalculatorHeight / 2.54) - 60));
                viewInfo.FMiller   = Math.Ceiling(56.2 + 1.41 * ((calorieCalculator.CalorieCalculatorHeight / 2.54) - 60));
                viewInfo.BMI       = Math.Ceiling(calorieCalculator.CalorieCalculatorWeight / ((calorieCalculator.CalorieCalculatorHeight / 100) * (calorieCalculator.CalorieCalculatorHeight / 100)));

                viewInfo.max = viewInfo.FHamwi;
                if (viewInfo.FDevine > viewInfo.max)
                {
                    viewInfo.max = viewInfo.FDevine;
                }
                if (viewInfo.FRobinson > viewInfo.max)
                {
                    viewInfo.max = viewInfo.FRobinson;
                }
                if (viewInfo.FMiller > viewInfo.max)
                {
                    viewInfo.max = viewInfo.FMiller;
                }


                viewInfo.min = viewInfo.FHamwi;
                if (viewInfo.FDevine < viewInfo.min)
                {
                    viewInfo.min = viewInfo.FDevine;
                }
                if (viewInfo.FRobinson < viewInfo.min)
                {
                    viewInfo.min = viewInfo.FRobinson;
                }
                if (viewInfo.FMiller < viewInfo.min)
                {
                    viewInfo.min = viewInfo.FMiller;
                }
            }
            else
            {
                computation        = Convert.ToDouble(550 + (9.6 * calorieCalculator.CalorieCalculatorWeight) + (1.7 * calorieCalculator.CalorieCalculatorHeight) - (4.7 * calorieCalculator.CalorieCalculatorAge));
                viewInfo.FHamwi    = Math.Ceiling(45.5 + 2.2 * ((calorieCalculator.CalorieCalculatorHeight / 2.54) - 60));
                viewInfo.FDevine   = Math.Floor(45.5 + 2.3 * ((calorieCalculator.CalorieCalculatorHeight / 2.54) - 60));
                viewInfo.FRobinson = Math.Ceiling(49 + 1.7 * ((calorieCalculator.CalorieCalculatorHeight / 2.54) - 60));
                viewInfo.FMiller   = Math.Ceiling(53 + 1.36 * ((calorieCalculator.CalorieCalculatorHeight / 2.54) - 60));
                viewInfo.BMI       = Math.Ceiling(calorieCalculator.CalorieCalculatorWeight / ((calorieCalculator.CalorieCalculatorHeight / 100) * (calorieCalculator.CalorieCalculatorHeight / 100)));

                viewInfo.max = viewInfo.FHamwi;
                if (viewInfo.FDevine > viewInfo.max)
                {
                    viewInfo.max = viewInfo.FDevine;
                }
                if (viewInfo.FRobinson > viewInfo.max)
                {
                    viewInfo.max = viewInfo.FRobinson;
                }
                if (viewInfo.FMiller > viewInfo.max)
                {
                    viewInfo.max = viewInfo.FMiller;
                }


                viewInfo.min = viewInfo.FHamwi;
                if (viewInfo.FDevine < viewInfo.min)
                {
                    viewInfo.min = viewInfo.FDevine;
                }
                if (viewInfo.FRobinson < viewInfo.min)
                {
                    viewInfo.min = viewInfo.FRobinson;
                }
                if (viewInfo.FMiller < viewInfo.min)
                {
                    viewInfo.min = viewInfo.FMiller;
                }
            }
            //viewInfo viewInfo = new viewInfo();
            viewInfo.BasalMetabolic   += (computation);
            viewInfo.Sedentary        += (computation + 300);
            viewInfo.LightExercise    += (computation + 400);
            viewInfo.ModerateExercise += (computation + 500);
            viewInfo.HeavyExercise    += (computation + 650);
            viewInfo.Athlete          += (computation + 750);

            if (calorieCalculator.CalorieCalculatorActivity == CalorieCalculatorActivity.Sedentary)
            {
                viewInfo.WeeklyCalories = Math.Ceiling(viewInfo.Sedentary * 7);
                viewInfo.Selection      = Math.Ceiling(viewInfo.Sedentary);
                int sum = 100;
                viewInfo.maintenanceModerateCarbs   = Math.Ceiling(viewInfo.Selection * 30 / 100);
                viewInfo.maintenanceModerateFats    = Math.Ceiling(viewInfo.Sedentary * 35 / 100);
                viewInfo.maintenanceModerateProtein = Math.Ceiling(viewInfo.Sedentary * 35 / 100);

                viewInfo.cuttingModerateCarbs   = Math.Ceiling(viewInfo.Sedentary * 40 / 100);
                viewInfo.cuttingModerateFats    = Math.Ceiling(viewInfo.Sedentary * 40 / 100);
                viewInfo.cuttingModerateProtein = Math.Ceiling(viewInfo.Sedentary * 20 / 100);

                viewInfo.bulkingModerateCarbs   = Math.Ceiling(viewInfo.Sedentary * 30 / 100);
                viewInfo.bulkingModerateFats    = Math.Ceiling(viewInfo.Sedentary * 20 / 100);
                viewInfo.bulkingModerateProtein = Math.Ceiling(viewInfo.Sedentary * 50 / 100);
                double cutting = (viewInfo.Sedentary - 500);
                viewInfo.maintenanceLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.maintenanceLowerFats    = Math.Ceiling(cutting * 35 / 100);
                viewInfo.maintenanceLowerProtein = Math.Ceiling(cutting * 35 / 100);

                viewInfo.cuttingLowerCarbs   = Math.Ceiling(cutting * 40 / 100);
                viewInfo.cuttingLowerFats    = Math.Ceiling(cutting * 40 / 100);
                viewInfo.cuttingLowerProtein = Math.Ceiling(cutting * 20 / 100);

                viewInfo.bulkingLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.bulkingLowerFats    = Math.Ceiling(cutting * 20 / 100);
                viewInfo.bulkingLowerProtein = Math.Ceiling(cutting * 50 / 100);
                double bulking = (viewInfo.Sedentary + 500);
                viewInfo.maintenanceHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.maintenanceHigherFats    = Math.Ceiling(bulking * 35 / 100);
                viewInfo.maintenanceHigherProtein = Math.Ceiling(bulking * 35 / 100);

                viewInfo.cuttingHigherCarbs   = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherFats    = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherProtein = Math.Ceiling(bulking * 20 / 100);

                viewInfo.bulkingHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.bulkingHigherFats    = Math.Ceiling(bulking * 20 / 100);
                viewInfo.bulkingHigherProtein = Math.Ceiling(bulking * 50 / 100);
            }
            else if (calorieCalculator.CalorieCalculatorActivity == CalorieCalculatorActivity.LightExercise)
            {
                viewInfo.WeeklyCalories = Math.Ceiling(viewInfo.LightExercise * 7);
                viewInfo.Selection      = Math.Ceiling(viewInfo.LightExercise);

                viewInfo.maintenanceModerateCarbs   = Math.Ceiling(viewInfo.LightExercise * 30 / 100);
                viewInfo.maintenanceModerateFats    = Math.Ceiling(viewInfo.LightExercise * 35 / 100);
                viewInfo.maintenanceModerateProtein = Math.Ceiling(viewInfo.LightExercise * 35 / 100);

                viewInfo.cuttingModerateCarbs   = Math.Ceiling(viewInfo.LightExercise * 40 / 100);
                viewInfo.cuttingModerateFats    = Math.Ceiling(viewInfo.LightExercise * 40 / 100);
                viewInfo.cuttingModerateProtein = Math.Ceiling(viewInfo.LightExercise * 20 / 100);

                viewInfo.bulkingModerateCarbs   = Math.Ceiling(viewInfo.LightExercise * 30 / 100);
                viewInfo.bulkingModerateFats    = Math.Ceiling(viewInfo.LightExercise * 20 / 100);
                viewInfo.bulkingModerateProtein = Math.Ceiling(viewInfo.LightExercise * 50 / 100);
                double cutting = (viewInfo.LightExercise - 500);
                viewInfo.maintenanceLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.maintenanceLowerFats    = Math.Ceiling(cutting * 35 / 100);
                viewInfo.maintenanceLowerProtein = Math.Ceiling(cutting * 35 / 100);

                viewInfo.maintenanceLowerCarbs   = Math.Ceiling(cutting * 40 / 100);
                viewInfo.maintenanceLowerFats    = Math.Ceiling(cutting * 40 / 100);
                viewInfo.maintenanceLowerProtein = Math.Ceiling(cutting * 20 / 100);

                viewInfo.bulkingLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.bulkingLowerFats    = Math.Ceiling(cutting * 20 / 100);
                viewInfo.bulkingLowerProtein = Math.Ceiling(cutting * 50 / 100);
                double bulking = (viewInfo.LightExercise + 500);
                viewInfo.maintenanceHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.maintenanceHigherFats    = Math.Ceiling(bulking * 35 / 100);
                viewInfo.maintenanceHigherProtein = Math.Ceiling(bulking * 35 / 100);

                viewInfo.cuttingHigherCarbs   = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherFats    = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherProtein = Math.Ceiling(bulking * 20 / 100);

                viewInfo.bulkingHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.bulkingHigherFats    = Math.Ceiling(bulking * 20 / 100);
                viewInfo.bulkingHigherProtein = Math.Ceiling(bulking * 50 / 100);
            }
            else if (calorieCalculator.CalorieCalculatorActivity == CalorieCalculatorActivity.ModerateExercise)
            {
                viewInfo.WeeklyCalories = Math.Ceiling(viewInfo.ModerateExercise * 7);
                viewInfo.Selection      = Math.Ceiling(viewInfo.ModerateExercise);

                viewInfo.maintenanceModerateCarbs   = Math.Ceiling(viewInfo.ModerateExercise * 30 / 100);
                viewInfo.maintenanceModerateFats    = Math.Ceiling(viewInfo.ModerateExercise * 35 / 100);
                viewInfo.maintenanceModerateProtein = Math.Ceiling(viewInfo.ModerateExercise * 35 / 100);

                viewInfo.cuttingModerateCarbs   = Math.Ceiling(viewInfo.ModerateExercise * 40 / 100);
                viewInfo.cuttingModerateFats    = Math.Ceiling(viewInfo.ModerateExercise * 40 / 100);
                viewInfo.cuttingModerateProtein = Math.Ceiling(viewInfo.ModerateExercise * 20 / 100);

                viewInfo.bulkingModerateCarbs   = Math.Ceiling(viewInfo.ModerateExercise * 30 / 100);
                viewInfo.bulkingModerateFats    = Math.Ceiling(viewInfo.ModerateExercise * 20 / 100);
                viewInfo.bulkingModerateProtein = Math.Ceiling(viewInfo.ModerateExercise * 50 / 100);
                double cutting = (viewInfo.ModerateExercise - 500);
                viewInfo.maintenanceLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.maintenanceLowerFats    = Math.Ceiling(cutting * 35 / 100);
                viewInfo.maintenanceLowerProtein = Math.Ceiling(cutting * 35 / 100);

                viewInfo.cuttingLowerCarbs   = Math.Ceiling(cutting * 40 / 100);
                viewInfo.cuttingLowerFats    = Math.Ceiling(cutting * 40 / 100);
                viewInfo.cuttingLowerProtein = Math.Ceiling(cutting * 20 / 100);

                viewInfo.bulkingLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.bulkingLowerFats    = Math.Ceiling(cutting * 20 / 100);
                viewInfo.bulkingLowerProtein = Math.Ceiling(cutting * 50 / 100);
                double bulking = (viewInfo.ModerateExercise + 500);
                viewInfo.maintenanceHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.maintenanceHigherFats    = Math.Ceiling(bulking * 35 / 100);
                viewInfo.maintenanceHigherProtein = Math.Ceiling(bulking * 35 / 100);

                viewInfo.cuttingHigherCarbs   = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherFats    = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherProtein = Math.Ceiling(bulking * 20 / 100);

                viewInfo.bulkingHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.bulkingHigherFats    = Math.Ceiling(bulking * 20 / 100);
                viewInfo.bulkingHigherProtein = Math.Ceiling(bulking * 50 / 100);
            }
            else if (calorieCalculator.CalorieCalculatorActivity == CalorieCalculatorActivity.HeavyExercise)
            {
                viewInfo.WeeklyCalories = Math.Ceiling(viewInfo.HeavyExercise * 7);
                viewInfo.Selection      = Math.Ceiling(viewInfo.HeavyExercise);

                viewInfo.maintenanceModerateCarbs   = Math.Ceiling(viewInfo.HeavyExercise * 30 / 100);
                viewInfo.maintenanceModerateFats    = Math.Ceiling(viewInfo.HeavyExercise * 35 / 100);
                viewInfo.maintenanceModerateProtein = Math.Ceiling(viewInfo.HeavyExercise * 35 / 100);

                viewInfo.cuttingModerateCarbs   = Math.Ceiling(viewInfo.HeavyExercise * 40 / 100);
                viewInfo.cuttingModerateFats    = Math.Ceiling(viewInfo.HeavyExercise * 40 / 100);
                viewInfo.cuttingModerateProtein = Math.Ceiling(viewInfo.HeavyExercise * 20 / 100);

                viewInfo.bulkingModerateCarbs   = Math.Ceiling(viewInfo.HeavyExercise * 30 / 100);
                viewInfo.bulkingModerateFats    = Math.Ceiling(viewInfo.HeavyExercise * 20 / 100);
                viewInfo.bulkingModerateProtein = Math.Ceiling(viewInfo.HeavyExercise * 50 / 100);
                double cutting = (viewInfo.HeavyExercise - 500);
                viewInfo.maintenanceLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.maintenanceLowerFats    = Math.Ceiling(cutting * 35 / 100);
                viewInfo.maintenanceLowerProtein = Math.Ceiling(cutting * 35 / 100);

                viewInfo.cuttingLowerCarbs   = Math.Ceiling(cutting * 40 / 100);
                viewInfo.cuttingLowerFats    = Math.Ceiling(cutting * 40 / 100);
                viewInfo.cuttingLowerProtein = Math.Ceiling(cutting * 20 / 100);

                viewInfo.bulkingLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.bulkingLowerFats    = Math.Ceiling(cutting * 20 / 100);
                viewInfo.bulkingLowerProtein = Math.Ceiling(cutting * 50 / 100);
                double bulking = (viewInfo.HeavyExercise + 500);
                viewInfo.maintenanceHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.maintenanceHigherFats    = Math.Ceiling(bulking * 35 / 100);
                viewInfo.maintenanceHigherProtein = Math.Ceiling(bulking * 35 / 100);

                viewInfo.cuttingHigherCarbs   = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherFats    = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherProtein = Math.Ceiling(bulking * 20 / 100);

                viewInfo.bulkingHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.bulkingHigherFats    = Math.Ceiling(bulking * 20 / 100);
                viewInfo.bulkingHigherProtein = Math.Ceiling(bulking * 50 / 100);
            }
            else if (calorieCalculator.CalorieCalculatorActivity == CalorieCalculatorActivity.Athlete)
            {
                viewInfo.WeeklyCalories = Math.Ceiling(viewInfo.Athlete * 7);
                viewInfo.Selection      = Math.Ceiling(viewInfo.Athlete);

                viewInfo.maintenanceModerateCarbs   = Math.Ceiling(viewInfo.Athlete * 30 / 100);
                viewInfo.maintenanceModerateFats    = Math.Ceiling(viewInfo.Athlete * 35 / 100);
                viewInfo.maintenanceModerateProtein = Math.Ceiling(viewInfo.Athlete * 35 / 100);

                viewInfo.cuttingModerateCarbs   = Math.Ceiling(viewInfo.Athlete * 40 / 100);
                viewInfo.cuttingModerateFats    = Math.Ceiling(viewInfo.Athlete * 40 / 100);
                viewInfo.cuttingModerateProtein = Math.Ceiling(viewInfo.Athlete * 20 / 100);

                viewInfo.bulkingModerateCarbs   = Math.Ceiling(viewInfo.Athlete * 30 / 100);
                viewInfo.bulkingModerateFats    = Math.Ceiling(viewInfo.Athlete * 20 / 100);
                viewInfo.bulkingModerateProtein = Math.Ceiling(viewInfo.Athlete * 50 / 100);
                double cutting = (viewInfo.Athlete - 500);
                viewInfo.maintenanceLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.maintenanceLowerFats    = Math.Ceiling(cutting * 35 / 100);
                viewInfo.maintenanceLowerProtein = Math.Ceiling(cutting * 35 / 100);

                viewInfo.cuttingLowerCarbs   = Math.Ceiling(cutting * 40 / 100);
                viewInfo.cuttingLowerFats    = Math.Ceiling(cutting * 40 / 100);
                viewInfo.cuttingLowerProtein = Math.Ceiling(cutting * 20 / 100);

                viewInfo.bulkingLowerCarbs   = Math.Ceiling(cutting * 30 / 100);
                viewInfo.bulkingLowerFats    = Math.Ceiling(cutting * 20 / 100);
                viewInfo.bulkingLowerProtein = Math.Ceiling(cutting * 50 / 100);
                double bulking = (viewInfo.Athlete + 500);
                viewInfo.maintenanceHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.maintenanceHigherFats    = Math.Ceiling(bulking * 35 / 100);
                viewInfo.maintenanceHigherProtein = Math.Ceiling(bulking * 35 / 100);

                viewInfo.cuttingHigherCarbs   = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherFats    = Math.Ceiling(bulking * 40 / 100);
                viewInfo.cuttingHigherProtein = Math.Ceiling(bulking * 20 / 100);

                viewInfo.bulkingHigherCarbs   = Math.Ceiling(bulking * 30 / 100);
                viewInfo.bulkingHigherFats    = Math.Ceiling(bulking * 20 / 100);
                viewInfo.bulkingHigherProtein = Math.Ceiling(bulking * 50 / 100);
            }
            return(viewInfo);
        }