public void Count()
        {
            // Arrange
            CommentRepository commentRepository = new CommentRepository(dbContext);
            int expectedCommentsInDb            = Resources.Classes.DbFiller.Instance.CommentAmount;

            // Act
            int actualCommentsInDb = commentRepository.Count();

            // Assert
            Assert.AreEqual(expectedCommentsInDb, actualCommentsInDb);
        }
        public void CountIfMonthIs7()
        {
            // Arrange
            CommentRepository commentRepository = new CommentRepository(dbContext);
            int monthNumber = 7;
            int expectedCommentsOn7Month = Resources.Classes.DbFiller.Instance.GetCommentByMonth(monthNumber);

            // Act
            int actualCommentsOn7Month = commentRepository.Count(comment => comment.Date.Month == monthNumber);

            // Assert
            Assert.AreEqual(expectedCommentsOn7Month, actualCommentsOn7Month);
        }
Esempio n. 3
0
        public JsonResult GetAllComments(int dataid)
        {
            var userprofile = Session["UserProfile"] as UserProfileVM;
            var userid      = 0;

            if (userprofile != null)
            {
                userid = userprofile.User.ID;
            }
            var data  = new CommentRepository().GetAllComments(userid, dataid);
            var total = data.Count();

            return(Json(new
            {
                data = data,
                total = total
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        /// <summary>
        /// 得到统计信息
        /// </summary>
        /// <returns></returns>
        public IDictionary <string, string> GetRefstatInfo()
        {
            double totalDayCount = (DateTime.Now - Convert.ToDateTime("2009-01-01")).Days;

            int todayVisitorCount = _logRepository.SiteVisitCountOnToday();
            int totalVisitorCount = _logRepository.SiteVisitCount();

            int PostCount    = _postRepository.Count();
            int commentCount = _commentRepository.Count();
            int boardCount   = _boardRepository.Count();

            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("今日访问量", todayVisitorCount.ToString());
            data.Add("总访问人数", totalVisitorCount.ToString());
            data.Add("文章总数", PostCount.ToString());
            data.Add("评论总数", commentCount.ToString());
            data.Add("留言总数", boardCount.ToString());
            data.Add("平均日访问量", (totalVisitorCount / totalDayCount).ToString("#0.00"));
            data.Add("平均日新增文章数", (PostCount / totalDayCount).ToString("#0.00"));
            data.Add("平均日新增评论数", (commentCount / totalDayCount).ToString("#0.00"));
            data.Add("平均日新增留言数", (boardCount / totalDayCount).ToString("#0.00"));
            return(data);
        }
Esempio n. 5
0
 public Int32 GetCommentsCount(Guid postId)
 {
     return(_commentRepository.Count(p => p.PostId == postId && !p.IsDeleted));
 }
Esempio n. 6
0
 public int Count()
 {
     return(CommentRepository.Count());
 }