FilterByDifficulty testing

This commit is contained in:
Francesco D'Amico
2025-04-01 17:02:47 +02:00
parent 2acb4b4117
commit 1fcf1a1c26
5 changed files with 22 additions and 24 deletions
@@ -5,7 +5,6 @@
using Francesco.Recipes.World.Repositories.Ingredient;
using Francesco.Recipes.World.Repositories.Recipe;
using Francesco.Recipes.World.Repositories.Unit;
using Francesco.Recipes.World.Views.Recipe;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -25,6 +24,8 @@
_ingredientRepository = ingredientRepository;
}
public IReadOnlyCollection<Recipe> Recipes { get; set; }
// GET: /Recipe/AddOrCreateIngredient
[HttpGet("{recipeId}/AddOrCreateIngredient")]
public async Task<IActionResult> AddOrCreateIngredient()
@@ -140,17 +141,8 @@
[HttpGet("FilterByDifficulty")]
public async Task<IActionResult> FilterByDifficulty(Difficulty? difficulty)
{
var viewModel = new FilterByDifficultyViewModel
{
SelectedDifficulty = difficulty,
};
if (difficulty.HasValue)
{
viewModel.Recipes = (await _recipeRepository.GetRecipesByDifficultyAsync(difficulty.Value)).ToList();
}
return View(viewModel);
Recipes = await _recipeRepository.GetRecipesByDifficultyAsync(difficulty);
return View(Recipes);
}
}
}