mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Add possible missing files (I don't trust git move).
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
using Aaru.Server.Old.Database.Models;
|
||||
using DbContext = Aaru.Server.Old.Database.DbContext;
|
||||
|
||||
namespace Aaru.Server.Old.Areas.Admin.Controllers;
|
||||
|
||||
[Area("Admin")]
|
||||
[Authorize]
|
||||
public sealed class CompactDiscOffsetsController : Controller
|
||||
{
|
||||
readonly DbContext _context;
|
||||
|
||||
public CompactDiscOffsetsController(DbContext context) => _context = context;
|
||||
|
||||
// GET: Admin/CompactDiscOffsets
|
||||
public async Task<IActionResult> Index() => View(await _context.CdOffsets.OrderBy(o => o.Manufacturer)
|
||||
.ThenBy(o => o.Model)
|
||||
.ThenBy(o => o.Offset)
|
||||
.ToListAsync());
|
||||
|
||||
// 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,Manufacturer,Model,Offset,Submissions,Agreement")] CompactDiscOffset changedModel)
|
||||
{
|
||||
if(id != changedModel.Id) return NotFound();
|
||||
|
||||
if(!ModelState.IsValid) return View(changedModel);
|
||||
|
||||
CompactDiscOffset model = await _context.CdOffsets.FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if(model is null) return NotFound();
|
||||
|
||||
model.Manufacturer = changedModel.Manufacturer;
|
||||
model.Model = changedModel.Model;
|
||||
model.Offset = changedModel.Offset;
|
||||
model.Submissions = changedModel.Submissions;
|
||||
model.Agreement = changedModel.Agreement;
|
||||
model.ModifiedWhen = DateTime.UtcNow;
|
||||
|
||||
try
|
||||
{
|
||||
_context.Update(model);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
ModelState.AddModelError("Concurrency", "Concurrency error, please report to the administrator.");
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
public IActionResult Update() => throw new NotImplementedException();
|
||||
}
|
||||
Reference in New Issue
Block a user