Esempio n. 1
0
 public BlogPostViewModel(
     BlogPost post,
     IReadOnlyList<BlogCategory> categories,
     IReadOnlyList<DateTime> archive) : base(categories, archive)
 {
     Post = post;
 }
Esempio n. 2
0
 public BlogPostViewModel(
     BlogPost post,
     IReadOnlyList<BlogCategory> categories,
     IReadOnlyList<DateTime> archive,
     IReadOnlyList<string> authors)
     : base(categories, archive, authors)
 {
     Post = post;
 }
Esempio n. 3
0
        public static IHtmlString RenderCategoryList(this HtmlHelper helper, BlogPost post)
        {
            var writer = new HtmlTextWriter(new StringWriter());
            for (int i = 0; i < post.Categories.Count; i++)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Href, LinkHelper.GetLink(post.Categories[i]));
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write(post.Categories[i].Title);
                writer.RenderEndTag();

                if (i != post.Categories.Count - 1)
                {
                    writer.Write(", ");
                }
            }
            return MvcHtmlString.Create(writer.InnerWriter.ToString());
        }
Esempio n. 4
0
 public static string GetLink(this HtmlHelper helper, BlogPost post)
 {
     return LinkHelper.GetLink(post);
 }
Esempio n. 5
0
 public static string GetLink(BlogPost post)
 {
     return $"/blog/{post.PostedAt.Year}/{post.PostedAt.Month:00}/{post.Slug}";
 }
Esempio n. 6
0
 public static string GetLink(BlogPost post)
 {
     return string.Format("/blog/{0}/{1:00}/{2}", post.PostedAt.Year, post.PostedAt.Month, post.Slug);
 }
Esempio n. 7
0
 private void AddToArchive(BlogPost post)
 {
     var year = post.PostedAt.Year;
     var month = post.PostedAt.Month;
     if (!_yearMonthToPostsLookup.ContainsKey(year))
     {
         _yearMonthToPostsLookup.Add(year, new Dictionary<int, List<BlogPost>>());
     }
     if (!_yearMonthToPostsLookup[year].ContainsKey(month))
     {
         _yearMonthToPostsLookup[year].Add(month, new List<BlogPost>());
         _archive.Add(new DateTime(year, month, 1, 0, 0, 0));
     }
     _yearMonthToPostsLookup[year][month].Add(post);
 }
Esempio n. 8
0
 private void AddToLookup(BlogPost post)
 {
     _idToPostLookup.Add(post.Id, post);
 }
Esempio n. 9
0
 private void AddToLookup(BlogPost post)
 {
     _idToPostLookup.Add(post.Id, post);
 }
Esempio n. 10
0
        public BlogPost GetBlogPost(int year, int month, string slug)
        {
            var id = BlogPost.GetId(year, month, slug);

            return(_idToPostLookup.ContainsKey(id) ? _idToPostLookup[id] : null);
        }