Exemplo n.º 1
0
        public IEnumerable <Post> ArchivePosts(int?Year, int?Month, int?Day, string Slug)
        {
            var posts = Posts.AsQueryable();

            if (Year.HasValue)
            {
                posts = posts.Where(p => p.Published.Year == Year.Value);
            }
            if (Month.HasValue)
            {
                posts = posts.Where(p => p.Published.Month == Month.Value);
            }
            if (Day.HasValue)
            {
                posts = posts.Where(p => p.Published.Day == Day.Value);
            }
            if (!string.IsNullOrWhiteSpace(Slug))
            {
                posts = posts.Where(p => p.Slug.Equals(Slug, StringComparison.InvariantCultureIgnoreCase));
            }

            return(posts.OrderByDescending(p => p.Published));
        }