Do not allow commands to be deleted, edited or detailed.

This commit is contained in:
2019-11-10 13:54:04 +00:00
parent 338dc7249f
commit 80ed393a19
5 changed files with 0 additions and 281 deletions

View File

@@ -16,106 +16,5 @@ namespace DiscImageChef.Server.Areas.Admin.Controllers
// GET: Admin/Commands
public async Task<IActionResult> Index() => View(await _context.Commands.OrderBy(c => c.Name).ToListAsync());
// GET: Admin/Commands/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null)
{
return NotFound();
}
Command command = await _context.Commands.FirstOrDefaultAsync(m => m.Id == id);
if(command == null)
{
return NotFound();
}
return View(command);
}
// GET: Admin/Commands/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null)
{
return NotFound();
}
Command command = await _context.Commands.FindAsync(id);
if(command == null)
{
return NotFound();
}
return View(command);
}
// POST: Admin/Commands/Edit/5
// 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("Id,Name,Count")] Command command)
{
if(id != command.Id)
{
return NotFound();
}
if(ModelState.IsValid)
{
try
{
_context.Update(command);
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!CommandExists(command.Id))
{
return NotFound();
}
throw;
}
return RedirectToAction(nameof(Index));
}
return View(command);
}
// GET: Admin/Commands/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null)
{
return NotFound();
}
Command command = await _context.Commands.FirstOrDefaultAsync(m => m.Id == id);
if(command == null)
{
return NotFound();
}
return View(command);
}
// POST: Admin/Commands/Delete/5
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Command command = await _context.Commands.FindAsync(id);
_context.Commands.Remove(command);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool CommandExists(int id) => _context.Commands.Any(e => e.Id == id);
}
}

View File

@@ -1,59 +0,0 @@
@model Command
@{
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
ViewBag.Title = "DiscImageChef";
}
@{
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Delete.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : DiscImageChef Server.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/
}
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Command</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Name)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Name)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Count)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Count)
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="Id" />
<a asp-action="Index" class="btn btn-primary">Back to List</a>
<input class="btn btn-danger" type="submit" value="Delete" />
</form>
</div>

View File

@@ -1,57 +0,0 @@
@model Command
@{
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
ViewBag.Title = "DiscImageChef";
}
@{
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Details.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : DiscImageChef Server.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/
}
<div>
<h4>Command</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Name)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Name)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.Count)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Count)
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">Edit</a>
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
</div>

View File

@@ -1,59 +0,0 @@
@model Command
@{
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
ViewBag.Title = "DiscImageChef";
}
@{
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Edit.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : DiscImageChef Server.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/
}
<h4>Command</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="Name" class="control-label"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Count" class="control-label"></label>
<input asp-for="Count" class="form-control" />
<span asp-validation-for="Count" class="text-danger"></span>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" value="Save" />
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
</div>
</form>
</div>
</div>

View File

@@ -55,11 +55,6 @@
<td>
@Html.DisplayFor(modelItem => item.Count)
</td>
<td>
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">Details</a>
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-secondary">Edit</a>
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">Delete</a>
</td>
</tr>
}
</tbody>