Sort memories by machine in admin page.

This commit is contained in:
2019-05-18 22:03:59 +01:00
parent b916bcedfa
commit b8614aca51
8 changed files with 80 additions and 44 deletions

View File

@@ -28,6 +28,8 @@
// Copyright © 2003-2018 Natalia Portillo // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
using System.ComponentModel;
namespace Cicm.Database.Models namespace Cicm.Database.Models
{ {
public class MemoryByMachine public class MemoryByMachine
@@ -36,8 +38,9 @@ namespace Cicm.Database.Models
public MemoryType Type { get; set; } public MemoryType Type { get; set; }
public MemoryUsage Usage { get; set; } public MemoryUsage Usage { get; set; }
public long? Size { get; set; } public long? Size { get; set; }
public double? Speed { get; set; } [DisplayName("Speed (Hz)")]
public long Id { get; set; } public double? Speed { get; set; }
public long Id { get; set; }
public virtual Machine Machine { get; set; } public virtual Machine Machine { get; set; }
} }

View File

@@ -55,7 +55,8 @@ namespace cicm_web.Areas.Admin.Controllers
{ {
IIncludableQueryable<MemoryByMachine, Machine> cicmContext = IIncludableQueryable<MemoryByMachine, Machine> cicmContext =
_context.MemoryByMachine.Include(m => m.Machine); _context.MemoryByMachine.Include(m => m.Machine);
return View(await cicmContext.ToListAsync()); return View(await cicmContext.OrderBy(m => m.Machine.Name).ThenBy(m => m.Usage).ThenBy(m => m.Size)
.ThenBy(m => m.Type).ToListAsync());
} }
// GET: Admin/MemoryByMachines/Details/5 // GET: Admin/MemoryByMachines/Details/5

View File

