public BlogPostViewModel( BlogPost post, IReadOnlyList<BlogCategory> categories, IReadOnlyList<DateTime> archive) : base(categories, archive) { Post = post; }
public BlogPostViewModel( BlogPost post, IReadOnlyList<BlogCategory> categories, IReadOnlyList<DateTime> archive, IReadOnlyList<string> authors) : base(categories, archive, authors) { Post = post; }
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()); }
public static string GetLink(this HtmlHelper helper, BlogPost post) { return LinkHelper.GetLink(post); }
public static string GetLink(BlogPost post) { return $"/blog/{post.PostedAt.Year}/{post.PostedAt.Month:00}/{post.Slug}"; }
public static string GetLink(BlogPost post) { return string.Format("/blog/{0}/{1:00}/{2}", post.PostedAt.Year, post.PostedAt.Month, post.Slug); }
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); }
private void AddToLookup(BlogPost post) { _idToPostLookup.Add(post.Id, post); }
public BlogPost GetBlogPost(int year, int month, string slug) { var id = BlogPost.GetId(year, month, slug); return(_idToPostLookup.ContainsKey(id) ? _idToPostLookup[id] : null); }