Ejemplo n.º 1
0
        public JsonResult GetPost(int id)
        {
            var post = GetMethods.GetPost(id);

            if (post == null)
            {
                var err = ErrorMethods.Handle404();
                JsonConvert.SerializeObject(err);
                return(new JsonResult
                {
                    Data = err,
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,

                    ContentType = "application/json"
                });
            }

            var jsonResult = new JsonResult
            {
                Data = post,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,

                ContentType = "application/json"
            };

            return(jsonResult);
        }