mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Implement promoting an uploaded report to a device report.
This commit is contained in:
@@ -5,6 +5,7 @@ using DiscImageChef.Server.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
|
||||
namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
{
|
||||
@@ -171,5 +172,35 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
|
||||
public IActionResult Find(int id, string manufacturer, string model, string bus) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
public IActionResult Promote(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
UploadedReport uploadedReport = _context.Reports.FirstOrDefault(m => m.Id == id);
|
||||
|
||||
if(uploadedReport == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var device = new Device(uploadedReport.ATAId, uploadedReport.ATAPIId, uploadedReport.FireWireId,
|
||||
uploadedReport.MultiMediaCardId, uploadedReport.PCMCIAId,
|
||||
uploadedReport.SecureDigitalId, uploadedReport.SCSIId, uploadedReport.USBId,
|
||||
uploadedReport.UploadedWhen, uploadedReport.Manufacturer, uploadedReport.Model,
|
||||
uploadedReport.Revision, uploadedReport.CompactFlash, uploadedReport.Type);
|
||||
|
||||
EntityEntry<Device> res = _context.Devices.Add(device);
|
||||
_context.Reports.Remove(uploadedReport);
|
||||
_context.SaveChanges();
|
||||
|
||||
return RedirectToAction(nameof(DevicesController.Details), "Devices", new
|
||||
{
|
||||
id = res.Entity.Id
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user