예제 #1
0
 /// <summary>
 /// 根据任意类型得到json
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>ContentResult</returns>
 public static ContentResult GetResult(object obj)
 {
     return(new ContentResult()
     {
         Content = JsonHandle.SerializeObject(obj),
         ContentType = "application/json",
         ContentEncoding = Encoding.UTF8
     });
 }
예제 #2
0
        /// <summary>
        /// 根据成功状态与对应的状态信息得到json
        /// </summary>
        /// <param name="isSuccess"></param>
        /// <param name="responseInfo"></param>
        /// <returns>ContentResult</returns>
        public static ContentResult GetResult(bool isSuccess, string responseInfo)
        {
            ActionResultModel <string> result = new ActionResultModel <string>();

            result.isSuccess    = isSuccess;
            result.responseInfo = responseInfo;
            return(new ContentResult()
            {
                Content = JsonHandle.SerializeObject(result),
                ContentType = "application/json",
                ContentEncoding = Encoding.UTF8
            });
        }
예제 #3
0
        /// <summary>
        /// 得到键值列表的json
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="_db"></param>
        /// <returns>ContentResult</returns>
        public static ContentResult GetKVList(string tableName, SqlSugarClient _db)
        {
            List <KeyValuePair <string, string> > json = _db.SqlQuery <KeyValuePair <string, string> >("select ListKey,Description from " + tableName + " where LanguageId=1");

            return(JsonHandle.GetResult(json));
        }