Fix editing uploaded reports.

This commit is contained in:
2019-11-23 18:19:59 +00:00
parent 7e78f57be2
commit 57c3924add
2 changed files with 23 additions and 30 deletions

View File

@@ -60,8 +60,7 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
int id, [Bind("UploadedWhen,Id,CompactFlash,Manufacturer,Model,Revision,Type")]
public async Task<IActionResult> Edit(int id, [Bind("Id,CompactFlash,Manufacturer,Model,Revision,Type")]
UploadedReport uploadedReport)
{
if(id != uploadedReport.Id)
@@ -69,8 +68,9 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
return NotFound();
}
if(ModelState.IsValid)
{
if(!ModelState.IsValid)
return View(uploadedReport);
try
{
_context.Update(uploadedReport);
@@ -89,9 +89,6 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
return RedirectToAction(nameof(Index));
}
return View(uploadedReport);
}
// GET: Admin/Reports/Delete/5
public async Task<IActionResult> Delete(int? id)
{

View File

@@ -1,26 +1,17 @@
@using DiscImageChef.CommonTypes.Enums
@model UploadedReport
@{
ViewData["Title"] = "Edit";
}
<h1>Edit</h1>
<h4>UploadedReport</h4>
<h4>Uploaded report</h4>
<hr />
<div class="row">
<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="UploadedWhen" class="control-label"></label>
<input asp-for="UploadedWhen" class="form-control" />
<span asp-validation-for="UploadedWhen" 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" />
@@ -36,9 +27,14 @@
<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="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">