diff --git a/cicm_web/Areas/Admin/Controllers/GpusByMachineController.cs b/cicm_web/Areas/Admin/Controllers/GpusByMachineController.cs index 5626aea1..52ee92ee 100644 --- a/cicm_web/Areas/Admin/Controllers/GpusByMachineController.cs +++ b/cicm_web/Areas/Admin/Controllers/GpusByMachineController.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Threading.Tasks; using Cicm.Database.Models; +using cicm_web.Areas.Admin.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; @@ -25,7 +26,11 @@ namespace cicm_web.Areas.Admin.Controllers { IIncludableQueryable cicmContext = _context.GpusByMachine.Include(g => g.Gpu).Include(g => g.Machine); - return View(await cicmContext.OrderBy(g => g.Machine.Name).ThenBy(g => g.Gpu.Name).ToListAsync()); + return View(await cicmContext.OrderBy(g => g.Machine.Name).ThenBy(g => g.Gpu.Name) + .Select(g => new GpusByMachineViewModel + { + Id = g.Id, Gpu = g.Gpu.Name, Machine = g.Machine.Name + }).ToListAsync()); } // GET: GpusByMachine/Details/5 diff --git a/cicm_web/Areas/Admin/Models/GpusByMachineViewModel.cs b/cicm_web/Areas/Admin/Models/GpusByMachineViewModel.cs new file mode 100644 index 00000000..feea1f18 --- /dev/null +++ b/cicm_web/Areas/Admin/Models/GpusByMachineViewModel.cs @@ -0,0 +1,43 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : GpusByMachine.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Junction betweeen GPU and machine. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +using System.ComponentModel; +using Cicm.Database.Models; + +namespace cicm_web.Areas.Admin.Models +{ + public class GpusByMachineViewModel : BaseModel + { + [DisplayName("GPU")] + public string Gpu; + public long Id; + public string Machine; + } +} \ No newline at end of file diff --git a/cicm_web/Areas/Admin/Views/GpusByMachine/Index.cshtml b/cicm_web/Areas/Admin/Views/GpusByMachine/Index.cshtml index 599b8a64..47177744 100644 --- a/cicm_web/Areas/Admin/Views/GpusByMachine/Index.cshtml +++ b/cicm_web/Areas/Admin/Views/GpusByMachine/Index.cshtml @@ -1,4 +1,5 @@ -@model IEnumerable +@using cicm_web.Areas.Admin.Models +@model IEnumerable @{ ViewData["Title"] = "Index"; @@ -7,35 +8,51 @@

GPUs by machine

- Create New + + Create New +

- - - - - + + + + + -@foreach (var item in Model) { + @foreach(GpusByMachineViewModel item in Model) + { -} + } -
- @Html.DisplayNameFor(model => model.Machine) - - @Html.DisplayNameFor(model => model.Gpu) -
+ @Html.DisplayNameFor(model => model.Machine) + + @Html.DisplayNameFor(model => model.Gpu) +
- @Html.DisplayFor(modelItem => item.Machine.Name) + @Html.DisplayFor(modelItem => item.Machine) - @Html.DisplayFor(modelItem => item.Gpu.Name) + @Html.DisplayFor(modelItem => item.Gpu) - Details - Edit - Delete + + Details + + + Edit + + + Delete +
+ \ No newline at end of file diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index 67b4e26a..49b66f51 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.2 - 3.0.99.549 + 3.0.99.550 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website