Пример #1
0
        public async void DeleteEntry(FoodEntryView foodEntry)
        {
            FoodToday.AllFoodEntries.Remove(foodEntry);
            await CalorieService.UpdateFoodPerDay(FoodToday);

            StateHasChanged();
        }
Пример #2
0
        static void Main(string[] args)
        {
            CalorieService calorieService = new CalorieService();
            Person         person         = new Person()
            {
                Gender       = Gender.Male,
                HeightFeet   = 6,
                WeightPounds = 194,
                Age          = 29
            };

            var reeCals = calorieService.CalcuateRestingEnergyExpenditure(person);

            Console.WriteLine("Calories = " + reeCals);
        }
Пример #3
0
        public void TestREECalcualtion_Returns_Correct_Calorie()
        {
            CalorieService calorieService = new CalorieService();
            Person         person         = new Person()
            {
                Gender       = Gender.Male,
                HeightFeet   = 6,
                WeightPounds = 194,
                Age          = 29
            };

            var reeCals = calorieService.CalcuateRestingEnergyExpenditure(person);

            Console.WriteLine("Calories = " + reeCals);
            Assert.True(reeCals == 1882);
        }
Пример #4
0
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            AllFoodItems = await FoodService.GetAllFood();

            if (AllFoodItems.Any())
            {
                Name = AllFoodItems.ElementAt(0)?.Name;
            }

            FoodToday = await CalorieService.GetFoodPerDay(DateTime.Now.Date) ?? FoodToday;

            FoodEntry          = new FoodEntryView();
            FoodEntry.Calories = CalculateCalories(FoodEntry);
        }
Пример #5
0
        public async Task AddFoodEntry()
        {
            var food = AllFoodItems.FirstOrDefault(f => f.Name.Equals(Name));

            FoodEntry.FoodName = food.Name;
            FoodEntry.FoodId   = food.FoodId;
            FoodEntry.Calories = CalculateCalories(FoodEntry);
            FoodToday.AllFoodEntries.Add(FoodEntry);

            await CalorieService.UpdateFoodPerDay(FoodToday);

            FoodEntry = new FoodEntryView()
            {
                Amount = 0, FoodId = 0
            };

            StateHasChanged();
        }
Пример #6
0
 public HomeController(AuthService auth, CalorieService calories)
 {
     _auth     = auth;
     _calories = calories;
 }