From d3a74196f2f15069824a0cea7ba5353b130f4cae Mon Sep 17 00:00:00 2001 From: franc Date: Mon, 28 Apr 2025 15:02:20 +0200 Subject: [PATCH] Use new method in controller --- .../Controller/Instruction/InstructionController.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Francesco.Recipes.World/Controller/Instruction/InstructionController.cs b/Francesco.Recipes.World/Controller/Instruction/InstructionController.cs index 4ce79ef..a770783 100644 --- a/Francesco.Recipes.World/Controller/Instruction/InstructionController.cs +++ b/Francesco.Recipes.World/Controller/Instruction/InstructionController.cs @@ -1,5 +1,6 @@ namespace Francesco.Recipes.World.Controller.Instruction { + using Francesco.Recipes.World.Models; using Francesco.Recipes.World.Repositories.Instruction; using Francesco.Recipes.World.Services.Instruction; using Microsoft.AspNetCore.Mvc; @@ -50,11 +51,14 @@ { try { - var instructions = await _instructionRepository.GetInstructionsOfRecipeAsync(recipeId); - var sortedInstructions = instructions.OrderBy(i => i.Number).ToList(); - ViewData["RecipeId"] = recipeId; + var sortedInstructions = await _instructionService.GetSortedInstructionsAsync(recipeId); + var viewModel = new InstructionViewModel + { + RecipeId = recipeId, + Instructions = sortedInstructions, + }; - return View("~/Views/Shared/_GetInstructions.cshtml", sortedInstructions); + return View("~/Views/Shared/_GetInstructions.cshtml", viewModel); } catch (Exception ex) {