public async void DeleteEntry(FoodEntryView foodEntry) { FoodToday.AllFoodEntries.Remove(foodEntry); await CalorieService.UpdateFoodPerDay(FoodToday); StateHasChanged(); }
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); }
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); }
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); }
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(); }
public HomeController(AuthService auth, CalorieService calories) { _auth = auth; _calories = calories; }