public static ActionResult AsSuccess(params string[] infos) { var result = new ActionResult(true); foreach (var info in infos) { result.WithInfo(info); } return result; }
public static ActionResult AsError(params string[] errors) { var result = new ActionResult(true); foreach (var error in errors) { result.WithError(error); } return result; }
public static Response AsJsonErrorOnValidation(this IResponseFormatter responseFormatter, IEnumerable<ModelValidationError> errors) { var actionResult = new ActionResult(false); foreach (var error in errors) { foreach (var member in error.MemberNames) { actionResult.Errors.Add(error.GetMessage(member)); } } return responseFormatter.AsJson(actionResult); }
public static ActionResult AsErrorOnValidation(ModelValidationResult validationResult) { var result = new ActionResult(false); foreach (var error in validationResult.Errors) { foreach (var member in error.MemberNames) { result.WithError(error.GetMessage(member)); } } return result; }