Implement index admin page for screens by machine.

This commit is contained in:
2019-06-02 02:26:18 +01:00
parent 619777a200
commit 39adb7c702
7 changed files with 79 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,14 @@ namespace cicm_web.Areas.Admin.Controllers
{
IIncludableQueryable<ScreensByMachine, Screen> cicmContext =
_context.ScreensByMachine.Include(s => s.Machine).Include(s => s.Screen);
return View(await cicmContext.ToListAsync());
return View(await cicmContext.Select(s => new ScreensByMachineViewModel
{
Id = s.Id,
Screen = s.Screen.NativeResolution != null
? $"{s.Screen.Diagonal}\" {s.Screen.Type} with {s.Screen.NativeResolution}"
: $"{s.Screen.Diagonal}\" {s.Screen}",
Machine = $"{s.Machine.Company.Name} {s.Machine.Name}"
}).OrderBy(s => s.Machine).ThenBy(s => s.Screen).ToListAsync());
}
// GET: ScreensByMachine/Details/5