コード例 #1
0
ファイル: GetHandler.cs プロジェクト: alistair/fubumvc.blog
        public ArticlesCountViewModel Execute(ArticlesCountInputModel inputModel)
        {
            IDocumentCollection stats;
            var draftCount = _database
                             .Statistics <Article>(out stats)
                             .Where(x => !x.IsPublished)
                             .LongCount();

            var history = _database.Query <Article>()
                          .Where(x => x.PublishedDate > DateTime.Now.Subtract(new TimeSpan(30, 0, 0, 0)))
                          .ToList()
                          .GroupBy(x => x.PublishedDate.Date)
                          .Select(x => new DateCountViewModal
            {
                PostedDate         = x.Key.ToString("MM/dd"),
                DraftArticleCount  = x.Sum(a => a.IsPublished ? 0 : 1),
                PostedArticleCount = x.Sum(a => a.IsPublished ? 1 : 0),
            });

            return(new ArticlesCountViewModel
            {
                Total = stats.Count,
                Draft = draftCount,
                History = history
            });
        }
コード例 #2
0
ファイル: GetHandler.cs プロジェクト: alistair/fubumvc.blog
        public CommentsCountViewModel Execute(CommentsCountInputModel inputModel)
        {
            IDocumentCollection info;
            var spamCount = _database
                            .Statistics <Comment>(out info)
                            .Where(x => x.IsPotentialSpam)
                            .LongCount();


            var history = _database.Query <Comment>()
                          .Where(x => x.PublishedDate > DateTime.Now.Subtract(new TimeSpan(30, 0, 0, 0)))
                          .ToList()
                          .GroupBy(x => x.PublishedDate.Date)
                          .Select(x => new DateCountViewModal
            {
                PostedDate          = x.Key.ToString("MM/dd"),
                SpamCount           = x.Sum(a => a.IsPotentialSpam ? 1 : 0),
                PostedCommentsCount = x.Sum(a => a.IsApproved ? 1 : 0),
            });

            return(new CommentsCountViewModel
            {
                Total = info.Count,
                Spam = spamCount,
                History = history
            });
        }
コード例 #3
0
ファイル: GetHandler.cs プロジェクト: alistair/fubumvc.blog
        public ManageArticlesViewModel Execute(ManageArticlesInputModel inputModel)
        {
            IDocumentCollection stats;

            var articles = _database
                           .Statistics <Article>(out stats)
                           .FilteryByPublished(inputModel.ShowDraft)
                           .Page(inputModel)
                           .ToList();

            return(new ManageArticlesViewModel
            {
                Articles = articles.Select(x => x.DynamicMap <ManageArticleViewModel>()),
                TotalPages = stats.Count.TotalPages(inputModel.Count),
                ShowDraft = inputModel.ShowDraft
            });
        }