private void SavePost() { Post post = App.MasterViewModel.CurrentPost; Blog blog = App.MasterViewModel.CurrentBlog; if (post.HasMedia() && !post.IsLocalDraft()) { StringBuilder prependBuilder = new StringBuilder(); StringBuilder appendBuilder = new StringBuilder(); List <string> mediaIds = new List <string>(); bool galleryEnabled = uploadImagesAsGalleryCheckbox.Visibility == Visibility.Visible && uploadImagesAsGalleryCheckbox.IsChecked.GetValueOrDefault(); post.GenerateImageMarkup(blog.PlaceImageAboveText, galleryEnabled); } //make sure the post has the latest UI data--the Save button is a ToolbarButton //which doesn't force focus to change post.Title = titleTextBox.Text; if (post.IsNew) { if (!post.IsLocalDraft()) { NewPostRPC rpc = new NewPostRPC(App.MasterViewModel.CurrentBlog, post); rpc.PostType = ePostType.page; rpc.Completed += OnNewPostRPCCompleted; rpc.ExecuteAsync(); currentXmlRpcConnection = rpc; } else { // Create or update a local draft if (App.MasterViewModel.CurrentPageListItem != null) { if (App.MasterViewModel.CurrentPageListItem.DraftIndex > -1) { App.MasterViewModel.CurrentBlog.LocalPageDrafts[App.MasterViewModel.CurrentPageListItem.DraftIndex] = post; } } else { blog.LocalPageDrafts.Add(post); } // Exit post editor if (NavigationService.CanGoBack) { NavigationService.GoBack(); } else { throw new ApplicationShouldEndException(); } } } else { EditPostRPC rpc = new EditPostRPC(App.MasterViewModel.CurrentBlog, post); if (post.PostStatus == "publish") { rpc.Publish = true; } else { rpc.Publish = false; } rpc.PostType = ePostType.page; rpc.Completed += OnEditPostRPCCompleted; currentXmlRpcConnection = rpc; rpc.ExecuteAsync(); } this.Focus(); ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges); }
private void SavePost() { //Post post = DataContext as Post; //changed to CurrentPost so categories would save Post post = App.MasterViewModel.CurrentPost; Blog blog = App.MasterViewModel.CurrentBlog; if (post.HasMedia() && !post.IsLocalDraft()) { bool galleryEnabled = uploadImagesAsGalleryCheckbox.Visibility == Visibility.Visible && uploadImagesAsGalleryCheckbox.IsChecked.GetValueOrDefault(); post.GenerateImageMarkup(blog.PlaceImageAboveText, galleryEnabled); } //make sure the post has the latest UI data--the Save button is a ToolbarButton //which doesn't force focus to change post.Title = titleTextBox.Text; post.MtKeyWords = tagsTextBox.Text; if (post.IsNew) { if (!post.IsLocalDraft()) { // Anything but local draft status gets uploaded UserSettings settings = new UserSettings(); if (settings.UseTaglineForNewPosts) { post.AddTagline(settings.Tagline); } NewPostRPC rpc = new NewPostRPC(App.MasterViewModel.CurrentBlog, post); rpc.PostType = ePostType.post; rpc.Completed += OnNewPostRPCCompleted; rpc.ExecuteAsync(); currentXmlRpcConnection = rpc; this.Focus(); ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges); } else { // Create or update a local draft if (App.MasterViewModel.CurrentPostListItem != null) { if (App.MasterViewModel.CurrentPostListItem.DraftIndex > -1) { App.MasterViewModel.CurrentBlog.LocalPostDrafts[App.MasterViewModel.CurrentPostListItem.DraftIndex] = post; } } else { blog.LocalPostDrafts.Add(post); } // Exit post editor if the app was not lauched from the sharing feature. if (NavigationService.CanGoBack) { NavigationService.GoBack(); } else { throw new ApplicationShouldEndException(); } } } else { EditPostRPC rpc = new EditPostRPC(App.MasterViewModel.CurrentBlog, post); rpc.Completed += OnEditPostRPCCompleted; rpc.ExecuteAsync(); currentXmlRpcConnection = rpc; this.Focus(); ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges); } }