Exemple #1
0
 private string GetErrorMessages(ModelErrorCollection errors)
 {
     if (errors != null)
     {
         return(string.Join(
                    ", ",
                    errors.Where(error => !string.IsNullOrWhiteSpace(error.ErrorMessage))
                    .Select(error => error.ErrorMessage)) +
                string.Join(
                    ", ",
                    errors.Where(error => error.Exception != null && !string.IsNullOrWhiteSpace(error.Exception.Message))
                    .Select(error => error.Exception.Message)));
     }
     else
     {
         return(string.Empty);
     }
 }
 private IEnumerable <ModelStateError> GetExceptions(string field, ModelErrorCollection modelErrors)
 {
     return(modelErrors
            .Where(p => p.Exception != null)
            .Select(p => new ModelStateError(field, p.Exception.MostInnerMessage())));
 }
 private IEnumerable <ModelStateError> GetMessages(string field, ModelErrorCollection modelErrors)
 {
     return(modelErrors
            .Where(p => !string.IsNullOrWhiteSpace(p.ErrorMessage))
            .Select(p => new ModelStateError(field, p.ErrorMessage)));
 }