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
*******************************************************************************/
using System.ComponentModel;
namespace Cicm.Database.Models
{
public class MemoryByMachine
@@ -36,6 +38,7 @@ namespace Cicm.Database.Models
public MemoryType Type { get; set; }
public MemoryUsage Usage { get; set; }
public long? Size { get; set; }
[DisplayName("Speed (Hz)")]
public double? Speed { get; set; }
public long Id { get; set; }

View File

@@ -55,7 +55,8 @@ namespace cicm_web.Areas.Admin.Controllers
{
IIncludableQueryable<MemoryByMachine, Machine> cicmContext =
_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

View File

@@ -29,6 +29,7 @@
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
}
@using Cicm.Database
@model Cicm.Database.Models.MemoryByMachine
@{
@@ -54,6 +55,30 @@
asp-items="ViewBag.MachineId">
</select>
</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">
<label asp-for="Size"
class="control-label">

View File

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

View File

@@ -42,10 +42,10 @@
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Type)
@Html.DisplayNameFor(model => model.Machine)
</dt>
<dd>
@Html.DisplayFor(model => model.Type)
@Html.DisplayFor(model => model.Machine.Name)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Usage)
@@ -53,6 +53,12 @@
<dd>
@Html.DisplayFor(model => model.Usage)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Type)
</dt>
<dd>
@Html.DisplayFor(model => model.Type)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Size)
</dt>
@@ -65,15 +71,16 @@
<dd>
@Html.DisplayFor(model => model.Speed)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Machine)
</dt>
<dd>
@Html.DisplayFor(model => model.Machine.Name)
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">Edit</a>
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
<a asp-action="Edit"
asp-route-id="@Model.Id"
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
*******************************************************************************/
}
@using Cicm.Database
@model Cicm.Database.Models.MemoryByMachine
@{
@@ -53,7 +54,16 @@
class="form-control"
asp-items="ViewBag.MachineId">
</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">
</span>
</div>
@@ -62,23 +72,13 @@
class="control-label">
</label>
<select asp-for="Type"
class="form-control">
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">
<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">
<label asp-for="Size"
class="control-label">

View File

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

View File

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