Details and queue management

This commit is contained in:
2017-01-06 08:43:22 -05:00
parent d14e40a36b
commit 42ac27e16f
24 changed files with 260 additions and 51 deletions
@@ -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"
};
}
}
}