public void ActionDetail(string endCode) { if (ViewPage.CurrentPage.MenuID > 0) { MenuID = ViewPage.CurrentPage.MenuID; } var item = ModNewsService.Instance.CreateQuery() .Where(o => o.Activity == true && o.Code == endCode) .WhereIn(MenuID > 0, o => o.MenuID, WebMenuService.Instance.GetChildIDForWeb_Cache("News", MenuID, ViewPage.CurrentLang.ID)) .ToSingle(); if (item != null) { // Tăng số lượt xem item.CountViewed = item.CountViewed + 1; ModNewsService.Instance.Save(item); MNewsModel model = new MNewsModel(); TryUpdateModel(model); //var dbQuery = ModCommentService.Instance.CreateQuery() // .Where(o => o.Activity == true && o.NewsID == item.ID && o.ReplyByID == 0) // .OrderByDesc(o => o.ID) // .Take(PageSize) // .Skip(PageSize * model.Page); //ViewBag.Comment = dbQuery.ToList(); //model.TotalRecord = dbQuery.TotalRecord; //model.PageSize = PageSize; //ViewBag.Model = model; ViewBag.Other = ModNewsService.Instance.CreateQuery() .Where(o => o.Activity == true && o.MenuID == item.MenuID && o.ID != item.ID) // && o.Order < item.Order //.WhereIn(MenuID > 0, o => o.MenuID, WebMenuService.Instance.GetChildIDForWeb_Cache("News", MenuID, ViewPage.CurrentLang.ID)) .OrderByDesc(o => o.Published) //.OrderByDesc(o => o.Order) .Take(PageSize) .ToList(); ViewBag.Data = item; // Lấy danh sách các bình luận ViewBag.ListComment = BinhLuan(item); ViewPage.CurrentPage.PageTitle = string.IsNullOrEmpty(item.PageTitle) ? item.Name : item.PageTitle; ViewPage.CurrentPage.PageDescription = string.IsNullOrEmpty(item.PageDescription) ? item.Summary : item.PageDescription; ViewPage.CurrentPage.PageKeywords = item.PageKeywords; // save CategoryId VSW.Lib.Global.Session.SetValue("MenuID", item.MenuID); // Current News Id VSW.Lib.Global.Session.SetValue("NewsID", item.ID); } else { ViewPage.Error404(); } }
public void ActionIndex(MNewsModel model) { if (ViewPage.CurrentPage.MenuID > 0) { MenuID = ViewPage.CurrentPage.MenuID; } var dbQuery = ModNewsService.Instance.CreateQuery() .Where(o => o.Activity == true) .WhereIn(MenuID > 0, o => o.MenuID, WebMenuService.Instance.GetChildIDForWeb_Cache("News", MenuID, ViewPage.CurrentLang.ID)) .OrderByDesc(o => o.Order) .Take(PageSize) .Skip(PageSize * model.Page); ViewBag.Data = dbQuery.ToList(); model.TotalRecord = dbQuery.TotalRecord; model.PageSize = PageSize; ViewBag.Model = model; }