mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Aaru.Server.Models;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Aaru.Server.Areas.Admin.Controllers
|
|
{
|
|
[Area("Admin"), Authorize]
|
|
public sealed class UsbVendorsController : Controller
|
|
{
|
|
readonly AaruServerContext _context;
|
|
|
|
public UsbVendorsController(AaruServerContext context) => _context = context;
|
|
|
|
// GET: Admin/UsbVendors
|
|
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)
|
|
{
|
|
if(id == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
UsbVendor usbVendor = await _context.UsbVendors.FirstOrDefaultAsync(m => m.Id == id);
|
|
|
|
if(usbVendor == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
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()
|
|
});
|
|
}
|
|
}
|
|
} |