Optimize view of GPUs by machine admin page.

This commit is contained in:
2019-05-20 01:11:45 +01:00
parent f54a8599ea
commit 43e472732f
4 changed files with 86 additions and 21 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;
@@ -25,7 +26,11 @@ namespace cicm_web.Areas.Admin.Controllers
{
IIncludableQueryable<GpusByMachine, Machine> cicmContext =
_context.GpusByMachine.Include(g => g.Gpu).Include(g => g.Machine);
return View(await cicmContext.OrderBy(g => g.Machine.Name).ThenBy(g => g.Gpu.Name).ToListAsync());
return View(await cicmContext.OrderBy(g => g.Machine.Name).ThenBy(g => g.Gpu.Name)
.Select(g => new GpusByMachineViewModel
{
Id = g.Id, Gpu = g.Gpu.Name, Machine = g.Machine.Name
}).ToListAsync());
}
// GET: GpusByMachine/Details/5