public override void Execute([NotNull] CommandContext context) { Assert.ArgumentNotNull(context, "context"); var items = context.Items; Assert.IsNotNull(items, "items"); var item = items.SingleOrDefault(); Assert.IsNotNull(item, "item"); var home = BloggrContext.GetHome(item); var structure = home != null?BloggrContext.GetPostsStructureItem(home) : null; var bloggrPostTemplate = item.GetItem("{2BDE036E-3503-4BF0-B978-213F46541B21}"); if (structure == null || structure.Get("Bloggr Post AutoName") != "1") { context.Parameters.Add("master", bloggrPostTemplate.ID.ToString()); base.Execute(context); return; } var template = (TemplateItem)bloggrPostTemplate; Context.Workflow.AddItem("Bloggr Post", template, item); }
public virtual bool ValidatePostLocation([NotNull] Item bloggrPost) { Assert.ArgumentNotNull(bloggrPost, "bloggrPost"); var statistics = bloggrPost.Statistics; Assert.IsNotNull(statistics, "statistics"); var created = statistics.Created; if (created == DateTime.MinValue) { // in Sitecore 8.0 is used UTC, in previous versions - local time. created = DateTime.UtcNow; } var day = bloggrPost.Parent; if (day == null || day.Name != created.ToString("dd")) { return(false); } var month = day.Parent; if (month == null || month.Name != created.ToString("MM")) { return(false); } var year = month.Parent; if (year == null || year.Name != created.ToString("yyyy")) { return(false); } return(BloggrContext.GetHome(year) != null); }