Implement delete owned machine admin page.

This commit is contained in:
2019-05-30 01:07:46 +01:00
parent 9447da14c3
commit f61f7819b8
3 changed files with 62 additions and 34 deletions

View File

@@ -173,8 +173,24 @@ namespace cicm_web.Areas.Admin.Controllers
{
if(id == null) return NotFound();
OwnedMachine ownedMachine = await _context.OwnedMachines
.Include(o => o.Machine).FirstOrDefaultAsync(m => m.Id == id);
OwnedMachineViewModel ownedMachine = await _context.OwnedMachines
.Include(o => o.Machine)
.Select(o => new OwnedMachineViewModel
{
AcquisitionDate = o.AcquisitionDate,
Boxed = o.Boxed,
LastStatusDate = o.LastStatusDate,
LostDate = o.LostDate,
Machine =
$"{o.Machine.Company.Name} {o.Machine.Name}",
Manuals = o.Manuals,
SerialNumber = o.SerialNumber,
SerialNumberVisible =
o.SerialNumberVisible,
Status = o.Status,
User = o.User.UserName,
Id = o.Id
}).FirstOrDefaultAsync(m => m.Id == id);
if(ownedMachine == null) return NotFound();
return View(ownedMachine);