Exemplo n.º 1
0
        public static object Success <T>(this SherlockApiController controller, T obj)
        {
            var response = obj.IncludeResponse();

            controller.SetStatusCode(HttpStatusCode.OK);
            return(response);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 5
0
 static void SetStatusCode(this SherlockApiController controller, HttpStatusCode code)
 {
     controller.Response.StatusCode = (int)code;
 }
Exemplo n.º 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));
        }
Exemplo n.º 7
0
 public static object Success(this SherlockApiController controller)
 {
     controller.SetStatusCode(HttpStatusCode.OK);
     return(default(object));
 }
Exemplo n.º 8
0
 public static object Error <T>(this SherlockApiController controller, T enumCode)
     where T : struct
 {
     return(Error(controller, enumCode, default(object)));
 }