Example #1
0
        protected virtual IActionResult BadRequestResult(ModelStateDictionary modelState)
        {
            // ToDo : does this have to be logged ?
            //return new BadRequestObjectResult(modelState);
            var errorMessages = modelState.AllModelStateErrors();
            var message       = string.Join(",", errorMessages.Select(x => x.ErrorMessage));

            return(Content(new AjaxResult {
                state = ResultType.error.ToString(), message = message
            }.ToJson()));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="state"></param>
 /// <param name="status"></param>
 public ModelStateExceptionViewModel(ModelStateDictionary state, ApiResult status = null)
 {
     if (status == null)
     {
         status = new ApiResult(-1404, "数据格式错误");
     }
     this.Status  = status.Status;
     this.Message = status.Message;
     Data         = new ModelStateExceptionDataModel {
         List = state.AllModelStateErrors()
     };
 }