mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Remove details, edit and delete from USB products.
This commit is contained in:
@@ -23,113 +23,5 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
|
||||
return View(await dicServerContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Admin/UsbProducts/Details/5
|
||||
public async Task<IActionResult> Details(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
UsbProduct usbProduct =
|
||||
await _context.UsbProducts.Include(u => u.Vendor).FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if(usbProduct == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(usbProduct);
|
||||
}
|
||||
|
||||
// GET: Admin/UsbProducts/Edit/5
|
||||
public async Task<IActionResult> Edit(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
UsbProduct usbProduct = await _context.UsbProducts.FindAsync(id);
|
||||
|
||||
if(usbProduct == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewData["VendorId"] = new SelectList(_context.UsbVendors, "Id", "Id", usbProduct.VendorId);
|
||||
|
||||
return View(usbProduct);
|
||||
}
|
||||
|
||||
// POST: Admin/UsbProducts/Edit/5
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost, ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(int id, [Bind("Id,ProductId,Product,AddedWhen,ModifiedWhen,VendorId")]
|
||||
UsbProduct usbProduct)
|
||||
{
|
||||
if(id != usbProduct.Id)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Update(usbProduct);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
if(!UsbProductExists(usbProduct.Id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
ViewData["VendorId"] = new SelectList(_context.UsbVendors, "Id", "Id", usbProduct.VendorId);
|
||||
|
||||
return View(usbProduct);
|
||||
}
|
||||
|
||||
// GET: Admin/UsbProducts/Delete/5
|
||||
public async Task<IActionResult> Delete(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
UsbProduct usbProduct =
|
||||
await _context.UsbProducts.Include(u => u.Vendor).FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if(usbProduct == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(usbProduct);
|
||||
}
|
||||
|
||||
// POST: Admin/UsbProducts/Delete/5
|
||||
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(int id)
|
||||
{
|
||||
UsbProduct usbProduct = await _context.UsbProducts.FindAsync(id);
|
||||
_context.UsbProducts.Remove(usbProduct);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
bool UsbProductExists(int id) => _context.UsbProducts.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user