예제 #1
0
        public ShowCommentForAdminViewModel GetAllComfirmedCommentsForAdmin(int pageid = 1, string filtername = "", string filterreporttitle = "", string filtercommenttext = "")
        {
            IQueryable <ReportComment> comments = _context.ReportComments.Where(c => c.IsAdminRead == true).Include(c => c.User).Include(c => c.Report);

            if (!string.IsNullOrEmpty(filtername))
            {
                comments = comments.Where(c => c.User.UserName.Contains(filtername));
            }
            if (!string.IsNullOrEmpty(filterreporttitle))
            {
                comments = comments.Where(c => c.Report.ReportTitle.Contains(filterreporttitle));
            }
            if (!string.IsNullOrEmpty(filtercommenttext))
            {
                comments = comments.Where(c => c.CommentText.Contains(filtercommenttext));
            }

            int take = 10;
            int skip = (pageid - 1) * take;

            ShowCommentForAdminViewModel list = new ShowCommentForAdminViewModel();

            list.CurrentPage    = pageid;
            list.PageCount      = comments.Count() / take;
            list.ReportComments = comments.OrderByDescending(c => c.CreateDate).Skip(skip).Take(take).ToList();
            return(list);
        }
예제 #2
0
 public void OnGet(int pageid = 1, string filtername = "", string filterreporttitle = "", string filtercommenttext = "")
 {
     Comments = _reportService.GetAllCommentsForAdmin(pageid, filtername, filterreporttitle, filtercommenttext);
 }