Optimize view of instruction set extensions by processor admin page.

This commit is contained in:
2019-05-19 23:37:58 +01:00
parent 60cdf6f98b
commit 4a58d8df7e
5 changed files with 24 additions and 8 deletions

View File

@@ -1,6 +1,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;
@@ -26,7 +27,12 @@ namespace cicm_web.Areas.Admin.Controllers
IIncludableQueryable<InstructionSetExtensionsByProcessor, Processor> cicmContext =
_context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor);
return View(await cicmContext.OrderBy(e => e.Processor.Name).ThenBy(e => e.Extension.Extension)
.ToListAsync());
.Select(e => new InstructionSetExtensionsByProcessorViewModel
{
Id = e.Id,
Extension = e.Extension.Extension,
Processor = e.Processor.Name
}).ToListAsync());
}
// GET: InstructionSetExtensionsByProcessor/Details/5

View File

@@ -16,6 +16,7 @@ namespace cicm_web.Areas.Admin.Models
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
public DateTime? Sold { get; set; }
[DisplayName("Sold to")]
public string SoldTo { get; set; }
public string Country { get; set; }
[Required]

View File

@@ -0,0 +1,9 @@
namespace cicm_web.Areas.Admin.Models
{
public class InstructionSetExtensionsByProcessorViewModel
{
public string Extension;
public int Id;
public string Processor;
}
}

View File

@@ -1,5 +1,5 @@
@using Cicm.Database.Models
@model IEnumerable<Cicm.Database.Models.InstructionSetExtensionsByProcessor>
@using cicm_web.Areas.Admin.Models
@model IEnumerable<cicm_web.Areas.Admin.Models.InstructionSetExtensionsByProcessorViewModel>
@{
ViewData["Title"] = "Index";
@@ -26,14 +26,14 @@
</tr>
</thead>
<tbody>
@foreach(InstructionSetExtensionsByProcessor item in Model)
@foreach(InstructionSetExtensionsByProcessorViewModel item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Processor.Name)
@Html.DisplayFor(modelItem => item.Processor)
</td>
<td>
@Html.DisplayFor(modelItem => item.Extension.Extension)
@Html.DisplayFor(modelItem => item.Extension)
</td>
<td>
<a asp-action="Details"

View File

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