Show similar device and uploaded reports in device report details.

This commit is contained in:
2019-11-23 22:06:53 +00:00
parent 37a2ee0b37
commit ea8fe50ec7
3 changed files with 314 additions and 22 deletions

View File

@@ -28,14 +28,51 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
return NotFound();
}
Device device = await _context.Devices.FirstOrDefaultAsync(m => m.Id == id);
var model = new DeviceDetails
{
Report = await _context.Devices.FirstOrDefaultAsync(m => m.Id == id)
};
if(device == null)
if(model.Report is null)
{
return NotFound();
}
return View(device);
model.ReportAll = _context.
Reports.Where(d => d.Manufacturer == model.Report.Manufacturer &&
d.Model == model.Report.Model &&
d.Revision == model.Report.Revision).
Select(d => d.Id).ToList();
model.ReportButManufacturer = _context.
Reports.Where(d => d.Model == model.Report.Model &&
d.Revision == model.Report.Revision).Select(d => d.Id).
Where(d => model.ReportAll.All(r => r != d)).ToList();
model.SameAll = _context.
Devices.Where(d => d.Manufacturer == model.Report.Manufacturer &&
d.Model == model.Report.Model &&
d.Revision == model.Report.Revision &&
d.Id != id).Select(d => d.Id).ToList();
model.SameButManufacturer = _context.
Devices.Where(d => d.Model == model.Report.Model &&
d.Revision == model.Report.Revision && d.Id != id).
Select(d => d.Id).Where(d => model.SameAll.All(r => r != d)).ToList();
model.StatsAll = _context.DeviceStats.
Where(d => d.Manufacturer == model.Report.Manufacturer &&
d.Model == model.Report.Model &&
d.Revision == model.Report.Revision).
Include(d => d.Report).ToList();
model.StatsButManufacturer = _context.DeviceStats.
Where(d => d.Model == model.Report.Model &&
d.Revision == model.Report.Revision).
Include(d => d.Report).AsEnumerable().
Where(d => model.StatsAll.All(s => s.Id != d.Id)).ToList();
return View(model);
}
// GET: Admin/Devices/Edit/5