예제 #1
0
        /// <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);
            }
        }
예제 #2
0
 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;
 }
예제 #4
0
 public static ActionResult WithModelErrors(this ActionResult result, ModelStateDictionary modelState, IEnumerable <Error> errors)
 {
     modelState.AddErrors(errors);
     return(result);
 }