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.Categories = categories.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(c => c.Trim().ToLowerInvariant()).ToList(); existing.Title = post.Title.Trim(); existing.Slug = post.Slug.Trim(); existing.Slug = !string.IsNullOrWhiteSpace(post.Slug) ? post.Slug.Trim() : Models.Post.CreateSlug(post.Title); existing.IsPublished = post.IsPublished; existing.Content = post.Content.Trim(); existing.Excerpt = post.Excerpt.Trim(); await _blog.SavePost(existing); //await SaveFilesToDisk(existing); return(Redirect(post.GetLink())); }
private WilderMinds.MetaWeblog.Post ToMetaWebLogPost(Models.Post post) { var request = _context.HttpContext.Request; string url = request.Scheme + "://" + request.Host; return(new WilderMinds.MetaWeblog.Post { postid = post.ID, title = post.Title, wp_slug = post.Slug, permalink = url + post.GetLink(), dateCreated = post.PubDate, description = post.Content, categories = post.Categories.ToArray() }); }