mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Optimize view of processors admin page.
This commit is contained in:
@@ -55,7 +55,16 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
{
|
||||
IIncludableQueryable<Processor, InstructionSet> cicmContext =
|
||||
_context.Processors.Include(p => p.Company).Include(p => p.InstructionSet);
|
||||
return View(await cicmContext.OrderBy(p => p.Company.Name).ThenBy(p => p.Name).ToListAsync());
|
||||
return View(await cicmContext.OrderBy(p => p.Company.Name).ThenBy(p => p.Name)
|
||||
.Select(p => new ProcessorViewModel
|
||||
{
|
||||
Company = p.Company.Name,
|
||||
Id = p.Id,
|
||||
InstructionSet = p.InstructionSet.Name,
|
||||
Introduced = p.Introduced,
|
||||
ModelCode = p.ModelCode,
|
||||
Name = p.Name
|
||||
}).ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Admin/Processors/Details/5
|
||||
|
||||
56
cicm_web/Areas/Admin/Models/ProcessorViewModel.cs
Normal file
56
cicm_web/Areas/Admin/Models/ProcessorViewModel.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Processor.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Describes general purpose processors or application specific coprocessors
|
||||
// that are not strictly for graphic or sound generation.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2018 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class ProcessorViewModel
|
||||
{
|
||||
public int Id;
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Company { get; set; }
|
||||
[DisplayName("Model code")]
|
||||
public string ModelCode { get; set; }
|
||||
[DisplayFormat(DataFormatString = "{0:d}")]
|
||||
[DataType(DataType.Date)]
|
||||
public DateTime? Introduced { get; set; }
|
||||
[DisplayName("Instruction set")]
|
||||
public string InstructionSet { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
*******************************************************************************/
|
||||
}
|
||||
@using Cicm.Database.Models
|
||||
@model IEnumerable<Cicm.Database.Models.Processor>
|
||||
@model IEnumerable<Cicm.Database.Models.ProcessorViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Processors (Admin)";
|
||||
@@ -66,11 +66,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(Processor item in Model)
|
||||
@foreach(ProcessorViewModel item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Company.Name)
|
||||
@Html.DisplayFor(modelItem => item.Company)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
@@ -82,7 +82,7 @@
|
||||
@Html.DisplayFor(modelItem => item.IntroducedView)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.InstructionSet.Name)
|
||||
@Html.DisplayFor(modelItem => item.InstructionSet)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Details"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.540</Version>
|
||||
<Version>3.0.99.541</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user