Add ResultsAdmin, delete action

This commit is contained in:
2016-05-20 22:47:28 -04:00
parent cff6a0d96f
commit 790e2494e3
6 changed files with 182 additions and 1 deletions
+42
View File
@@ -0,0 +1,42 @@
using System;
using System.Linq;
using System.Web.Mvc;
using LeafWeb.Web.Attributes;
using LeafWeb.Web.ViewModels.LeafInput;
using LeafWeb.Web.ViewModels.Results;
using LeafWeb.Web.ViewModels.ResultsAdmin;
namespace LeafWeb.Web.Controllers
{
public class ResultsAdminController : ControllerBase
{
public ActionResult Index()
{
var viewModel =
DataService.GetLeafInputs()
.OrderByDescending(f => f.Id)
.ToList()
.Select(leafInput => new ResultStatusViewModel(leafInput));
return View(viewModel);
}
public ActionResult Delete(int id)
{
var leafInput = DataService.GetLeafInput(id);
var viewModel = new LeafInputViewModel(leafInput);
return View(viewModel);
}
[HttpPost, ActionName("Delete")]
[ActionLog]
public ActionResult DeleteConfirmed(int id)
{
// TODO: don't allow currently running LeafInput to be deleted
var leafInput = DataService.GetLeafInput(id);
DataService.DeleteLeafInput(leafInput);
SetStatusMessage($"LeafInput '{leafInput.Identifier}' deleted");
return RedirectToAction("Index");
}
}
}