Update: Forcibly Close Job

Allow jobs to be closed if procedures cannot be followed.
This commit is contained in:
Gary Sharp
2013-03-19 15:42:16 +11:00
parent 79085614d3
commit e422bf163d
13 changed files with 373 additions and 84 deletions
@@ -1555,6 +1555,29 @@ namespace Disco.Web.Areas.API.Controllers
}
return Json("Invalid Job Number", JsonRequestBehavior.AllowGet);
}
public virtual ActionResult ForceClose(int id, string Reason, Nullable<bool> redirect = null)
{
var j = dbContext.Jobs.Find(id);
dbContext.Configuration.LazyLoadingEnabled = true;
if (j != null)
{
if (j.CanForceClose())
{
j.OnForceClose(dbContext, DiscoApplication.CurrentUser, Reason);
dbContext.SaveChanges();
if (redirect.HasValue && redirect.Value)
return RedirectToAction(MVC.Job.Show(id));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
else
{
return Json("Job's state doesn't allow this action", JsonRequestBehavior.AllowGet);
}
}
return Json("Invalid Job Number", JsonRequestBehavior.AllowGet);
}
public virtual ActionResult Close(int id, bool redirect)
{
var j = dbContext.Jobs.Find(id);