public PublishDetailsViewModel(Details post, List<BlogSetting> blogs) { this.post = post; Blogs = new ObservableCollection<BlogSetting>(blogs); SelectedBlog = Blogs[0]; }
/// <summary> /// Publishes any document /// </summary> /// <param name="postId"></param> /// <param name="document"></param> /// <returns></returns> public Task<IMarkpadDocument> PublishDocument(string postId, IMarkpadDocument document) { var blogs = blogService.GetBlogs(); if (blogs == null || blogs.Count == 0) { if (!blogService.ConfigureNewBlog("Publish document")) return TaskEx.FromResult<IMarkpadDocument>(null); blogs = blogService.GetBlogs(); if (blogs == null || blogs.Count == 0) return TaskEx.FromResult<IMarkpadDocument>(null); } var categories = new List<string>(); var webDocument = document as WebDocument; if (webDocument != null) categories = webDocument.Categories; var pd = new Details { Title = document.Title, Categories = categories.ToArray()}; var detailsResult = windowManager.ShowDialog(new PublishDetailsViewModel(pd, blogs)); if (detailsResult != true) return TaskEx.FromResult<IMarkpadDocument>(null); var newDocument = new WebDocument(pd.Blog, null, pd.Title, document.MarkdownContent, new FileReference[0], this, webDocumentService.Value, siteContextGenerator.GetWebContext(pd.Blog), fileSystem); foreach (var associatedFile in document.AssociatedFiles) { newDocument.AddFile(new FileReference(associatedFile.FullPath, associatedFile.RelativePath, false)); } return newDocument.Save(); }
public Task<IMarkpadDocument> PublishDocument(IMarkpadDocument document) { var blogs = blogService.GetBlogs(); if (blogs == null || blogs.Count == 0) { if (!blogService.ConfigureNewBlog("Publish document")) return TaskEx.FromResult<IMarkpadDocument>(null); blogs = blogService.GetBlogs(); if (blogs == null || blogs.Count == 0) return TaskEx.FromResult<IMarkpadDocument>(null); } var post = new Post(); var pd = new Details { Title = document.Title, Categories = post.categories }; var detailsResult = windowManager.ShowDialog(new PublishDetailsViewModel(pd, blogs)); if (detailsResult != true) return TaskEx.FromResult<IMarkpadDocument>(null); return TaskEx.Run(() => CreateNewWebMarkdownFile(null, pd.Title, pd.Categories, document.MarkdownContent, pd.Blog)); }