Use new method in controller

This commit is contained in:
franc
2025-04-28 15:02:20 +02:00
parent be211b12c6
commit d3a74196f2
@@ -1,5 +1,6 @@
namespace Francesco.Recipes.World.Controller.Instruction namespace Francesco.Recipes.World.Controller.Instruction
{ {
using Francesco.Recipes.World.Models;
using Francesco.Recipes.World.Repositories.Instruction; using Francesco.Recipes.World.Repositories.Instruction;
using Francesco.Recipes.World.Services.Instruction; using Francesco.Recipes.World.Services.Instruction;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -50,11 +51,14 @@
{ {
try try
{ {
var instructions = await _instructionRepository.GetInstructionsOfRecipeAsync(recipeId); var sortedInstructions = await _instructionService.GetSortedInstructionsAsync(recipeId);
var sortedInstructions = instructions.OrderBy(i => i.Number).ToList(); var viewModel = new InstructionViewModel
ViewData["RecipeId"] = recipeId; {
RecipeId = recipeId,
Instructions = sortedInstructions,
};
return View("~/Views/Shared/_GetInstructions.cshtml", sortedInstructions); return View("~/Views/Shared/_GetInstructions.cshtml", viewModel);
} }
catch (Exception ex) catch (Exception ex)
{ {