diff --git a/Francesco.Recipes.World/Views/Shared/_RecipeInstructionGridPartial.cshtml b/Francesco.Recipes.World/Views/Shared/_RecipeInstructionGridPartial.cshtml new file mode 100644 index 0000000..2a7b44b --- /dev/null +++ b/Francesco.Recipes.World/Views/Shared/_RecipeInstructionGridPartial.cshtml @@ -0,0 +1,43 @@ +@model Francesco.Recipes.World.Models.InstructionViewModel + +
+

Instructions

+ +
+ @{ + var groupedInstructions = Model.Instructions.OrderBy(i => i.Number).ToList(); + var rows = (int)Math.Ceiling(groupedInstructions.Count / 3.0); + + for (int row = 0; row < rows; row++) + { +
+ @for (int col = 0; col < 3 && (row * 3 + col < groupedInstructions.Count); col++) + { + var instruction = groupedInstructions[row * 3 + col]; +
+
+ @if (instruction.MediaFiles != null && instruction.MediaFiles.Any()) + { + var mediaFile = instruction.MediaFiles.First(); + @if (mediaFile.Data != null && mediaFile.Data.Length > 0) + { + Step @instruction.Number + } + } + + else + { +
+ +
+ } + @instruction.Number +
+

@instruction.Description

+
+ } +
+ } + } +
+