public IActionResult OnGet(int productId, int?mealId, bool trigger = false) { Trigger = trigger; if (!mealId.HasValue) { return(RedirectToPage("./NotFound")); } Meal = mealData.GetById(mealId.Value); Product = productData.GetById(productId); return(Page()); }
public IActionResult GetById(int id) { try { Meal = mealData.GetById(id); if (Meal == null) { return(NotFound()); } return(Ok(ApiRepository.MealtoDto(Meal))); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public IActionResult OnGet(int mealId) { Meal = mealData.GetById(mealId); Meal = mealData.LoadIngredients(Meal); if (Meal == null) { return(RedirectToPage("/NotFound")); } return(Page()); }
public IActionResult OnGet(int mealId) { Meal = mealData.GetById(mealId); Meal = mealData.LoadIngredients(Meal); Ingredients = Meal.Products.ToList(); if (Meal.MealProducts != null) { Stats = Meal.MealProducts.ToList(); } Statistics = mealData.GetStatistics(mealId); return(Page()); }
public IActionResult OnPostProcessMeal(int mealId, [FromRoute] int dayId, [FromRoute] int category, [FromRoute] bool?isremoved = false) { IsRemoved = isremoved.Value; Meal = mealData.GetById(mealId); Day = dayData.GetById(dayId) ?? new Day { DayMeals = new List <DayMeal>() }; if (!IsRemoved) { DayMeal = dayMealData.SetValues(Day, Meal, (MealCategory)category); Day.DayMeals.Add(DayMeal); if (Day.DayId == 0) { Day.OwnerName = User.Identity.Name; Day.Date = DateTime.Now.Date; dayData.Add(Day); } else { Day = dayData.GetById(dayId); dayData.Update(Day); } TempData["Message"] = $"{Meal.Name} added to {(MealCategory)category}"; } else { DayMeal = dayMealData.GetByValues(dayId, mealId, (MealCategory)category); Day.DayMeals.Remove(DayMeal); TempData["Message"] = $"{Meal.Name} removed from {(MealCategory)category}"; } dayData.Commit(); return(RedirectToPage("./Today", new { dayId = Day.DayId })); }
public IActionResult OnGet(int?mealId) { if (mealId.HasValue) { Meal = mealData.GetById(mealId.Value); } else { Meal = new Meal(); } if (Meal == null) { return(RedirectToPage("./NotFound")); } Products = productData.GetAll(); return(Page()); }