mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Show products in USB vendor details.
This commit is contained in:
@@ -15,7 +15,8 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
public UsbVendorsController(DicServerContext context) => _context = context;
|
||||
|
||||
// GET: Admin/UsbVendors
|
||||
public async Task<IActionResult> Index() => View(await _context.UsbVendors.OrderBy(v => v.Vendor).ThenBy(v => v.VendorId).ToListAsync());
|
||||
public async Task<IActionResult> Index() =>
|
||||
View(await _context.UsbVendors.OrderBy(v => v.Vendor).ThenBy(v => v.VendorId).ToListAsync());
|
||||
|
||||
// GET: Admin/UsbVendors/Details/5
|
||||
public async Task<IActionResult> Details(int? id)
|
||||
@@ -32,7 +33,20 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(usbVendor);
|
||||
return View(new UsbVendorModel
|
||||
{
|
||||
Vendor = usbVendor.Vendor, VendorId = usbVendor.VendorId, Products = _context.
|
||||
UsbProducts.
|
||||
Where(p => p.VendorId ==
|
||||
usbVendor.Id).
|
||||
OrderBy(p => p.Product).
|
||||
ThenBy(p => p.ProductId).
|
||||
Select(p => new UsbProductModel
|
||||
{
|
||||
ProductId = p.ProductId,
|
||||
ProductName = p.Product
|
||||
}).ToList()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@model UsbVendor
|
||||
@model UsbVendorModel
|
||||
|
||||
@{
|
||||
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
|
||||
@@ -34,7 +34,7 @@
|
||||
// ****************************************************************************/
|
||||
}
|
||||
<div>
|
||||
<h4>UsbVendor</h4>
|
||||
<h4>USB vendor</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@@ -51,6 +51,43 @@
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Products:</h4>
|
||||
<table class="table" id="tblProducts">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Products[0].ProductName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Products[0].ProductId)
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model.Products)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ProductName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ProductId)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section scripts{
|
||||
<script crossorigin="anonymous" integrity="sha256-L4cf7m/cgC51e7BFPxQcKZcXryzSju7VYBKJLOKPHvQ=" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
|
||||
<script language="javascript">
|
||||
$(document).ready(function() {
|
||||
$('#tblProducts').DataTable();
|
||||
} );
|
||||
</script>
|
||||
}
|
||||
15
DiscImageChef.Server/Models/UsbVendorModel.cs
Normal file
15
DiscImageChef.Server/Models/UsbVendorModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DiscImageChef.Server.Models
|
||||
{
|
||||
public class UsbVendorModel
|
||||
{
|
||||
[DisplayName("Manufacturer")]
|
||||
public string Vendor { get; set; }
|
||||
[DisplayName("Vendor ID"), DisplayFormat(DataFormatString = "0x{0:X4}")]
|
||||
public ushort VendorId { get; set; }
|
||||
public List<UsbProductModel> Products { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user