Sort processors by machine in admin page.

This commit is contained in:
2019-05-19 00:29:46 +01:00
parent 9e3c0e7ea7
commit 86470c6bca
8 changed files with 59 additions and 49 deletions

View File

@@ -28,12 +28,15 @@
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
using System.ComponentModel;
namespace Cicm.Database.Models
{
public class ProcessorsByMachine
{
public int ProcessorId { get; set; }
public int MachineId { get; set; }
[DisplayName("Speed (MHz)")]
public float? Speed { get; set; }
public long Id { get; set; }

View File

@@ -55,7 +55,7 @@ namespace cicm_web.Areas.Admin.Controllers
{
IIncludableQueryable<ProcessorsByMachine, Processor> cicmContext =
_context.ProcessorsByMachine.Include(p => p.Machine).Include(p => p.Processor);
return View(await cicmContext.ToListAsync());
return View(await cicmContext.OrderBy(p => p.Machine.Name).ThenBy(p => p.Processor.Name).ToListAsync());
}
// GET: Admin/ProcessorsByMachines/Details/5

View File

@@ -45,6 +45,15 @@
<div asp-validation-summary="ModelOnly"
class="text-danger">
</div>
<div class="form-group">
<label asp-for="Machine"
class="control-label">
</label>
<select asp-for="Machine"
class="form-control"
asp-items="ViewBag.MachineId">
</select>
</div>
<div class="form-group">
<label asp-for="ProcessorId"
class="control-label">
@@ -54,15 +63,6 @@
asp-items="ViewBag.ProcessorId">
</select>
</div>
<div class="form-group">
<label asp-for="MachineId"
class="control-label">
</label>
<select asp-for="MachineId"
class="form-control"
asp-items="ViewBag.MachineId">
</select>
</div>
<div class="form-group">
<label asp-for="Speed"
class="control-label">

View File

@@ -42,12 +42,6 @@
<h4>Processors by machine</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Speed)
</dt>
<dd>
@Html.DisplayFor(model => model.Speed)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Machine)
</dt>
@@ -60,6 +54,12 @@
<dd>
@Html.DisplayFor(model => model.Processor.Name)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Speed)
</dt>
<dd>
@Html.DisplayFor(model => model.Speed)
</dd>
</dl>
<form asp-action="Delete">

View File

@@ -41,12 +41,6 @@
<h4>Processors by machine</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Speed)
</dt>
<dd>
@Html.DisplayFor(model => model.Speed)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Machine)
</dt>
@@ -59,9 +53,22 @@
<dd>
@Html.DisplayFor(model => model.Processor.Name)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Speed)
</dt>
<dd>
@Html.DisplayFor(model => model.Speed)
</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

@@ -46,19 +46,7 @@
class="text-danger">
</div>
<div class="form-group">
<label asp-for="ProcessorId"
class="control-label">
</label>
<select asp-for="ProcessorId"
class="form-control"
asp-items="ViewBag.ProcessorId">
</select>
<span asp-validation-for="ProcessorId"
class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="MachineId"
<label asp-for="Machine"
class="control-label">
</label>
<select asp-for="MachineId"
@@ -69,6 +57,18 @@
class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Processor"
class="control-label">
</label>
<select asp-for="ProcessorId"
class="form-control"
asp-items="ViewBag.ProcessorId">
</select>
<span asp-validation-for="ProcessorId"
class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Speed"
class="control-label">

View File

@@ -47,15 +47,15 @@
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Speed)
</th>
<th>
@Html.DisplayNameFor(model => model.Machine)
</th>
<th>
@Html.DisplayNameFor(model => model.Processor)
</th>
<th>
@Html.DisplayNameFor(model => model.Speed)
</th>
<th></th>
</tr>
</thead>
@@ -63,15 +63,15 @@
@foreach(ProcessorsByMachine item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Speed)
</td>
<td>
@Html.DisplayFor(modelItem => item.Machine.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Processor.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Speed)
</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.443</Version>
<Version>3.0.99.445</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>