public ActionResult NewsDetail(int id) { ViewData.Model = GetNewsDetails(id); #region 一篇、下一篇 //-上一篇、下一篇 //用pre和next变量分别存放上一篇文章和下一篇文章的id号 int pre = 0, next = 0, i = 0, j; //计算总记录数 int num = NewsBll.LoadEntities(n => n.Id > 0).Count(); int[] a = new int[num]; var query = NewsBll.LoadEntities(n => true).Select(n => n.Id).ToArray(); //将所有的文章id号全部放入一个数组中 foreach (var item in query) { a[i] = Convert.ToInt32(item); i++; } //循环,获取上一篇和下一篇文章的ID号,分别放入变量pre和next中 for (j = 0; j < num; j++) { if (a[j] == id) { if (j != 0) { pre = a[j - 1]; //上一篇id } if (j != num - 1) { next = a[j + 1]; //下一篇文章id } } } //获取上一篇文章的标题 if (pre == 0) { ViewBag.preTitle = "没有了"; ViewBag.pre = id; } else { ViewBag.preTitle = NewsBll.LoadEntities(n => n.Id == pre).Single().Title; ViewBag.pre = pre; } //获取下一篇文章的标题 if (next == 0) { ViewBag.nextTitle = "没有了"; ViewBag.next = id; } else { ViewBag.nextTitle = NewsBll.LoadEntities(n => n.Id == next).Single().Title; ViewBag.next = next; } #endregion ViewBag.SameKeys = NewsBll.TheSameKeyWords(id); return(View()); }
public ActionResult CpyNewsEdit(int id) { var currentCpy = GetCurrentUser(); ViewData.Model = NewsBll.LoadEntities(n => n.Id == id && n.CompanyId == currentCpy.Id).FirstOrDefault(); return(View()); }
//新游在线 热游、产业:1,2,3 private List <FrontNews> GetAllNews(string type) { List <FrontNews> list = NewsBll.LoadEntities(n => n.Type == type && n.State == "1").Select(n => new FrontNews() { Id = n.Id, Title = n.Title, EditTitle = n.EditTitle, InTime = n.InTime }).AsNoTracking().OrderByDescending(n => n.InTime).Take(6).ToList(); return(list); }
/// <summary> /// 新闻评论的数据加载 /// </summary> /// <returns></returns> public ActionResult LoadNewsLeaveMsg() { int newsId = int.Parse(Request["newsId"]); int pageIndex = int.Parse(Request["pageIndex"] ?? "1"); int pageSize = int.Parse(Request["pageSize"] ?? "20"); int total = 0; var msg = LeaveMsgBll.LoadEntities(m => true); var news = NewsBll.LoadEntities(n => n.Id > 0).Select(n => new { n.Id }); var user = PersonalUserBll.LoadEntities(u => u.Id > 0).Select(u => new { u.UName, u.Id, u.Head }); //-------------请求发布的评论---------------------------------- var data = from m in msg join u in user on m.PersonalUserId equals u.Id into um from umi in um.DefaultIfEmpty() join n in news on m.NewsId equals n.Id where m.NewsId == newsId where m.ReplyId == null || m.ReplyId == 0 select new Publish() { Id = m.Id, Msg = m.Msg, City = m.City, UserName = umi != null ? umi.UName : "" + m.Id + "" + "爽赞网友", //用户名 UserNameImg = umi.Head != null ? ("/Content/Img/" + umi.Head) : null, //用户头像 InTime = m.InTime, Tip = m.Tip == null ? 0 : m.Tip, Stamp = m.Stamp == null ? 0 : m.Stamp, }; var alldata = data.AsNoTracking().OrderByDescending(d => d.InTime).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList(); total = data.Count(); List <Publish> list = WebHelper.ToListTimeSpan(alldata); //-------------------------- //回复的数据--------------------------------------------- string pubStrNav = LaomaPager.ShowPageNavigate(pageSize, pageIndex, total); //回复的数据 var replyData = LeaveMsgBll.GetNewsLeaveMsgData(newsId).Select(n => new Reply { SelfId = n.SelfId, ReplyId = n.ReplyId, ReplyContent = n.ReplyContent, ReplyCity = n.ReplyCity, ReplyName = n.ReplyName, ReplyUserImg = n.ReplyUserImg, //用户头像 ReplyInTime = n.ReplyInTime, ReplyTip = n.ReplyTip, ReplyStamp = n.ReplyStamp, }).ToList(); List <Reply> replyList = WebHelper.ToReplyStrTimeSpan(replyData); var result = new { Data = list, replyData = replyList, PubStrNav = pubStrNav, Total = total }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public List <FrontNews> GetNewestNewsPC() { List <FrontNews> list = NewsBll.LoadEntities(n => n.Type == "4" && n.State == "1") .Select(n => new FrontNews() { Id = n.Id, Title = n.Title, EditTitle = n.EditTitle, InTime = n.InTime }).OrderByDescending(n => n.InTime).Take(15).AsNoTracking().ToList(); return(list); }
public ActionResult CpyNewsInfoEdit(int newsId, int companyId) { var news = NewsBll.LoadEntities(n => n.Id == newsId).FirstOrDefault(); news.CompanyId = int.Parse(Request["companyId"].ToString()); news.Title = Request["title"]; news.Game = Request["gameName"]; news.Kewords = Request["keyword"]; news.Type = Request["type"]; news.Memo = Request["memo"]; news.Msg = Request["msg"]; news.State = "2"; if (NewsBll.Update(news)) { return(Content("ok")); } else { return(Content("no")); } }
public ActionResult GetCpyNews(int limit, int offset, string title, DateTime?startday, DateTime?endday) { var currentCpy = GetCurrentUser(); var data = NewsBll.LoadEntities(n => n.CompanyId == currentCpy.Id).Select(n => new { n.Title, n.InTime, n.Kewords, n.State, n.Id }); if (!string.IsNullOrEmpty(title)) { data = data.Where(d => d.Title.Contains(title)); } if (startday.HasValue || endday.HasValue) { endday = endday.Value.AddDays(1); data = data.Where(d => d.InTime >= startday && d.InTime <= endday); } var total = data.Count(); var rows = data.OrderByDescending(d => d.InTime) .Skip(offset).Take(limit).ToList(); return(Json(new { total = total, rows = rows }, JsonRequestBehavior.AllowGet)); }
public ActionResult Views(int id) { var news = NewsBll.LoadEntities(n => n.Id == id).FirstOrDefault(); if (news != null) { news.Views = news.Views == null?1:news.Views + 1; if (NewsBll.Update(news)) { return(Content("ok")); } else { return(Content("no")); } } else { return(Content("noExist")); } }
public ActionResult SeeCpyNewsDetail(int id) { ViewData.Model = NewsBll.LoadEntities(n => n.Id == id).FirstOrDefault(); return(View()); }
public ActionResult FunNewsDetail(int id) { var nn = GetNewsDetails(id); ViewData.Model = nn; //-----相关推荐 ViewData["recTopSixFunNews"] = NewsBll.GetRelatedFunNews(id, 6, "0"); #region 一篇、下一篇 //-上一篇、下一篇 //用pre和next变量分别存放上一篇文章和下一篇文章的id号 int pre = 0, next = 0, i = 0, j; //计算总记录数 int num = NewsBll.LoadEntities(n => true).Count(); int[] a = new int[num]; var query = NewsBll.LoadEntities(n => true).Select(n => n.Id).ToArray(); //将所有的文章id号全部放入一个数组中 foreach (var item in query) { a[i] = Convert.ToInt32(item); i++; } //循环,获取上一篇和下一篇文章的ID号,分别放入变量pre和next中 for (j = 0; j < num; j++) { if (a[j] == id) { if (j != 0) { pre = a[j - 1]; //上一篇id } if (j != num - 1) { next = a[j + 1]; //下一篇文章id } } } //获取上一篇文章的标题 if (pre == 0) { ViewBag.preTitle = "没有了"; ViewBag.pre = id; } else { string edtitTitle = NewsBll.LoadEntities(n => n.Id == pre).Single().EditTitle; //拿了原标题 if (edtitTitle != null) { ViewBag.preTitle = edtitTitle; } else { ViewBag.preTitle = NewsBll.LoadEntities(n => n.Id == pre).Single().Title; } ViewBag.pre = pre; } //获取下一篇文章的标题 if (next == 0) { ViewBag.nextTitle = "没有了"; ViewBag.next = id; } else { string edtitTitle = NewsBll.LoadEntities(n => n.Id == next).Single().EditTitle; //拿了原标题 if (edtitTitle != null) { ViewBag.nextTitle = edtitTitle; } else { ViewBag.nextTitle = NewsBll.LoadEntities(n => n.Id == next).Single().Title; } ViewBag.next = next; } #endregion return(View()); }