Beispiel #1
0
        /// <summary>
        /// 返回成功消息
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns></returns>
        protected virtual ActionResult Success(HttpCodeEnum code)
        {
            TData obj = new TData();

            obj.code = code;
            obj.msg  = code.ParseToEnumDescribe();
            return(Json(obj));
        }
Beispiel #2
0
        /// <summary>
        /// Error
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns></returns>
        protected virtual ActionResult Error(HttpCodeEnum code, string msg = "")
        {
            TData obj = new TData();

            obj.code = code;
            obj.msg  = string.IsNullOrWhiteSpace(msg) ? msg.ParseToEnumDescribe() : msg;
            return(Json(obj));
        }
        public JsonDataHandler(Exception ex = null, HttpCodeEnum httpCode = HttpCodeEnum.InternalServerError, string message = null)
        {
            Ex = ex;
            HttpCode = httpCode;
            Message = HttpCode.ToString();

            if (message != null)
                Message = string.Join(" ", Message, message);

            if (Ex != null)
                Message = string.Join(" ", Message, Ex.Message);

            if (Message == null)
                Message = "Internal Server Error";
        }
        public JsonDataHandler(Exception ex = null, HttpCodeEnum httpCode = HttpCodeEnum.InternalServerError, string message = null)
        {
            Ex       = ex;
            HttpCode = httpCode;
            Message  = HttpCode.ToString();

            if (message != null)
            {
                Message = string.Join(" ", Message, message);
            }

            if (Ex != null)
            {
                Message = string.Join(" ", Message, Ex.Message);
            }

            if (Message == null)
            {
                Message = "Internal Server Error";
            }
        }