public async Task <IActionResult> UpdatePost(Post post)
        {
            if (!ModelState.IsValid)
            {
                return(View("Edit", post));
            }

            var existing = await _blog.GetPostById(post.ID) ?? post;

            string categories = Request.Form["categories"];

            existing = PostModule.UpdateWith(existing, post);
            existing = PostModule.WithCategories(categories, post);

            await _blog.SavePost(existing);

            await SaveFilesToDisk(existing);

            return(Redirect(PostModule.GetLink(existing)));
        }
        public bool EditPost(string postid, string username, string password, WilderMinds.MetaWeblog.Post post, bool publish)
        {
            ValidateUser(username, password);

            var existing = _blog.GetPostById(postid).GetAwaiter().GetResult();

            if (existing != null)
            {
                var update = PostModule.Create(post.title, Microsoft.FSharp.Core.OptionModule.OfObj(post.wp_slug), existing.Excerpt, post.description, existing.IsPublished);
                existing = PostModule.UpdateWith(existing, update);
                existing = PostModule.WithCategories(String.Join(",", post.categories), existing);

                if (post.dateCreated != DateTime.MinValue)
                {
                    existing = PostModule.WithPubDate(post.dateCreated, existing);
                }

                _blog.SavePost(existing).GetAwaiter().GetResult();

                return(true);
            }

            return(false);
        }