public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string             message    = "";
            var                viewResult = new JsonResult();
            ValidationResponse response   = new ValidationResponse();

            IDictionary <string, object> parametersDictionary = filterContext.ActionParameters;
            var modelToValidate = (ViewModel)parametersDictionary.First().Value;

            ILMSValidator validator = ComponetContext.Resolve <ILMSValidator>();

            message = modelToValidate.Validate(validator);
            if (!string.IsNullOrEmpty(message))
            {
                response.Success = false;
                response.Message = "Save operation failed! " + message;
            }
            else
            {
                response.Success = true;
                response.Message = "Save operation finished!";
            }

            viewResult.Data = response;

            filterContext.RouteData.Values.Add("validation", viewResult);
            base.OnActionExecuting(filterContext);
        }
示例#2
0
 public override string Validate(ILMSValidator validator)
 {
     return(validator.InvokeValidation(this));
 }
示例#3
0
 public abstract string Validate(ILMSValidator validator);