@@ -29,6 +29,7 @@
// Copyright © 2003-2018 Natalia Portillo // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
} }
@using Cicm.Database
@model Cicm.Database.Models.MemoryByMachine @model Cicm.Database.Models.MemoryByMachine
@{ @{
@@ -54,6 +55,30 @@
asp-items="ViewBag.MachineId"> asp-items="ViewBag.MachineId">
</select> </select>
</div> </div>
<div class="form-group">
<label asp-for="Usage"
class="control-label">
</label>
<select asp-for="Usage"
class="form-control"
asp-items="Html.GetEnumSelectList<MemoryUsage>().OrderBy(s => s.Text)">
</select>
<span asp-validation-for="Usage"
class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Type"
class="control-label">
</label>
<select asp-for="Type"
class="form-control"
asp-items="Html.GetEnumSelectList<MemoryType>().OrderBy(s => s.Text)">
</select>
<span asp-validation-for="Type"
class="text-danger">
</span>
</div>
<div class="form-group"> <div class="form-group">
<label asp-for="Size" <label asp-for="Size"
class="control-label"> class="control-label">

View File

@@ -43,10 +43,10 @@
<hr /> <hr />
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt> <dt>
@Html.DisplayNameFor(model => model.Type) @Html.DisplayNameFor(model => model.Machine)
</dt> </dt>
<dd> <dd>
@Html.DisplayFor(model => model.Type) @Html.DisplayFor(model => model.Machine.Name)
</dd> </dd>
<dt> <dt>
@Html.DisplayNameFor(model => model.Usage) @Html.DisplayNameFor(model => model.Usage)
@@ -54,6 +54,12 @@
<dd> <dd>
@Html.DisplayFor(model => model.Usage) @Html.DisplayFor(model => model.Usage)
</dd> </dd>
<dt>
@Html.DisplayNameFor(model => model.Type)
</dt>
<dd>
@Html.DisplayFor(model => model.Type)
</dd>
<dt> <dt>
@Html.DisplayNameFor(model => model.Size) @Html.DisplayNameFor(model => model.Size)
</dt> </dt>
@@ -66,12 +72,6 @@
<dd> <dd>
@Html.DisplayFor(model => model.Speed) @Html.DisplayFor(model => model.Speed)
</dd> </dd>
<dt>
@Html.DisplayNameFor(model => model.Machine)
</dt>
<dd>
@Html.DisplayFor(model => model.Machine.Name)
</dd>
</dl> </dl>
<form asp-action="Delete"> <form asp-action="Delete">

View File

@@ -42,10 +42,10 @@
<hr /> <hr />
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt> <dt>
@Html.DisplayNameFor(model => model.Type) @Html.DisplayNameFor(model => model.Machine)
</dt> </dt>
<dd> <dd>
@Html.DisplayFor(model => model.Type) @Html.DisplayFor(model => model.Machine.Name)
</dd> </dd>
<dt> <dt>
@Html.DisplayNameFor(model => model.Usage) @Html.DisplayNameFor(model => model.Usage)
@@ -53,6 +53,12 @@
<dd> <dd>
@Html.DisplayFor(model => model.Usage) @Html.DisplayFor(model => model.Usage)
</dd> </dd>
<dt>
@Html.DisplayNameFor(model => model.Type)
</dt>
<dd>
@Html.DisplayFor(model => model.Type)
</dd>
<dt> <dt>
@Html.DisplayNameFor(model => model.Size) @Html.DisplayNameFor(model => model.Size)
</dt> </dt>
@@ -65,15 +71,16 @@
<dd> <dd>
@Html.DisplayFor(model => model.Speed) @Html.DisplayFor(model => model.Speed)
</dd> </dd>
<dt>
@Html.DisplayNameFor(model => model.Machine)
</dt>
<dd>
@Html.DisplayFor(model => model.Machine.Name)
</dd>
</dl> </dl>
</div> </div>
<div> <div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">Edit</a> <a asp-action="Edit"
<a asp-action="Index" class="btn btn-secondary">Back to List</a> asp-route-id="@Model.Id"
</div> class="btn btn-primary">
Edit
</a>
<a asp-action="Index"
class="btn btn-secondary">
Back to List
</a>
</div>

View File

@@ -29,6 +29,7 @@
// Copyright © 2003-2018 Natalia Portillo // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
} }
@using Cicm.Database
@model Cicm.Database.Models.MemoryByMachine @model Cicm.Database.Models.MemoryByMachine
@{ @{
@@ -53,7 +54,16 @@
class="form-control" class="form-control"
asp-items="ViewBag.MachineId"> asp-items="ViewBag.MachineId">
</select> </select>
<span asp-validation-for="MachineId" </div>
<div class="form-group">
<label asp-for="Usage"
class="control-label">
</label>
<select asp-for="Usage"
class="form-control"
asp-items="Html.GetEnumSelectList<MemoryUsage>().OrderBy(s => s.Text)">
</select>
<span asp-validation-for="Usage"
class="text-danger"> class="text-danger">
</span> </span>
</div> </div>
@@ -62,23 +72,13 @@
class="control-label"> class="control-label">
</label> </label>
<select asp-for="Type" <select asp-for="Type"
class="form-control"> class="form-control"
asp-items="Html.GetEnumSelectList<MemoryType>().OrderBy(s => s.Text)">
</select> </select>
<span asp-validation-for="Type" <span asp-validation-for="Type"
class="text-danger"> class="text-danger">
</span> </span>
</div> </div>
<div class="form-group">
<label asp-for="Usage"
class="control-label">
</label>
<select asp-for="Usage"
class="form-control">
</select>
<span asp-validation-for="Usage"
class="text-danger">
</span>
</div>
<div class="form-group"> <div class="form-group">
<label asp-for="Size" <label asp-for="Size"
class="control-label"> class="control-label">

View File

@@ -48,20 +48,20 @@
<thead> <thead>
<tr> <tr>
<th> <th>
@Html.DisplayNameFor(model => model.Type) @Html.DisplayNameFor(model => model.Machine)
</th> </th>
<th> <th>
@Html.DisplayNameFor(model => model.Usage) @Html.DisplayNameFor(model => model.Usage)
</th> </th>
<th>
@Html.DisplayNameFor(model => model.Type)
</th>
<th> <th>
@Html.DisplayNameFor(model => model.Size) @Html.DisplayNameFor(model => model.Size)
</th> </th>
<th> <th>
@Html.DisplayNameFor(model => model.Speed) @Html.DisplayNameFor(model => model.Speed)
</th> </th>
<th>
@Html.DisplayNameFor(model => model.Machine)
</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@@ -70,20 +70,20 @@
{ {
<tr> <tr>
<td> <td>
@Html.DisplayFor(modelItem => item.Type) @Html.DisplayFor(modelItem => item.Machine.Name)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => item.Usage) @Html.DisplayFor(modelItem => item.Usage)
</td> </td>
<td>
@Html.DisplayFor(modelItem => item.Type)
</td>
<td> <td>
@Html.DisplayFor(modelItem => item.Size) @Html.DisplayFor(modelItem => item.Size)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => item.Speed) @Html.DisplayFor(modelItem => item.Speed)
</td> </td>
<td>
@Html.DisplayFor(modelItem => item.Machine.Name)
</td>
<td> <td>
<a asp-action="Details" <a asp-action="Details"
asp-route-id="@item.Id" asp-route-id="@item.Id"

View File

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