Esempio n. 1
0
        public ActionResult Index(string tags = null)
        {
            var posts = this.posts.All();

            if (!string.IsNullOrWhiteSpace(tags))
            {
                var separatedTags = Regex.Split(tags, @"\W+");
                posts = posts.Where(x => x.Tags.Any(y => separatedTags.Contains(y.Name)));
            }

            var model = posts
                        .OrderByDescending(x => x.CreatedOn)
                        .ThenBy(x => x.Id)
                        .ProjectTo <IndexBlogPostViewModel>();

            return(this.View(model));
        }