예제 #1
0
        public static string SerializeError(ModelStateDictionary modelState, ApiError apiError)
        {
            var errors = modelState.Values.SelectMany(e => e.Errors);

            foreach (var error in errors)
            {
                apiError.AddMessage(error.ErrorMessage);
            }

            string json = JsonConvert.SerializeObject(apiError, Formatting.Indented);

            return(json);
        }