public virtual ActionResult OnViewComments(long orderId) { LogI("OnViewComments, orderId=" + orderId); var model = new ViewCommentsViewModel(Db, orderId); ViewBag.PartialViewName = "ViewComments"; return(View("EditEmpty", model)); }
public async Task <IActionResult> ViewComments(Guid newsId, int pageNumber = 1) { News news = websiteDB.News.First(n => n.Id == newsId); int pageSize = 10; IQueryable <Comment> source = websiteDB.Comments.Where(c => c.NewsId == newsId); List <Comment> comments = await source.OrderByDescending(c => c.CommentDate).Skip((pageNumber - 1) * pageSize).Take(pageSize).ToListAsync(); int commentsCount = await source.CountAsync(); ViewCommentsViewModel model = new ViewCommentsViewModel() { News = news, Comments = comments, CurrentPage = pageNumber, TotalPages = (int)Math.Ceiling(commentsCount / (double)pageSize) }; return(View(model)); }
/// <summary> /// Provides a deterministic way to create the ViewComments property. /// </summary> public static void CreateViewComments() { if (_viewcomments == null) { _viewcomments = new ViewCommentsViewModel(); } }
/// <summary> /// Provides a deterministic way to delete the ViewComments property. /// </summary> public static void ClearViewComments() { if (_viewcomments != null) _viewcomments.Cleanup(); _viewcomments = null; }