コード例 #1
0
        /// <summary>
        /// 无参的失败返回类型
        /// </summary>
        /// <param name="resultCode"></param>
        /// <returns></returns>
        public IActionResult Failure(ResultCode resultCode)
        {
            GetStudentGroupResult result = new GetStudentGroupResult();

            result.code = (int)resultCode;
            result.msg  = resultCode.GetDescription();
            return(Ok(result));
        }
コード例 #2
0
        /// <summary>
        /// 不带参失败返回
        /// </summary>
        /// <param name="resultCode"></param>
        /// <returns></returns>
        public IActionResult Failure(ResultCode resultCode)
        {
            GetCoueseResult result = new GetCoueseResult
            {
                code = (int)resultCode,
                msg  = resultCode.GetDescription()
            };

            return(Ok(result));
        }
コード例 #3
0
ファイル: ApiResultBase.cs プロジェクト: wwwK/Comet
        public static ApiResultBase GetInstance(ResultCode code = ResultCode.Default, dynamic result = null, string message = "", string responseTime = "")
        {
            var apiResult = new ApiResultBase();

            apiResult.Code         = code;
            apiResult.Message      = string.IsNullOrEmpty(message) ? code.GetDescription() : message;
            apiResult.Result       = result ?? "";
            apiResult.ResponseTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            return(apiResult);
        }
コード例 #4
0
        /// <summary>
        /// 有参的失败返回类型
        /// </summary>
        /// <param name="resultCode"></param>
        /// <param name="response"></param>
        /// <returns></returns>
        public IActionResult Failure <T>(ResultCode resultCode, T response)
        {
            GetStudentGroupResult <T> result = new GetStudentGroupResult <T>();

            result.code = (int)resultCode;
            result.msg  = resultCode.GetDescription();

            result.data = response;
            return(Ok(result));
        }
コード例 #5
0
        /// <summary>
        /// 带数据失败返回类型
        /// </summary>
        /// <param name="resultCode"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public IActionResult Failure <T>(ResultCode resultCode, T data)
        {
            GetCoueseResult result = new GetCoueseResult
            {
                code = (int)resultCode,
                msg  = resultCode.GetDescription(),
                data = data
            };

            return(Ok(result));
        }
コード例 #6
0
 /// <summary>
 /// 返回响应码状态描述
 /// </summary>
 /// <param name="code">返回响应码状态枚举</param>
 /// <returns></returns>
 public static ResponseResult GenFaildResponse(ResultCode code = ResultCode.Faild)
 {
     return(new ResponseResult {
         Code = (int)code, Message = code.GetDescription()
     });
 }
コード例 #7
0
 public Result(ResultCode code, string msg, T data)
 {
     this.code = code;
     this.msg  = msg ?? code.GetDescription();
     this.data = data;
 }
コード例 #8
0
        public static string ConvertString(this ResultCode code, params string[] @params)
        {
            string description = string.Format(code.GetDescription(), @params);

            return(string.Format("{0} {1}", (int)code, description));
        }
コード例 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="resultCode"></param>
 /// <param name="popup"></param>
 public ResultMessage(ResultCode resultCode = ResultCode.Ok, PopupOption popup = PopupOption.Default)
 {
     Title   = resultCode.GetDescription();
     Message = resultCode.GetDescription();
     Popup   = popup;
 }