Example #1
0
        public IPagedList<Article> GetArticles(ArticleList page, ArticleSearchModel model)
        {
            var query = _session.QueryOver<Article>()
                                .Where(a => a.Parent == page);

            if (!String.IsNullOrEmpty(model.Category))
            {
                Tag tagAlias = null;
                query = query.JoinAlias(article => article.Tags, () => tagAlias).Where(() => tagAlias.Name.IsInsensitiveLike(model.Category, MatchMode.Exact));
            }

            if (model.Month.HasValue)
            {
                query =
                    query.Where(
                        article => article.PublishOn != null && article.PublishOn.Value.MonthPart() == model.Month);
            }
            if (model.Year.HasValue)
            {
                query =
                    query.Where(
                        article => article.PublishOn != null && article.PublishOn.Value.YearPart() == model.Year);
            }

            return query.OrderBy(x => x.PublishOn).Desc.Paged(model.Page, page.PageSize);
        }
Example #2
0
        public SyndicationFeed GetSyndicationFeed(ArticleList page)
        {
            var possiblyPublishedArticles =
                _session.QueryOver<Article>()
                    .Where(article => article.Parent.Id == page.Id && article.PublishOn != null)
                    .Cacheable()
                    .List().Where(article => article.Published).OrderByDescending(article => article.PublishOn);

            var items = possiblyPublishedArticles.Select(GetItem).ToList();

            return new SyndicationFeed(page.Name, page.BodyContent.StripHtml(), new Uri(page.AbsoluteUrl), items);
        }
Example #3
0
        public List<ArchiveModel> GetMonthsAndYears(ArticleList articleList)
        {
            var query = (from article in _session.Query<Article>()
                         where article.Parent == articleList && article.PublishOn != null
                         group article by new { article.PublishOn.Value.Year, article.PublishOn.Value.Month } into entryGroup
                         select new ArchiveModel
                                    {
                                        Date = new DateTime(entryGroup.Key.Year, entryGroup.Key.Month, 1),
                                        Count = entryGroup.Count()
                                    });
            return query.ToList().OrderByDescending(x => x.Date).ToList();

        }