mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Remove details and edit from media formats.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DiscImageChef.Server.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -17,76 +16,6 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
// GET: Admin/MediaFormats
|
||||
public async Task<IActionResult> Index() => View(await _context.MediaFormats.ToListAsync());
|
||||
|
||||
// GET: Admin/MediaFormats/Details/5
|
||||
public async Task<IActionResult> Details(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
MediaFormat mediaFormat = await _context.MediaFormats.FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if(mediaFormat == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(mediaFormat);
|
||||
}
|
||||
|
||||
// GET: Admin/MediaFormats/Edit/5
|
||||
public async Task<IActionResult> Edit(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
MediaFormat mediaFormat = await _context.MediaFormats.FindAsync(id);
|
||||
|
||||
if(mediaFormat == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(mediaFormat);
|
||||
}
|
||||
|
||||
// POST: Admin/MediaFormats/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,Name,Count")] MediaFormat mediaFormat)
|
||||
{
|
||||
if(id != mediaFormat.Id)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Update(mediaFormat);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
if(!MediaFormatExists(mediaFormat.Id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
return View(mediaFormat);
|
||||
}
|
||||
|
||||
// GET: Admin/MediaFormats/Delete/5
|
||||
public async Task<IActionResult> Delete(int? id)
|
||||
{
|
||||
@@ -115,7 +44,5 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
bool MediaFormatExists(int id) => _context.MediaFormats.Any(e => e.Id == id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user