public virtual ActionResult OnViewComments(long orderId)
        {
            LogI("OnViewComments, orderId=" + orderId);

            var model = new ViewCommentsViewModel(Db, orderId);

            ViewBag.PartialViewName = "ViewComments";
            return(View("EditEmpty", model));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 /// <summary>
 /// Provides a deterministic way to create the ViewComments property.
 /// </summary>
 public static void CreateViewComments()
 {
     if (_viewcomments == null)
     {
         _viewcomments = new ViewCommentsViewModel();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Provides a deterministic way to delete the ViewComments property.
 /// </summary>
 public static void ClearViewComments()
 {
     if (_viewcomments != null)
         _viewcomments.Cleanup();
     _viewcomments = null;
 }