diff --git a/cicm_web/Areas/Admin/Controllers/ProcessorsController.cs b/cicm_web/Areas/Admin/Controllers/ProcessorsController.cs index 1d15c2dd..1082081d 100644 --- a/cicm_web/Areas/Admin/Controllers/ProcessorsController.cs +++ b/cicm_web/Areas/Admin/Controllers/ProcessorsController.cs @@ -55,7 +55,16 @@ namespace cicm_web.Areas.Admin.Controllers { IIncludableQueryable 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 diff --git a/cicm_web/Areas/Admin/Models/ProcessorViewModel.cs b/cicm_web/Areas/Admin/Models/ProcessorViewModel.cs new file mode 100644 index 00000000..871d6960 --- /dev/null +++ b/cicm_web/Areas/Admin/Models/ProcessorViewModel.cs @@ -0,0 +1,56 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Processor.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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"; + } +} \ No newline at end of file diff --git a/cicm_web/Areas/Admin/Views/Processors/Index.cshtml b/cicm_web/Areas/Admin/Views/Processors/Index.cshtml index c6427b3e..0d04aacc 100644 --- a/cicm_web/Areas/Admin/Views/Processors/Index.cshtml +++ b/cicm_web/Areas/Admin/Views/Processors/Index.cshtml @@ -30,7 +30,7 @@ *******************************************************************************/ } @using Cicm.Database.Models -@model IEnumerable +@model IEnumerable @{ ViewData["Title"] = "Processors (Admin)"; @@ -66,11 +66,11 @@ - @foreach(Processor item in Model) + @foreach(ProcessorViewModel item in Model) { - @Html.DisplayFor(modelItem => item.Company.Name) + @Html.DisplayFor(modelItem => item.Company) @Html.DisplayFor(modelItem => item.Name) @@ -82,7 +82,7 @@ @Html.DisplayFor(modelItem => item.IntroducedView) - @Html.DisplayFor(modelItem => item.InstructionSet.Name) + @Html.DisplayFor(modelItem => item.InstructionSet) netcoreapp2.2 - 3.0.99.540 + 3.0.99.541 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website