Optimize view of resolutions by gpu admin page.

This commit is contained in:
2019-05-20 00:24:26 +01:00
parent 3b057339a5
commit 91e9b04b45
4 changed files with 58 additions and 7 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;
@@ -28,7 +29,13 @@ namespace cicm_web.Areas.Admin.Controllers
return View(await cicmContext.OrderBy(r => r.Gpu.Company.Name).ThenBy(r => r.Gpu.Name)
.ThenBy(r => r.Resolution.Chars).ThenBy(r => r.Resolution.Width)
.ThenBy(r => r.Resolution.Height).ThenBy(r => r.Resolution.Colors)
.ToListAsync());
.Select(r => new ResolutionsByGpuViewModel
{
Gpu = r.Gpu.Name,
GpuCompany = r.Gpu.Company.Name,
Id = r.Id,
Resolution = r.Resolution
}).ToListAsync());
}
// GET: ResolutionsByGpu/Details/5

View File

@@ -0,0 +1,44 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : ResolutionsByGpu.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Junction of resolutions and gpus.
//
// --[ 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.ComponentModel;
using Cicm.Database.Models;
namespace cicm_web.Areas.Admin.Models
{
public class ResolutionsByGpuViewModel
{
public string GpuCompany;
public long Id;
[DisplayName("GPU")]
public string Gpu { get; set; }
public Resolution Resolution { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
@using Cicm.Database.Models
@model IEnumerable<Cicm.Database.Models.ResolutionsByGpu>
@using cicm_web.Areas.Admin.Models
@model IEnumerable<cicm_web.Areas.Admin.Models.ResolutionsByGpuViewModel>
@{
ViewData["Title"] = "Index";
@@ -26,12 +26,12 @@
</tr>
</thead>
<tbody>
@foreach(ResolutionsByGpu item in Model)
@foreach(ResolutionsByGpuViewModel item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Gpu.Company.Name)
@Html.DisplayFor(modelItem => item.Gpu.Name)
@Html.DisplayFor(modelItem => item.GpuCompany)
@Html.DisplayFor(modelItem => item.Gpu)
</td>
<td>
@item.Resolution

View File

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