/// <summary> /// Populate the model state with errors. /// </summary> /// <param name="result"></param> public static void PopulateErrors(EntityActionResult result, ModelStateDictionary modelState, IList <string> stringErrors = null, IErrors errors = null) { if (result.Success || result.Errors == null || !result.Errors.HasAny) { return; } if (modelState["Id"] != null) { modelState.Remove("Id"); } if (result.Errors.HasAny) { modelState.AddErrors(result.Errors); } if (errors != null && errors.Count > 0) { modelState.AddErrors(errors); } }
public static void AddErrors(this IdentityResult result, ModelStateDictionary modelState) => modelState.AddErrors(result);
public static ActionResult WithModelErrors(this ActionResult result, ModelStateDictionary modelState, IEnumerable<Error> errors) { modelState.AddErrors(errors); return result; }
public static ActionResult WithModelErrors(this ActionResult result, ModelStateDictionary modelState, IEnumerable <Error> errors) { modelState.AddErrors(errors); return(result); }