mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Show vendor alongside usb product.
This commit is contained in:
@@ -3,9 +3,7 @@ using System.Threading.Tasks;
|
|||||||
using DiscImageChef.Server.Models;
|
using DiscImageChef.Server.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Query;
|
|
||||||
|
|
||||||
namespace DiscImageChef.Server.Areas.Admin.Controllers
|
namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||||
{
|
{
|
||||||
@@ -17,11 +15,14 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
|||||||
public UsbProductsController(DicServerContext context) => _context = context;
|
public UsbProductsController(DicServerContext context) => _context = context;
|
||||||
|
|
||||||
// GET: Admin/UsbProducts
|
// GET: Admin/UsbProducts
|
||||||
public async Task<IActionResult> Index()
|
public async Task<IActionResult> Index() => View(await _context.
|
||||||
{
|
UsbProducts.Include(u => u.Vendor).
|
||||||
IIncludableQueryable<UsbProduct, UsbVendor> dicServerContext = _context.UsbProducts.Include(u => u.Vendor);
|
OrderBy(p => p.Vendor.Vendor).ThenBy(p => p.Product).
|
||||||
|
ThenBy(p => p.ProductId).Select(p => new UsbProductModel
|
||||||
return View(await dicServerContext.ToListAsync());
|
{
|
||||||
}
|
ProductId = p.ProductId, ProductName = p.Product,
|
||||||
|
VendorId = p.Vendor.Id,
|
||||||
|
VendorName = p.Vendor.Vendor
|
||||||
|
}).ToListAsync());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@model IEnumerable<UsbProduct>
|
@model IEnumerable<UsbProductModel>
|
||||||
|
|
||||||
@{
|
@{
|
||||||
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
|
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
|
||||||
@@ -36,42 +36,30 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.VendorName)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayNameFor(model => model.ProductName)
|
||||||
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.ProductId)
|
@Html.DisplayNameFor(model => model.ProductId)
|
||||||
</th>
|
</th>
|
||||||
<th>
|
|
||||||
@Html.DisplayNameFor(model => model.Product)
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
@Html.DisplayNameFor(model => model.AddedWhen)
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
@Html.DisplayNameFor(model => model.ModifiedWhen)
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
@Html.DisplayNameFor(model => model.Vendor)
|
|
||||||
</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model)
|
@foreach (var item in Model)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a asp-controller="UsbVendors" asp-action="Details" asp-route-id="@item.VendorId" target="_blank">@Html.DisplayFor(modelItem => item.VendorName)</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ProductName)
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.ProductId)
|
@Html.DisplayFor(modelItem => item.ProductId)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Product)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.AddedWhen)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.ModifiedWhen)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Vendor.Id)
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
16
DiscImageChef.Server/Models/UsbProductModel.cs
Normal file
16
DiscImageChef.Server/Models/UsbProductModel.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace DiscImageChef.Server.Models
|
||||||
|
{
|
||||||
|
public class UsbProductModel
|
||||||
|
{
|
||||||
|
[DisplayName("Manufacturer")]
|
||||||
|
public string VendorName { get; set; }
|
||||||
|
public int VendorId { get; set; }
|
||||||
|
[DisplayName("Product")]
|
||||||
|
public string ProductName { get; set; }
|
||||||
|
[DisplayName("Product ID"), DisplayFormat(DataFormatString = "0x{0:X4}")]
|
||||||
|
public ushort ProductId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user