Пример #1
0
        public APIResponse(IExecuteWrapper <T> executeWrapper)
        {
            if (executeWrapper.IsSuccess)
            {
                StatusCode = (int)HttpStatusCode.OK;
                Data       = executeWrapper?.Result;
                return;
            }

            if (executeWrapper == null || (executeWrapper?.Error != null && !executeWrapper.Error.IsValid && executeWrapper.Error.ValidationErrors != null))
            {
                StatusCode = (int)HttpStatusCode.BadRequest;
                Error      = executeWrapper.Error;
                return;
            }

            if (executeWrapper?.Error != null)
            {
                StatusCode = (int)HttpStatusCode.InternalServerError;
                Error      = executeWrapper?.Error;
            }
        }
Пример #2
0
 public APIResponse(Exception ex)
 {
     StatusCode = (int)HttpStatusCode.InternalServerError;
     Error      = new APIError(ex);
 }
Пример #3
0
 public APIResponse(ApiException ex)
 {
     StatusCode = (int)ex.StatusCode;
     Error      = new APIError(ex);
 }
Пример #4
0
 public APIResponse(BadRequestException ex)
 {
     StatusCode = (int)ex.StatusCode;
     Error      = new APIError(ex?.ValidationResponse);
 }