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.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
|
|
||||||
namespace DiscImageChef.Server.Areas.Admin.Controllers
|
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) =>
|
public IActionResult Find(int id, string manufacturer, string model, string bus) =>
|
||||||
throw new NotImplementedException();
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.CommonTypes.Metadata;
|
using DiscImageChef.CommonTypes.Metadata;
|
||||||
|
|
||||||
namespace DiscImageChef.Server.Models
|
namespace DiscImageChef.Server.Models
|
||||||
@@ -59,11 +60,41 @@ namespace DiscImageChef.Server.Models
|
|||||||
Type = report.Type;
|
Type = report.Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Device(int? ataId, int? atapiId, int? firewireId, int? multimediacardId, int? pcmciaId,
|
||||||
|
int? securedigitalId, int? scsiId, int? usbId, DateTime uploadedWhen, string manufacturer,
|
||||||
|
string model, string revision, bool compactFlash, DeviceType type)
|
||||||
|
{
|
||||||
|
ATAId = ataId;
|
||||||
|
ATAPIId = atapiId;
|
||||||
|
FireWireId = firewireId;
|
||||||
|
MultiMediaCardId = multimediacardId;
|
||||||
|
PCMCIAId = pcmciaId;
|
||||||
|
SecureDigitalId = securedigitalId;
|
||||||
|
SCSIId = scsiId;
|
||||||
|
USBId = usbId;
|
||||||
|
AddedWhen = uploadedWhen;
|
||||||
|
ModifiedWhen = DateTime.UtcNow;
|
||||||
|
Manufacturer = manufacturer;
|
||||||
|
Model = model;
|
||||||
|
Revision = revision;
|
||||||
|
CompactFlash = compactFlash;
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime AddedWhen { get; set; }
|
public DateTime AddedWhen { get; set; }
|
||||||
public DateTime? ModifiedWhen { get; set; }
|
public DateTime? ModifiedWhen { get; set; }
|
||||||
public virtual CompactDiscOffset CdOffset { get; set; }
|
public virtual CompactDiscOffset CdOffset { get; set; }
|
||||||
|
|
||||||
[DefaultValue(0)]
|
[DefaultValue(0)]
|
||||||
public int OptimalMultipleSectorsRead { get; set; }
|
public int OptimalMultipleSectorsRead { get; set; }
|
||||||
|
|
||||||
|
public int? ATAId { get; set; }
|
||||||
|
public int? ATAPIId { get; set; }
|
||||||
|
public int? FireWireId { get; set; }
|
||||||
|
public int? MultiMediaCardId { get; set; }
|
||||||
|
public int? PCMCIAId { get; set; }
|
||||||
|
public int? SecureDigitalId { get; set; }
|
||||||
|
public int? SCSIId { get; set; }
|
||||||
|
public int? USBId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,5 +58,14 @@ namespace DiscImageChef.Server.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DateTime UploadedWhen { get; set; }
|
public DateTime UploadedWhen { get; set; }
|
||||||
|
|
||||||
|
public int? ATAId { get; set; }
|
||||||
|
public int? ATAPIId { get; set; }
|
||||||
|
public int? FireWireId { get; set; }
|
||||||
|
public int? MultiMediaCardId { get; set; }
|
||||||
|
public int? PCMCIAId { get; set; }
|
||||||
|
public int? SecureDigitalId { get; set; }
|
||||||
|
public int? SCSIId { get; set; }
|
||||||
|
public int? USBId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user