Пример #1
0
        /// <summary>
        /// Formats the result of a query. Results are wrapped inside an object with a data property
        /// for consistency and prevent a vulnerability with return JSON arrays. If the result is
        /// null then a 404 response is returned.
        /// </summary>
        /// <typeparam name="T">Type of the result</typeparam>
        /// <param name="result">The result to return</param>
        public JsonResult SimpleQueryResponse <T>(T result)
        {
            var response = new SimpleResponseData <T>()
            {
                Data = result
            };

            var jsonResult = CreateJsonResult(response);

            if (result == null)
            {
                jsonResult.StatusCode = 404;
            }

            return(jsonResult);
        }