Details and queue management
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace LeafWeb.WebCms.Controllers
|
||||
{
|
||||
// http://stackoverflow.com/a/9036075/99492
|
||||
public class EnforceTrueAttribute : ValidationAttribute, IClientValidatable
|
||||
{
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
if (value == null) return false;
|
||||
if (value.GetType() != typeof(bool)) throw new InvalidOperationException("can only be used on boolean properties.");
|
||||
return (bool)value;
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
return "The " + name + " field must be checked in order to continue.";
|
||||
}
|
||||
|
||||
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
|
||||
{
|
||||
yield return new ModelClientValidationRule
|
||||
{
|
||||
ErrorMessage =
|
||||
string.IsNullOrEmpty(ErrorMessage)
|
||||
? FormatErrorMessage(metadata.DisplayName)
|
||||
: ErrorMessage,
|
||||
ValidationType = "enforcetrue"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Hangfire;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Utility;
|
||||
using LeafWeb.WebCms.Models;
|
||||
using LeafWeb.WebCms.Services;
|
||||
|
||||
namespace LeafWeb.WebCms.Controllers
|
||||
{
|
||||
@@ -73,23 +75,45 @@ namespace LeafWeb.WebCms.Controllers
|
||||
return new FileContentResult(zip, "application/zip") { FileDownloadName = filename };
|
||||
}
|
||||
|
||||
[ActionLog]
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
var leafInput = DataService.GetLeafInput(id);
|
||||
var viewModel = new LeafInputCreate();
|
||||
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);
|
||||
// don't allow currently running LeafInput to be deleted
|
||||
if (leafInput.IsRunning)
|
||||
{
|
||||
SetStatusMessage($"LeafInput '{leafInput.Identifier}' is currently running!", StatusType.Error);
|
||||
return View(Request.UrlReferrer.ToString());
|
||||
}
|
||||
|
||||
DataService.DeleteLeafInput(leafInput);
|
||||
|
||||
SetStatusMessage($"LeafInput '{leafInput.Identifier}' deleted");
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
[ActionLog]
|
||||
public ActionResult SendUserDownloadLink(int id)
|
||||
{
|
||||
var leafInput = DataService.GetLeafInput(id);
|
||||
if (!leafInput.IsComplete)
|
||||
{
|
||||
SetStatusMessage($"LeafInput '{leafInput.Identifier}' is not complete!", StatusType.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
var leafInputId = leafInput.Id;
|
||||
BackgroundJob.Enqueue<EmailNotificationService>(e => e.SendLeafWebComplete(leafInputId));
|
||||
SetStatusMessage($"LeafInput '{leafInput.Identifier}' download link sent", StatusType.Success);
|
||||
}
|
||||
return View(Request.UrlReferrer.ToString());
|
||||
}
|
||||
|
||||
[ActionLog]
|
||||
public ActionResult SendUserChartLink(int id)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user