示例#1
0
        public static object CreateErrorResponse(string errorCode, string errorMessage, IEnumerable <ValidationErrorField> validationErrors)
        {
            var responseStatus = ResponseStatusUtils.CreateResponseStatus(errorCode, errorMessage, validationErrors);
            var responseDto    = CreateResponseDto(null, responseStatus);

            return(new HttpError(responseDto, HttpStatusCode.BadRequest, errorCode, errorMessage));
        }
        public ResponseStatus ToResponseStatus()
        {
            var errors = Errors.ConvertAll(x =>
                                           new ValidationErrorField(x.ErrorCode, x.PropertyName, x.ErrorMessage));

            var responseStatus = ResponseStatusUtils.CreateResponseStatus(typeof(ValidationException).Name, Message, errors);

            return(responseStatus);
        }
示例#3
0
        public ResponseStatus ToResponseStatus()
        {
            var errors = Errors.Map(x =>
                                    new ValidationErrorField(x.ErrorCode, x.PropertyName, x.ErrorMessage)
            {
                Meta = x.CustomState as Dictionary <string, string> ?? x.FormattedMessagePlaceholderValues.ToStringDictionary()
            });

            var responseStatus = ResponseStatusUtils.CreateResponseStatus(typeof(ValidationException).GetOperationName(), Message, errors);

            return(responseStatus);
        }
示例#4
0
        public ResponseStatus ToResponseStatus()
        {
            var errors = Errors.Map(x =>
                                    new ValidationErrorField(x.ErrorCode, x.PropertyName, x.ErrorMessage)
            {
                Meta = x.CustomStateAsDictionary()
            });

            var responseStatus = ResponseStatusUtils.CreateResponseStatus(typeof(ValidationException).GetOperationName(), Message, errors);

            return(responseStatus);
        }
示例#5
0
 public ResponseStatus ToResponseStatus()
 {
     return(ResponseStatusUtils.CreateResponseStatus(ErrorCode, Message, Violations));
 }
 public ResponseStatus ToResponseStatus() =>
 ResponseStatusUtils.CreateResponseStatus(ErrorCode, Message, Violations);
示例#7
0
 public static ResponseStatus CreateResponseStatus(string errorCode, string errorMessage)
 {
     return(ResponseStatusUtils.CreateResponseStatus(errorCode, errorMessage, null));
 }
示例#8
0
        public static ResponseStatus CreateResponseStatus(string errorCode)
        {
            var errorMessage = errorCode.SplitCamelCase();

            return(ResponseStatusUtils.CreateResponseStatus(errorCode, errorMessage, null));
        }
示例#9
0
 public static ResponseStatus ToResponseStatus(this ValidationErrorResult validationResult)
 {
     return(validationResult.IsValid
         ? CreateSuccessResponse(validationResult.SuccessMessage)
         : ResponseStatusUtils.CreateResponseStatus(validationResult.ErrorCode, validationResult.ErrorMessage, validationResult.Errors));
 }
示例#10
0
 public static ResponseStatus ToResponseStatus(this ValidationError validationException)
 {
     return(ResponseStatusUtils.CreateResponseStatus(validationException.ErrorCode, validationException.Message, validationException.Violations));
 }