public async Task <IActionResult> UpdatePost(Post post) { if (!ModelState.IsValid) { return(View("Edit", post)); } var existing = await _note.GetPostById(post.ID) ?? post; string categories = Request.Form["categories"]; string title = (post.Title.Trim() != null) ? post.Title.Trim() : "need title for this post"; existing.Categories = categories.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(c => c.Trim().ToLowerInvariant()).ToList(); existing.Title = title; existing.Slug = Models.Post.CreateSlug(post.Title); existing.IsPublished = post.IsPublished; existing.Content = post.Content.Trim(); string content = post.Content.Trim(); existing.Excerpt = content.Substring(0, 500);; await _note.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() }); }