diff --git a/cicm_web/Areas/Admin/Controllers/StorageByMachinesController.cs b/cicm_web/Areas/Admin/Controllers/StorageByMachinesController.cs index 2a19d0f8..a51a41f6 100644 --- a/cicm_web/Areas/Admin/Controllers/StorageByMachinesController.cs +++ b/cicm_web/Areas/Admin/Controllers/StorageByMachinesController.cs @@ -31,6 +31,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; @@ -56,7 +57,15 @@ namespace cicm_web.Areas.Admin.Controllers IIncludableQueryable cicmContext = _context.StorageByMachine.Include(s => s.Machine); return View(await cicmContext.OrderBy(s => s.Machine.Company.Name).ThenBy(s => s.Machine.Name) - .ToListAsync()); + .Select(s => new StorageByMachineViewModel + { + Id = s.Id, + Company = s.Machine.Company.Name, + Machine = s.Machine.Name, + Type = s.Type, + Interface = s.Interface, + Capacity = s.Capacity + }).ToListAsync()); } // GET: Admin/StorageByMachines/Details/5 diff --git a/cicm_web/Areas/Admin/Models/StorageByMachineViewModel.cs b/cicm_web/Areas/Admin/Models/StorageByMachineViewModel.cs new file mode 100644 index 00000000..0d9fcbea --- /dev/null +++ b/cicm_web/Areas/Admin/Models/StorageByMachineViewModel.cs @@ -0,0 +1,44 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : StorageByMachine.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Junction of storage and machines. +// +// --[ 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 Cicm.Database; + +namespace cicm_web.Areas.Admin.Models +{ + public class StorageByMachineViewModel + { + public string Company; + public long Id; + public string Machine; + public StorageType Type { get; set; } + public StorageInterface Interface { get; set; } + public long? Capacity { get; set; } + } +} \ No newline at end of file diff --git a/cicm_web/Areas/Admin/Views/StorageByMachines/Index.cshtml b/cicm_web/Areas/Admin/Views/StorageByMachines/Index.cshtml index 7bd4596d..74c5b5a7 100644 --- a/cicm_web/Areas/Admin/Views/StorageByMachines/Index.cshtml +++ b/cicm_web/Areas/Admin/Views/StorageByMachines/Index.cshtml @@ -29,8 +29,8 @@ // Copyright © 2003-2018 Natalia Portillo *******************************************************************************/ } -@using Cicm.Database.Models -@model IEnumerable +@using cicm_web.Areas.Admin.Models +@model IEnumerable @{ ViewData["Title"] = "Storage by machines (Admin)"; @@ -48,7 +48,7 @@ - @Html.DisplayNameFor(model => model.Machine.Company) + @Html.DisplayNameFor(model => model.Company) @Html.DisplayNameFor(model => model.Machine) @@ -66,14 +66,14 @@ - @foreach(StorageByMachine item in Model) + @foreach(StorageByMachineViewModel item in Model) { - @Html.DisplayFor(modelItem => item.Machine.Company.Name) + @Html.DisplayFor(modelItem => item.Company) - @Html.DisplayFor(modelItem => item.Machine.Name) + @Html.DisplayFor(modelItem => item.Machine) @Html.DisplayFor(modelItem => item.Type) diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index c3803bb7..b6866262 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.2 - 3.0.99.544 + 3.0.99.545 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website