mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Optimize view of machine families admin page.
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Cicm.Database.Models;
|
using Cicm.Database.Models;
|
||||||
|
using cicm_web.Areas.Admin.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
@@ -54,7 +55,11 @@ namespace cicm_web.Areas.Admin.Controllers
|
|||||||
public async Task<IActionResult> Index()
|
public async Task<IActionResult> Index()
|
||||||
{
|
{
|
||||||
IIncludableQueryable<MachineFamily, Company> cicmContext = _context.MachineFamilies.Include(m => m.Company);
|
IIncludableQueryable<MachineFamily, Company> cicmContext = _context.MachineFamilies.Include(m => m.Company);
|
||||||
return View(await cicmContext.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).ToListAsync());
|
return View(await cicmContext.OrderBy(m => m.Company.Name).ThenBy(m => m.Name)
|
||||||
|
.Select(m => new MachineFamilyViewModel
|
||||||
|
{
|
||||||
|
Id = m.Id, Company = m.Company.Name, Name = m.Name
|
||||||
|
}).ToListAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: Admin/MachineFamilies/Details/5
|
// GET: Admin/MachineFamilies/Details/5
|
||||||
|
|||||||
9
cicm_web/Areas/Admin/Models/MachineFamilyViewModel.cs
Normal file
9
cicm_web/Areas/Admin/Models/MachineFamilyViewModel.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace cicm_web.Areas.Admin.Models
|
||||||
|
{
|
||||||
|
public class MachineFamilyViewModel
|
||||||
|
{
|
||||||
|
public string Company;
|
||||||
|
public int Id;
|
||||||
|
public string Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,8 +29,8 @@
|
|||||||
// Copyright © 2003-2018 Natalia Portillo
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
@using Cicm.Database.Models
|
@using cicm_web.Areas.Admin.Models
|
||||||
@model IEnumerable<Cicm.Database.Models.MachineFamily>
|
@model IEnumerable<cicm_web.Areas.Admin.Models.MachineFamilyViewModel>
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Machine families (Admin)";
|
ViewData["Title"] = "Machine families (Admin)";
|
||||||
@@ -57,11 +57,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach(MachineFamily item in Model)
|
@foreach(MachineFamilyViewModel item in Model)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Company.Name)
|
@Html.DisplayFor(modelItem => item.Company)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Name)
|
@Html.DisplayFor(modelItem => item.Name)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<Version>3.0.99.536</Version>
|
<Version>3.0.99.537</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user