Beispiel #1
0
 public MyOkResult()
 {
     _result = new BaseObjectResult
     {
         StatusCode = StatusCodes.Status200OK
     };
 }
 public ErrorResult(params string[] errors)
 {
     _result = new BaseObjectResult
     {
         StatusCode = StatusCodes.Status500InternalServerError,
         Errors = errors.ToList()
     };
 }
Beispiel #3
0
 public MyOkResult(object value, string message = null)
 {
     _result = new BaseObjectResult
     {
         StatusCode = StatusCodes.Status200OK,
         Result     = value,
         Message    = message
     };
 }
        public ModelValidationResult(ModelStateDictionary modelState)
        {
            _result = new BaseObjectResult
            {
                StatusCode = StatusCodes.Status422UnprocessableEntity,

                Errors = modelState.Keys
                         .SelectMany(key => modelState[key].Errors.Select(x => x.ErrorMessage))
                         .ToList()
            };
        }
        public ErrorResult(Exception ex)
        {

            if (ex is WebClientOfTException)
            {
                ObjectResult obj = ((WebClientOfTException)ex).ErrorResult;

                _result = new BaseObjectResult
                {
                    StatusCode = obj.StatusCode,
                    Message = obj.Message,
                    Errors = obj.Errors
                };

                /* _result = new BaseObjectResult
                {
                    StatusCode = StatusCodes.Status500InternalServerError,
                    Errors = ((WebClientOfTException)ex).ErrorResult.Errors
                };*/
            }
            else
            {
                _result = new BaseObjectResult
                {
                    StatusCode = StatusCodes.Status500InternalServerError,
                    Errors = new List<String>()
                };

                //{ String.Concat(ex.Message, " - ", ex.InnerException) }
                Exception loopException = ex;

                while (loopException != null)
                {
                    _result.Errors.Add(loopException.Message);
                    loopException = loopException.InnerException;
                }
            }


        }