Optimize view of storage by machine admin page.

This commit is contained in:
2019-05-20 00:43:25 +01:00
parent b7df0998aa
commit 07ff466117
4 changed files with 61 additions and 8 deletions

View File

@@ -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<StorageByMachine, Machine> 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

View File

@@ -0,0 +1,44 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : StorageByMachine.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// 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; }
}
}

View File

@@ -29,8 +29,8 @@
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
}
@using Cicm.Database.Models
@model IEnumerable<Cicm.Database.Models.StorageByMachine>
@using cicm_web.Areas.Admin.Models
@model IEnumerable<cicm_web.Areas.Admin.Models.StorageByMachineViewModel>
@{
ViewData["Title"] = "Storage by machines (Admin)";
@@ -48,7 +48,7 @@
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Machine.Company)
@Html.DisplayNameFor(model => model.Company)
</th>
<th>
@Html.DisplayNameFor(model => model.Machine)
@@ -66,14 +66,14 @@
</tr>
</thead>
<tbody>
@foreach(StorageByMachine item in Model)
@foreach(StorageByMachineViewModel item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Machine.Company.Name)
@Html.DisplayFor(modelItem => item.Company)
</td>
<td>
@Html.DisplayFor(modelItem => item.Machine.Name)
@Html.DisplayFor(modelItem => item.Machine)
</td>
<td>
@Html.DisplayFor(modelItem => item.Type)

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.544</Version>
<Version>3.0.99.545</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>