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 // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
using System.ComponentModel;
namespace Cicm.Database.Models namespace Cicm.Database.Models
{ {
public class ProcessorsByMachine public class ProcessorsByMachine
{ {
public int ProcessorId { get; set; } public int ProcessorId { get; set; }
public int MachineId { get; set; } public int MachineId { get; set; }
[DisplayName("Speed (MHz)")]
public float? Speed { get; set; } public float? Speed { get; set; }
public long Id { get; set; } public long Id { get; set; }

View File

@@ -55,7 +55,7 @@ namespace cicm_web.Areas.Admin.Controllers
{ {
IIncludableQueryable<ProcessorsByMachine, Processor> cicmContext = IIncludableQueryable<ProcessorsByMachine, Processor> cicmContext =
_context.ProcessorsByMachine.Include(p => p.Machine).Include(p => p.Processor); _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 // GET: Admin/ProcessorsByMachines/Details/5

View File

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

View File

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

View File

@@ -41,12 +41,6 @@
<h4>Processors by machine</h4> <h4>Processors by machine</h4>
<hr /> <hr />
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Speed)
</dt>
<dd>
@Html.DisplayFor(model => model.Speed)
</dd>
<dt> <dt>
@Html.DisplayNameFor(model => model.Machine) @Html.DisplayNameFor(model => model.Machine)
</dt> </dt>
@@ -59,9 +53,22 @@
<dd> <dd>
@Html.DisplayFor(model => model.Processor.Name) @Html.DisplayFor(model => model.Processor.Name)
</dd> </dd>
<dt>
@Html.DisplayNameFor(model => model.Speed)
</dt>
<dd>
@Html.DisplayFor(model => model.Speed)
</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"
class="btn btn-primary">
Edit
</a>
<a asp-action="Index"
class="btn btn-secondary">
Back to List
</a>
</div> </div>

View File

@@ -46,19 +46,7 @@
class="text-danger"> class="text-danger">
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="ProcessorId" <label asp-for="Machine"
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"
class="control-label"> class="control-label">
</label> </label>
<select asp-for="MachineId" <select asp-for="MachineId"
@@ -69,6 +57,18 @@
class="text-danger"> class="text-danger">
</span> </span>
</div> </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"> <div class="form-group">
<label asp-for="Speed" <label asp-for="Speed"
class="control-label"> class="control-label">

View File

@@ -47,15 +47,15 @@
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th>
@Html.DisplayNameFor(model => model.Speed)
</th>
<th> <th>
@Html.DisplayNameFor(model => model.Machine) @Html.DisplayNameFor(model => model.Machine)
</th> </th>
<th> <th>
@Html.DisplayNameFor(model => model.Processor) @Html.DisplayNameFor(model => model.Processor)
</th> </th>
<th>
@Html.DisplayNameFor(model => model.Speed)
</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@@ -63,15 +63,15 @@
@foreach(ProcessorsByMachine item in Model) @foreach(ProcessorsByMachine item in Model)
{ {
<tr> <tr>
<td>
@Html.DisplayFor(modelItem => item.Speed)
</td>
<td> <td>
@Html.DisplayFor(modelItem => item.Machine.Name) @Html.DisplayFor(modelItem => item.Machine.Name)
</td> </td>
<td> <td>
@Html.DisplayFor(modelItem => item.Processor.Name) @Html.DisplayFor(modelItem => item.Processor.Name)
</td> </td>
<td>
@Html.DisplayFor(modelItem => item.Speed)
</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.443</Version> <Version>3.0.99.445</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>