public
Created

  • Download Gist
Action.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
public ActionResult Archive(int year, int? month, int? day)
{
RavenQueryStatistics stats;
var postsQuery = RavenSession.Query<Post>()
.Include(x => x.AuthorId)
.Statistics(out stats)
.WhereIsPublicPost()
.Where(post => post.PublishAt.Year == year);
if (month != null)
postsQuery = postsQuery.Where(post => post.PublishAt.Month == month.Value);
 
if (day != null)
postsQuery = postsQuery.Where(post => post.PublishAt.Day == day.Value);
 
var posts =
postsQuery.OrderByDescending(post => post.PublishAt)
.Paging(CurrentPage, DefaultPage, PageSize)
.ToList();
 
return ListView(stats.TotalResults, posts);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.