示例#1
0
        public async Task <JsonResult> GetNewsData(decimal Id)
        {
            try
            {
                NewsOprations np = new NewsOprations();
                DataSet       ds = await Task.Run(() => np.GetNewPost(Id, 2));

                if (ds == null)
                {
                    return(null);
                }
                var result = new { latest = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None), popular = JsonConvert.SerializeObject(ds.Tables[1], Formatting.None), related = JsonConvert.SerializeObject(ds.Tables[2], Formatting.None), Prev = JsonConvert.SerializeObject(ds.Tables[3], Formatting.None), Next = JsonConvert.SerializeObject(ds.Tables[4], Formatting.None) };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            return(null);
        }
示例#2
0
        public async Task <ActionResult> News(string Category, int?Year, int?Month, decimal?Id, string SlugUrl)
        {
            try
            {
                NewsOprations np = new NewsOprations();
                DataSet       ds = await Task.Run(() => np.GetNewPost(Id.Value, 1));

                if (ds == null)
                {
                    return(View());
                }
                ViewBag.Url = HttpContext.Request;
                return(View(ds.Tables[0]));
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            return(View());
        }