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); }
protected override void OnInitialized() { AllFoodItems = _FoodService.GetAllFood(); if (AllFoodItems.Any()) { Name = AllFoodItems.ElementAt(0)?.Name; } FoodToday = _CalorieService.GetFoodOfDay(DateTime.Now) ?? new FoodInDay() { Day = DateTime.Now, TotalCalories = new List <FoodEntry>() }; FoodEntry = new FoodEntry() { Amount = 0, Food = new Food() }; CurrentDate = DateTime.Now.ToShortDateString(); base.OnInitialized(); }