예제 #1
0
        public static object Success <T>(this SherlockApiController controller, T obj)
        {
            var response = obj.IncludeResponse();

            controller.SetStatusCode(HttpStatusCode.OK);
            return(response);
        }
예제 #2
0
        static object Error <T>(this SherlockApiController controller, T obj, string code, string message, HttpStatusCode httpCode)
        {
            var response = obj.IncludeResponse(message, code);

            controller.SetStatusCode(httpCode);
            //var res = controller.StatusCode((int)httpCode, response);
            return(response);
        }
예제 #3
0
        public static object Error <T>(this SherlockApiController controller, T enumCode, string message)
            where T : struct

        {
            var def = enumCode.GetErrDefinition();

            return(Error(controller, default(object), def.Code, message, HttpStatusCode.BadRequest));
        }
예제 #4
0
        public static object Error <T, TObj>(this SherlockApiController controller, T enumCode, TObj obj)
            where T : struct
            where TObj : class
        {
            //var response = obj.IncludeResponse();
            var def = enumCode.GetErrDefinition();

            return(Error(controller, obj, def.Code, def.Msg, HttpStatusCode.BadRequest));
        }
예제 #5
0
 static void SetStatusCode(this SherlockApiController controller, HttpStatusCode code)
 {
     controller.Response.StatusCode = (int)code;
 }
예제 #6
0
        /// <summary>
        /// 拒绝请求,因为无相关权限,返回403
        /// </summary>
        /// <returns></returns>
        public static object Deny(this SherlockApiController controller)
        {
            var detail = ErrCodeCommon.PermissionDenied.GetErrDefinition();

            return(Error(controller, default(object), detail.Code, detail.Msg, HttpStatusCode.Forbidden));
        }
예제 #7
0
 public static object Success(this SherlockApiController controller)
 {
     controller.SetStatusCode(HttpStatusCode.OK);
     return(default(object));
 }
예제 #8
0
 public static object Error <T>(this SherlockApiController controller, T enumCode)
     where T : struct
 {
     return(Error(controller, enumCode, default(object)));
 }