mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Set edit for device reports.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DiscImageChef.Server.Models;
|
||||
@@ -60,8 +61,7 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost, ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(
|
||||
int id, [Bind(
|
||||
"AddedWhen,ModifiedWhen,OptimalMultipleSectorsRead,Id,CompactFlash,Manufacturer,Model,Revision,Type")]
|
||||
int id, [Bind("OptimalMultipleSectorsRead,Id,CompactFlash,Manufacturer,Model,Revision,Type")]
|
||||
Device device)
|
||||
{
|
||||
if(id != device.Id)
|
||||
@@ -69,27 +69,26 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if(ModelState.IsValid)
|
||||
if(!ModelState.IsValid)
|
||||
return View(device);
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
device.ModifiedWhen = DateTime.UtcNow;
|
||||
_context.Update(device);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
if(!DeviceExists(device.Id))
|
||||
{
|
||||
_context.Update(device);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
if(!DeviceExists(device.Id))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
throw;
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
throw;
|
||||
}
|
||||
|
||||
return View(device);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
// GET: Admin/Devices/Delete/5
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@using DiscImageChef.CommonTypes.Enums
|
||||
@model Device
|
||||
|
||||
@{
|
||||
@@ -39,27 +40,7 @@
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label asp-for="AddedWhen" class="control-label"></label>
|
||||
<input asp-for="AddedWhen" class="form-control" />
|
||||
<span asp-validation-for="AddedWhen" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ModifiedWhen" class="control-label"></label>
|
||||
<input asp-for="ModifiedWhen" class="form-control" />
|
||||
<span asp-validation-for="ModifiedWhen" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="OptimalMultipleSectorsRead" class="control-label"></label>
|
||||
<input asp-for="OptimalMultipleSectorsRead" class="form-control" />
|
||||
<span asp-validation-for="OptimalMultipleSectorsRead" class="text-danger"></span>
|
||||
</div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-check form-group">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="CompactFlash" /> @Html.DisplayNameFor(model => model.CompactFlash)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Manufacturer" class="control-label"></label>
|
||||
<input asp-for="Manufacturer" class="form-control" />
|
||||
@@ -75,9 +56,19 @@
|
||||
<input asp-for="Revision" class="form-control" />
|
||||
<span asp-validation-for="Revision" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-check form-group">
|
||||
<label class="form-check-label">
|
||||
<input class="form-check-input" asp-for="CompactFlash" /> @Html.DisplayNameFor(model => model.CompactFlash)
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="OptimalMultipleSectorsRead" class="control-label"></label>
|
||||
<input asp-for="OptimalMultipleSectorsRead" class="form-control" />
|
||||
<span asp-validation-for="OptimalMultipleSectorsRead" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Type" class="control-label"></label>
|
||||
<select asp-for="Type" class="form-control"></select>
|
||||
<select asp-for="Type" class="form-control" asp-items="Html.GetEnumSelectList<DeviceType>()"></select>
|
||||
<span asp-validation-for="Type" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user