public static DynamicTableEntity ToDte(Post post) { var dte = new DynamicTableEntity(post.UniqueKey, string.Empty); dte.Properties.Add("Slug", EntityProperty.GeneratePropertyForString(post.Slug)); dte.Properties.Add("Title", EntityProperty.GeneratePropertyForString(WebUtility.HtmlEncode(post.Title))); dte.Properties.Add("Date", EntityProperty.GeneratePropertyForDateTimeOffset(post.Date)); dte.Properties.Add("DateModified", EntityProperty.GeneratePropertyForDateTimeOffset(post.DateModified)); dte.Properties.Add("Categories", EntityProperty.GeneratePropertyForString(Category.ToString(post.Categories))); dte.Properties.Add("Tags", EntityProperty.GeneratePropertyForString(Category.ToString(post.Tags))); dte.Properties.Add("Author", EntityProperty.GeneratePropertyForString(PostAuthor.ToString(post.Author))); dte.Properties.Add("CommentCount", EntityProperty.GeneratePropertyForInt(post.CommentCount)); if (post.DasBlogEntryId.HasValue) { dte.Properties.Add("DasBlogEntryId", EntityProperty.GeneratePropertyForGuid(post.DasBlogEntryId.Value)); } if (!string.IsNullOrEmpty(post.DasBlogTitle)) { dte.Properties.Add("DasBlogTitle", EntityProperty.GeneratePropertyForString(post.DasBlogTitle)); } if (!string.IsNullOrEmpty(post.DasBlogUniqueTitle)) { dte.Properties.Add("DasBlogUniqueTitle", EntityProperty.GeneratePropertyForString(post.DasBlogUniqueTitle)); } return dte; }
static string FormatPostUrl(Post post) { return post == null ? null : $"/blog/{post.Date.ToString("yyyy/MM/dd")}/{post.Slug}"; }
string GeneratePostUrl(Post post) { return Url.Action("Post", new {year = post.Date.Year, month = post.Date.Month, day = post.Date.Day, slug = post.Slug}); }