Add LIst instead of use an 2 dimensional array

This commit is contained in:
Francesco Lorenzo D'Amico
2025-05-20 14:26:14 +02:00
parent 06ef8927a7
commit f89cf27be4
@@ -6,12 +6,16 @@
<div class="instructions-grid">
@{
var groupedInstructions = Model.Instructions.OrderBy(i => i.Number).ToList();
var rows = (int)Math.Ceiling(groupedInstructions.Count / 3.0);
var instructionRows = groupedInstructions
.Select((instruction, index) => new { Instruction = instruction, Index = index })
.GroupBy(x => x.Index / 3)
.Select(g => g.Select(x => x.Instruction).ToList())
.ToList();
for (int row = 0; row < rows; row++)
foreach (var row in instructionRows)
{
<div class="instruction-row">
@for (int col = 0; col < 3 && (row * 3 + col < groupedInstructions.Count); col++)
@for (var instruction in row)
{
var instruction = groupedInstructions[row * 3 + col];
<div class="instruction-card">