Add CRUD for main database tables.

This commit is contained in:
2019-11-07 22:43:37 +00:00
parent 4753cf3dbe
commit bae387df50
85 changed files with 5513 additions and 0 deletions

View File

@@ -0,0 +1,140 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class CommandsController : Controller
{
readonly DicServerContext _context;
public CommandsController(DicServerContext context) => _context = context;
// GET: Admin/Commands
public async Task<IActionResult> Index() => View(await _context.Commands.ToListAsync());
// GET: Admin/Commands/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
Command command = await _context.Commands.FirstOrDefaultAsync(m => m.Id == id);
if(command == null)
{
return NotFound();
}
return View(command);
}
// GET: Admin/Commands/Create
public IActionResult Create() => View();
// POST: Admin/Commands/Create
// 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> Create([Bind("Id,Name,Count")] Command command)
{
if(ModelState.IsValid)
{
_context.Add(command);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(command);
}
// GET: Admin/Commands/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
Command command = await _context.Commands.FindAsync(id);
if(command == null)
{
return NotFound();
}
return View(command);
}
// POST: Admin/Commands/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")] Command command)
{
if(id != command.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(command);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!CommandExists(command.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(command);
}
// GET: Admin/Commands/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
Command command = await _context.Commands.FirstOrDefaultAsync(m => m.Id == id);
if(command == null)
{
return NotFound();
}
return View(command);
}
// POST: Admin/Commands/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Command command = await _context.Commands.FindAsync(id);
_context.Commands.Remove(command);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool CommandExists(int id) => _context.Commands.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,144 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class CompactDiscOffsetsController : Controller
{
readonly DicServerContext _context;
public CompactDiscOffsetsController(DicServerContext context) => _context = context;
// GET: Admin/CompactDiscOffsets
public async Task<IActionResult> Index() => View(await _context.CdOffsets.ToListAsync());
// GET: Admin/CompactDiscOffsets/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
CompactDiscOffset compactDiscOffset = await _context.CdOffsets.FirstOrDefaultAsync(m => m.Id == id);
if(compactDiscOffset == null)
{
return NotFound();
}
return View(compactDiscOffset);
}
// GET: Admin/CompactDiscOffsets/Create
public IActionResult Create() => View();
// POST: Admin/CompactDiscOffsets/Create
// 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> Create(
[Bind("Id,AddedWhen,ModifiedWhen,Manufacturer,Model,Offset,Submissions,Agreement")]
CompactDiscOffset compactDiscOffset)
{
if(ModelState.IsValid)
{
_context.Add(compactDiscOffset);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(compactDiscOffset);
}
// GET: Admin/CompactDiscOffsets/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
CompactDiscOffset compactDiscOffset = await _context.CdOffsets.FindAsync(id);
if(compactDiscOffset == null)
{
return NotFound();
}
return View(compactDiscOffset);
}
// POST: Admin/CompactDiscOffsets/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,AddedWhen,ModifiedWhen,Manufacturer,Model,Offset,Submissions,Agreement")]
CompactDiscOffset compactDiscOffset)
{
if(id != compactDiscOffset.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(compactDiscOffset);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!CompactDiscOffsetExists(compactDiscOffset.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(compactDiscOffset);
}
// GET: Admin/CompactDiscOffsets/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
CompactDiscOffset compactDiscOffset = await _context.CdOffsets.FirstOrDefaultAsync(m => m.Id == id);
if(compactDiscOffset == null)
{
return NotFound();
}
return View(compactDiscOffset);
}
// POST: Admin/CompactDiscOffsets/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
CompactDiscOffset compactDiscOffset = await _context.CdOffsets.FindAsync(id);
_context.CdOffsets.Remove(compactDiscOffset);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool CompactDiscOffsetExists(int id) => _context.CdOffsets.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,142 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class DeviceStatsController : Controller
{
readonly DicServerContext _context;
public DeviceStatsController(DicServerContext context) => _context = context;
// GET: Admin/DeviceStats
public async Task<IActionResult> Index() => View(await _context.DeviceStats.ToListAsync());
// GET: Admin/DeviceStats/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
DeviceStat deviceStat = await _context.DeviceStats.FirstOrDefaultAsync(m => m.Id == id);
if(deviceStat == null)
{
return NotFound();
}
return View(deviceStat);
}
// GET: Admin/DeviceStats/Create
public IActionResult Create() => View();
// POST: Admin/DeviceStats/Create
// 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> Create([Bind("Id,Manufacturer,Model,Revision,Bus")]
DeviceStat deviceStat)
{
if(ModelState.IsValid)
{
_context.Add(deviceStat);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(deviceStat);
}
// GET: Admin/DeviceStats/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
DeviceStat deviceStat = await _context.DeviceStats.FindAsync(id);
if(deviceStat == null)
{
return NotFound();
}
return View(deviceStat);
}
// POST: Admin/DeviceStats/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,Manufacturer,Model,Revision,Bus")]
DeviceStat deviceStat)
{
if(id != deviceStat.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(deviceStat);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!DeviceStatExists(deviceStat.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(deviceStat);
}
// GET: Admin/DeviceStats/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
DeviceStat deviceStat = await _context.DeviceStats.FirstOrDefaultAsync(m => m.Id == id);
if(deviceStat == null)
{
return NotFound();
}
return View(deviceStat);
}
// POST: Admin/DeviceStats/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
DeviceStat deviceStat = await _context.DeviceStats.FindAsync(id);
_context.DeviceStats.Remove(deviceStat);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool DeviceStatExists(int id) => _context.DeviceStats.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,145 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class DevicesController : Controller
{
readonly DicServerContext _context;
public DevicesController(DicServerContext context) => _context = context;
// GET: Admin/Devices
public async Task<IActionResult> Index() => View(await _context.Devices.ToListAsync());
// GET: Admin/Devices/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
Device device = await _context.Devices.FirstOrDefaultAsync(m => m.Id == id);
if(device == null)
{
return NotFound();
}
return View(device);
}
// GET: Admin/Devices/Create
public IActionResult Create() => View();
// POST: Admin/Devices/Create
// 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> Create(
[Bind("AddedWhen,ModifiedWhen,OptimalMultipleSectorsRead,Id,CompactFlash,Manufacturer,Model,Revision,Type")]
Device device)
{
if(ModelState.IsValid)
{
_context.Add(device);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(device);
}
// GET: Admin/Devices/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
Device device = await _context.Devices.FindAsync(id);
if(device == null)
{
return NotFound();
}
return View(device);
}
// POST: Admin/Devices/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(
"AddedWhen,ModifiedWhen,OptimalMultipleSectorsRead,Id,CompactFlash,Manufacturer,Model,Revision,Type")]
Device device)
{
if(id != device.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(device);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!DeviceExists(device.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(device);
}
// GET: Admin/Devices/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
Device device = await _context.Devices.FirstOrDefaultAsync(m => m.Id == id);
if(device == null)
{
return NotFound();
}
return View(device);
}
// POST: Admin/Devices/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Device device = await _context.Devices.FindAsync(id);
_context.Devices.Remove(device);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool DeviceExists(int id) => _context.Devices.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,140 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class FilesystemsController : Controller
{
readonly DicServerContext _context;
public FilesystemsController(DicServerContext context) => _context = context;
// GET: Admin/Filesystems
public async Task<IActionResult> Index() => View(await _context.Filesystems.ToListAsync());
// GET: Admin/Filesystems/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
Filesystem filesystem = await _context.Filesystems.FirstOrDefaultAsync(m => m.Id == id);
if(filesystem == null)
{
return NotFound();
}
return View(filesystem);
}
// GET: Admin/Filesystems/Create
public IActionResult Create() => View();
// POST: Admin/Filesystems/Create
// 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> Create([Bind("Id,Name,Count")] Filesystem filesystem)
{
if(ModelState.IsValid)
{
_context.Add(filesystem);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(filesystem);
}
// GET: Admin/Filesystems/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
Filesystem filesystem = await _context.Filesystems.FindAsync(id);
if(filesystem == null)
{
return NotFound();
}
return View(filesystem);
}
// POST: Admin/Filesystems/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")] Filesystem filesystem)
{
if(id != filesystem.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(filesystem);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!FilesystemExists(filesystem.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(filesystem);
}
// GET: Admin/Filesystems/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
Filesystem filesystem = await _context.Filesystems.FirstOrDefaultAsync(m => m.Id == id);
if(filesystem == null)
{
return NotFound();
}
return View(filesystem);
}
// POST: Admin/Filesystems/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Filesystem filesystem = await _context.Filesystems.FindAsync(id);
_context.Filesystems.Remove(filesystem);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool FilesystemExists(int id) => _context.Filesystems.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,140 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class FiltersController : Controller
{
readonly DicServerContext _context;
public FiltersController(DicServerContext context) => _context = context;
// GET: Admin/Filters
public async Task<IActionResult> Index() => View(await _context.Filters.ToListAsync());
// GET: Admin/Filters/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
Filter filter = await _context.Filters.FirstOrDefaultAsync(m => m.Id == id);
if(filter == null)
{
return NotFound();
}
return View(filter);
}
// GET: Admin/Filters/Create
public IActionResult Create() => View();
// POST: Admin/Filters/Create
// 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> Create([Bind("Id,Name,Count")] Filter filter)
{
if(ModelState.IsValid)
{
_context.Add(filter);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(filter);
}
// GET: Admin/Filters/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
Filter filter = await _context.Filters.FindAsync(id);
if(filter == null)
{
return NotFound();
}
return View(filter);
}
// POST: Admin/Filters/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")] Filter filter)
{
if(id != filter.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(filter);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!FilterExists(filter.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(filter);
}
// GET: Admin/Filters/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
Filter filter = await _context.Filters.FirstOrDefaultAsync(m => m.Id == id);
if(filter == null)
{
return NotFound();
}
return View(filter);
}
// POST: Admin/Filters/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Filter filter = await _context.Filters.FindAsync(id);
_context.Filters.Remove(filter);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool FilterExists(int id) => _context.Filters.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,140 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class MediaFormatsController : Controller
{
readonly DicServerContext _context;
public MediaFormatsController(DicServerContext context) => _context = context;
// 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/Create
public IActionResult Create() => View();
// POST: Admin/MediaFormats/Create
// 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> Create([Bind("Id,Name,Count")] MediaFormat mediaFormat)
{
if(ModelState.IsValid)
{
_context.Add(mediaFormat);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
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)
{
if(id == null)
{
return NotFound();
}
MediaFormat mediaFormat = await _context.MediaFormats.FirstOrDefaultAsync(m => m.Id == id);
if(mediaFormat == null)
{
return NotFound();
}
return View(mediaFormat);
}
// POST: Admin/MediaFormats/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
MediaFormat mediaFormat = await _context.MediaFormats.FindAsync(id);
_context.MediaFormats.Remove(mediaFormat);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool MediaFormatExists(int id) => _context.MediaFormats.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,140 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class MediasController : Controller
{
readonly DicServerContext _context;
public MediasController(DicServerContext context) => _context = context;
// GET: Admin/Medias
public async Task<IActionResult> Index() => View(await _context.Medias.ToListAsync());
// GET: Admin/Medias/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
Media media = await _context.Medias.FirstOrDefaultAsync(m => m.Id == id);
if(media == null)
{
return NotFound();
}
return View(media);
}
// GET: Admin/Medias/Create
public IActionResult Create() => View();
// POST: Admin/Medias/Create
// 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> Create([Bind("Id,Type,Real,Count")] Media media)
{
if(ModelState.IsValid)
{
_context.Add(media);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(media);
}
// GET: Admin/Medias/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
Media media = await _context.Medias.FindAsync(id);
if(media == null)
{
return NotFound();
}
return View(media);
}
// POST: Admin/Medias/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,Type,Real,Count")] Media media)
{
if(id != media.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(media);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!MediaExists(media.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(media);
}
// GET: Admin/Medias/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
Media media = await _context.Medias.FirstOrDefaultAsync(m => m.Id == id);
if(media == null)
{
return NotFound();
}
return View(media);
}
// POST: Admin/Medias/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Media media = await _context.Medias.FindAsync(id);
_context.Medias.Remove(media);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool MediaExists(int id) => _context.Medias.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,140 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class OperatingSystemsController : Controller
{
readonly DicServerContext _context;
public OperatingSystemsController(DicServerContext context) => _context = context;
// GET: Admin/OperatingSystems
public async Task<IActionResult> Index() => View(await _context.OperatingSystems.ToListAsync());
// GET: Admin/OperatingSystems/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
OperatingSystem operatingSystem = await _context.OperatingSystems.FirstOrDefaultAsync(m => m.Id == id);
if(operatingSystem == null)
{
return NotFound();
}
return View(operatingSystem);
}
// GET: Admin/OperatingSystems/Create
public IActionResult Create() => View();
// POST: Admin/OperatingSystems/Create
// 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> Create([Bind("Id,Name,Version,Count")] OperatingSystem operatingSystem)
{
if(ModelState.IsValid)
{
_context.Add(operatingSystem);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(operatingSystem);
}
// GET: Admin/OperatingSystems/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
OperatingSystem operatingSystem = await _context.OperatingSystems.FindAsync(id);
if(operatingSystem == null)
{
return NotFound();
}
return View(operatingSystem);
}
// POST: Admin/OperatingSystems/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,Version,Count")] OperatingSystem operatingSystem)
{
if(id != operatingSystem.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(operatingSystem);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!OperatingSystemExists(operatingSystem.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(operatingSystem);
}
// GET: Admin/OperatingSystems/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
OperatingSystem operatingSystem = await _context.OperatingSystems.FirstOrDefaultAsync(m => m.Id == id);
if(operatingSystem == null)
{
return NotFound();
}
return View(operatingSystem);
}
// POST: Admin/OperatingSystems/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
OperatingSystem operatingSystem = await _context.OperatingSystems.FindAsync(id);
_context.OperatingSystems.Remove(operatingSystem);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool OperatingSystemExists(int id) => _context.OperatingSystems.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,140 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class PartitionsController : Controller
{
readonly DicServerContext _context;
public PartitionsController(DicServerContext context) => _context = context;
// GET: Admin/Partitions
public async Task<IActionResult> Index() => View(await _context.Partitions.ToListAsync());
// GET: Admin/Partitions/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
Partition partition = await _context.Partitions.FirstOrDefaultAsync(m => m.Id == id);
if(partition == null)
{
return NotFound();
}
return View(partition);
}
// GET: Admin/Partitions/Create
public IActionResult Create() => View();
// POST: Admin/Partitions/Create
// 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> Create([Bind("Id,Name,Count")] Partition partition)
{
if(ModelState.IsValid)
{
_context.Add(partition);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(partition);
}
// GET: Admin/Partitions/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
Partition partition = await _context.Partitions.FindAsync(id);
if(partition == null)
{
return NotFound();
}
return View(partition);
}
// POST: Admin/Partitions/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")] Partition partition)
{
if(id != partition.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(partition);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!PartitionExists(partition.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(partition);
}
// GET: Admin/Partitions/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
Partition partition = await _context.Partitions.FirstOrDefaultAsync(m => m.Id == id);
if(partition == null)
{
return NotFound();
}
return View(partition);
}
// POST: Admin/Partitions/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Partition partition = await _context.Partitions.FindAsync(id);
_context.Partitions.Remove(partition);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool PartitionExists(int id) => _context.Partitions.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,143 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class ReportsController : Controller
{
readonly DicServerContext _context;
public ReportsController(DicServerContext context) => _context = context;
// GET: Admin/Reports
public async Task<IActionResult> Index() => View(await _context.Reports.ToListAsync());
// GET: Admin/Reports/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
UploadedReport uploadedReport = await _context.Reports.FirstOrDefaultAsync(m => m.Id == id);
if(uploadedReport == null)
{
return NotFound();
}
return View(uploadedReport);
}
// GET: Admin/Reports/Create
public IActionResult Create() => View();
// POST: Admin/Reports/Create
// 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> Create([Bind("UploadedWhen,Id,CompactFlash,Manufacturer,Model,Revision,Type")]
UploadedReport uploadedReport)
{
if(ModelState.IsValid)
{
_context.Add(uploadedReport);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(uploadedReport);
}
// GET: Admin/Reports/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
UploadedReport uploadedReport = await _context.Reports.FindAsync(id);
if(uploadedReport == null)
{
return NotFound();
}
return View(uploadedReport);
}
// POST: Admin/Reports/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("UploadedWhen,Id,CompactFlash,Manufacturer,Model,Revision,Type")]
UploadedReport uploadedReport)
{
if(id != uploadedReport.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(uploadedReport);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!UploadedReportExists(uploadedReport.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(uploadedReport);
}
// GET: Admin/Reports/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
UploadedReport uploadedReport = await _context.Reports.FirstOrDefaultAsync(m => m.Id == id);
if(uploadedReport == null)
{
return NotFound();
}
return View(uploadedReport);
}
// POST: Admin/Reports/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
UploadedReport uploadedReport = await _context.Reports.FindAsync(id);
_context.Reports.Remove(uploadedReport);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool UploadedReportExists(int id) => _context.Reports.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,162 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class UsbProductsController : Controller
{
readonly DicServerContext _context;
public UsbProductsController(DicServerContext context) => _context = context;
// GET: Admin/UsbProducts
public async Task<IActionResult> Index()
{
IIncludableQueryable<UsbProduct, UsbVendor> dicServerContext = _context.UsbProducts.Include(u => u.Vendor);
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/Create
public IActionResult Create()
{
ViewData["VendorId"] = new SelectList(_context.UsbVendors, "Id", "Id");
return View();
}
// POST: Admin/UsbProducts/Create
// 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> Create([Bind("Id,ProductId,Product,AddedWhen,ModifiedWhen,VendorId")]
UsbProduct usbProduct)
{
if(ModelState.IsValid)
{
_context.Add(usbProduct);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["VendorId"] = new SelectList(_context.UsbVendors, "Id", "Id", usbProduct.VendorId);
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);
}
}

View File

@@ -0,0 +1,142 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class UsbVendorsController : Controller
{
readonly DicServerContext _context;
public UsbVendorsController(DicServerContext context) => _context = context;
// GET: Admin/UsbVendors
public async Task<IActionResult> Index() => View(await _context.UsbVendors.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(usbVendor);
}
// GET: Admin/UsbVendors/Create
public IActionResult Create() => View();
// POST: Admin/UsbVendors/Create
// 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> Create([Bind("Id,VendorId,Vendor,AddedWhen,ModifiedWhen")]
UsbVendor usbVendor)
{
if(ModelState.IsValid)
{
_context.Add(usbVendor);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(usbVendor);
}
// GET: Admin/UsbVendors/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
UsbVendor usbVendor = await _context.UsbVendors.FindAsync(id);
if(usbVendor == null)
{
return NotFound();
}
return View(usbVendor);
}
// POST: Admin/UsbVendors/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,VendorId,Vendor,AddedWhen,ModifiedWhen")]
UsbVendor usbVendor)
{
if(id != usbVendor.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(usbVendor);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!UsbVendorExists(usbVendor.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(usbVendor);
}
// GET: Admin/UsbVendors/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
UsbVendor usbVendor = await _context.UsbVendors.FirstOrDefaultAsync(m => m.Id == id);
if(usbVendor == null)
{
return NotFound();
}
return View(usbVendor);
}
// POST: Admin/UsbVendors/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
UsbVendor usbVendor = await _context.UsbVendors.FindAsync(id);
_context.UsbVendors.Remove(usbVendor);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool UsbVendorExists(int id) => _context.UsbVendors.Any(e => e.Id == id);
}
}

View File

@@ -0,0 +1,140 @@
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace DiscImageChef.Server.Areas.Admin.Controllers
{
[Area("Admin")]
public class VersionsController : Controller
{
readonly DicServerContext _context;
public VersionsController(DicServerContext context) => _context = context;
// GET: Admin/Versions
public async Task<IActionResult> Index() => View(await _context.Versions.ToListAsync());
// GET: Admin/Versions/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
Version version = await _context.Versions.FirstOrDefaultAsync(m => m.Id == id);
if(version == null)
{
return NotFound();
}
return View(version);
}
// GET: Admin/Versions/Create
public IActionResult Create() => View();
// POST: Admin/Versions/Create
// 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> Create([Bind("Id,Value,Count")] Version version)
{
if(ModelState.IsValid)
{
_context.Add(version);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(version);
}
// GET: Admin/Versions/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
Version version = await _context.Versions.FindAsync(id);
if(version == null)
{
return NotFound();
}
return View(version);
}
// POST: Admin/Versions/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,Value,Count")] Version version)
{
if(id != version.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(version);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!VersionExists(version.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(version);
}
// GET: Admin/Versions/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
Version version = await _context.Versions.FirstOrDefaultAsync(m => m.Id == id);
if(version == null)
{
return NotFound();
}
return View(version);
}
// POST: Admin/Versions/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Version version = await _context.Versions.FindAsync(id);
_context.Versions.Remove(version);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool VersionExists(int id) => _context.Versions.Any(e => e.Id == id);
}
}