public async Task <PostResult> EditPost(BlogPost post, INewCategoryContext newCategoryContext, bool publish) { // initialize result (for edits the id never changes) PostResult result = new PostResult(); var editpostResult = new EditPostResult(); result.PostId = post.Id; try { //apply any publishing filters and make the post using (new ContentFilterApplier(post, ClientOptions, ContentFilterMode.Publish)) { // make the post if (post.IsPage) { await BlogClient.EditPage(_settings.HostBlogId, post, publish, result.ETag, result.AtomRemotePost); } else { await BlogClient.EditPost(_settings.HostBlogId, post, newCategoryContext, publish, editpostResult); } } // note success _settings.LastPublishFailed = false; } catch (BlogClientProviderException ex) { if (ErrorIsInvalidPostId(ex)) { return(await NewPost(post, newCategoryContext, publish)); } else { throw; } } catch { _settings.LastPublishFailed = true; throw; } // determine the date-published based on whether there was an override if (post.HasDatePublishedOverride) { result.DatePublished = post.DatePublishedOverride; } else { result.DatePublished = DateTime.UtcNow; } // return result return(result); }