Пример #1
0
        public IActionResult Error(string message = default(string), string internalMessage = default(string), string data = default(string), int code = 500)
        {
            var rv = new MVReturn
            {
                Success         = false,
                Message         = message,
                InternalMessage = internalMessage,
                Data            = data,
                Code            = code
            };

            if (rv.Code == 500)
            {
                return(StatusCode(500, rv));
            }

            else if (rv.Code == 401)
            {
                return(Unauthorized());
            }

            else if (rv.Code == 403)
            {
                return(Forbid());
            }

            else if (rv.Code == 404)
            {
                return(NotFound(rv));
            }

            return(BadRequest(rv));
        }
Пример #2
0
        public IActionResult Error(string message = default(string), string internalMessage = default(string), object data = default(object), int code = 400, List <MVReturnError> errorMessages = null)
        {
            var rv = new MVReturn()
            {
                Success         = false,
                Message         = message,
                InternalMessage = internalMessage,
                Data            = data,
                Code            = code
            };

            if (rv.Code == 500)
            {
                return(StatusCode(500, rv));
            }
            if (rv.Code == 401)
            {
                return(Unauthorized());
            }
            if (rv.Code == 403)
            {
                return(Forbid());
            }

            return(BadRequest(rv));
        }