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); }
public override string Validate(ILMSValidator validator) { return(validator.InvokeValidation(this)); }
public abstract string Validate(ILMSValidator validator);