mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Add option to consolidate one ATA from another.
This commit is contained in:
@@ -149,6 +149,52 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
public IActionResult ConsolidateWithIds(int masterId, int slaveId)
|
||||
{
|
||||
if(_context.Ata.Count(m => m.Id == masterId) == 0)
|
||||
return RedirectToAction(nameof(Compare), new
|
||||
{
|
||||
id = masterId, rightId = slaveId
|
||||
});
|
||||
|
||||
if(_context.Ata.Count(m => m.Id == slaveId) == 0)
|
||||
return RedirectToAction(nameof(Compare), new
|
||||
{
|
||||
id = masterId, rightId = slaveId
|
||||
});
|
||||
|
||||
foreach(Device ataDevice in _context.Devices.Where(d => d.ATAId == slaveId))
|
||||
{
|
||||
ataDevice.ATAId = masterId;
|
||||
}
|
||||
|
||||
foreach(Device atapiDevice in _context.Devices.Where(d => d.ATAPIId == slaveId))
|
||||
{
|
||||
atapiDevice.ATAPIId = masterId;
|
||||
}
|
||||
|
||||
foreach(UploadedReport ataReport in _context.Reports.Where(d => d.ATAId == slaveId))
|
||||
{
|
||||
ataReport.ATAId = masterId;
|
||||
}
|
||||
|
||||
foreach(UploadedReport atapiReport in _context.Reports.Where(d => d.ATAPIId == slaveId))
|
||||
{
|
||||
atapiReport.ATAPIId = masterId;
|
||||
}
|
||||
|
||||
foreach(TestedMedia testedMedia in _context.TestedMedia.Where(d => d.AtaId == slaveId))
|
||||
{
|
||||
testedMedia.AtaId = masterId;
|
||||
}
|
||||
|
||||
_context.Ata.Remove(_context.Ata.First(d => d.Id == slaveId));
|
||||
|
||||
_context.SaveChanges();
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
public IActionResult Compare(int id, int rightId)
|
||||
{
|
||||
var model = new CompareModel();
|
||||
@@ -213,8 +259,8 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
|
||||
foreach(FieldInfo fieldInfo in leftValue.GetType().GetFields())
|
||||
{
|
||||
object? lv = fieldInfo.GetValue(leftValue);
|
||||
object? rv = fieldInfo.GetValue(rightValue);
|
||||
object lv = fieldInfo.GetValue(leftValue);
|
||||
object rv = fieldInfo.GetValue(rightValue);
|
||||
|
||||
if(fieldInfo.FieldType.IsArray)
|
||||
{
|
||||
|
||||
@@ -79,4 +79,6 @@
|
||||
</table>
|
||||
<a asp-action="Index" class="btn btn-primary">Back to List</a>
|
||||
<a asp-action="Delete" asp-route-id="@Model.LeftId" class="btn btn-danger">Delete ID @Model.LeftId</a>
|
||||
<a asp-action="Delete" asp-route-id="@Model.RightId" class="btn btn-danger">Delete ID @Model.RightId</a>
|
||||
<a asp-action="Delete" asp-route-id="@Model.RightId" class="btn btn-danger">Delete ID @Model.RightId</a>
|
||||
<a asp-action="ConsolidateWithIds" asp-route-masterId="@Model.LeftId" asp-route-slaveId="@Model.RightId" class="btn btn-secondary">Replace all dependencies from ID @Model.RightId with ID @Model.LeftId</a>
|
||||
<a asp-action="ConsolidateWithIds" asp-route-masterId="@Model.RightId" asp-route-slaveId="@Model.LeftId" class="btn btn-secondary">Replace all dependencies from ID @Model.LeftId with ID @Model.RightId</a>
|
||||
@@ -65,7 +65,7 @@ namespace DiscImageChef.Server.Models
|
||||
|
||||
[DefaultValue(0)]
|
||||
public int OptimalMultipleSectorsRead { get; set; }
|
||||
public int ATAId { get; set; }
|
||||
public int ATAPIId { get; set; }
|
||||
public int? ATAId { get; set; }
|
||||
public int? ATAPIId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace DiscImageChef.Server.Models
|
||||
}
|
||||
|
||||
public DateTime UploadedWhen { get; set; }
|
||||
public int ATAId { get; set; }
|
||||
public int ATAPIId { get; set; }
|
||||
public int? ATAId { get; set; }
|
||||
public int? ATAPIId { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user