예제 #1
0
        public VisitorHomePageModelContainer ReadStatisticsForHomePage()
        {
            var topVisits = VisitBiz.Read().GroupBy(r => r.ContentId)
                            .Select(group => new { ContentId = group.Key, TotalVisit = group.Sum(r => r.Count) })
                            .OrderByDescending(r => r.TotalVisit)
                            .Take(AppConfigurationManager.TopArticlesNumber);

            var topArticlesVisits = from a in ArticleBiz.ReadPublishedArticles()
                                    join av in topVisits
                                    on a.Id equals av.ContentId
                                    select new { a, av.TotalVisit };

            var topArticles = topArticlesVisits.OrderByDescending(t => t.TotalVisit).Select(t => t.a);

            return(new VisitorHomePageModelContainer()
            {
                TopArticles =
                    topArticles.MapTo <ContentInfo6PM>()
                    .ToList(),
                LatestArticles =
                    ArticleBiz.ReadLatestArticles(AppConfigurationManager.LatestArticlesNumber)
                    .MapTo <ContentInfo6PM>()
                    .ToList(),
                FeaturedArticles = FeaturedContentBiz.ReadFeaturedArticles().MapTo <ContentInfo6PM>().ToList(),
            });
        }
예제 #2
0
        public AdminDashboardModelContainer GetAdminDashboardStatistics()
        {
            var today = DateTime.Now.Date;

            return(new AdminDashboardModelContainer()
            {
                TodayVisitsCount =
                    VisitBiz.GetTodaySiteTotalVisitsCount(),
                TotalArticlesCount =
                    ArticleBiz.Read(c => c.State == ContentState.Published && c.Type == ContentType.Article).Count(),
                TotalBlogPostCount =
                    ArticleBiz.Read(c => c.State == ContentState.Published && c.Type == ContentType.BlogPost).Count(),
                TotalUsersCount = UserBiz.Read().Count(),
                NewUsers = UserBiz.GetNewUsers(top: 3).MapTo <AdminDashboardNewUserPm>().ToList(),
                NewArticles = ArticleBiz.ReadLatestArticles(3).MapTo <AdminDashboardNewArticlePm>().ToList()
            });
        }