Files
Aaru.Server/DiscImageChef.Server/Areas/Admin/Controllers/SupportedDensitiesController.cs

57 lines
2.3 KiB
C#
Raw Normal View History

2019-11-17 21:12:26 +00:00
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Authorization;
2019-11-08 20:30:13 +00:00
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
2019-11-08 20:30:13 +00:00
[Area("Admin"), Authorize]
public class SupportedDensitiesController : Controller
{
2019-11-08 20:30:13 +00:00
readonly DicServerContext _context;
2019-11-08 20:30:13 +00:00
public SupportedDensitiesController(DicServerContext context) => _context = context;
// GET: Admin/SupportedDensities
2019-11-17 21:12:26 +00:00
public async Task<IActionResult> Index() => View(await _context.
SupportedDensity.OrderBy(d => d.Organization).
ThenBy(d => d.Name).ThenBy(d => d.Description).
ThenBy(d => d.Capacity).ThenBy(d => d.PrimaryCode).
ThenBy(d => d.SecondaryCode).ThenBy(d => d.BitsPerMm).
ThenBy(d => d.Width).ThenBy(d => d.Tracks).
ThenBy(d => d.DefaultDensity).ThenBy(d => d.Writable).
ThenBy(d => d.Duplicate).ToListAsync());
// GET: Admin/SupportedDensities/Delete/5
public async Task<IActionResult> Delete(int? id)
{
2019-11-08 20:30:13 +00:00
if(id == null)
{
return NotFound();
}
2019-11-08 20:30:13 +00:00
SupportedDensity supportedDensity = await _context.SupportedDensity.FirstOrDefaultAsync(m => m.Id == id);
if(supportedDensity == null)
{
return NotFound();
}
return View(supportedDensity);
}
// POST: Admin/SupportedDensities/Delete/5
2019-11-08 20:30:13 +00:00
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
2019-11-08 20:30:13 +00:00
SupportedDensity supportedDensity = await _context.SupportedDensity.FindAsync(id);
_context.SupportedDensity.Remove(supportedDensity);
await _context.SaveChangesAsync();
2019-11-08 20:30:13 +00:00
return RedirectToAction(nameof(Index));
}
}
2019-11-08 20:30:13 +00:00
}