예제 #1
0
        public async Task <IActionResult> Edit(string slugArticle, Article article)
        {
            if (ModelState.IsValid)
            {
                article.Slug           = Slug(article.Title);
                article.Title          = article.Title;
                article.WritedDatetime = DateTime.Now;
                article.Content        = article.Content;
                article.Description    = Truncate(Markdown.ToPlainText(article.Content), 300, "…", true);
                article.AuthorUsername = User.Identity.Name;
                article.Keywords       = article.Keywords;
                article.IsDraft        = article.IsDraft;
                article.Unlisted       = article.Unlisted;
                await _articles.EditArticleAsync(slugArticle, article);

                return(RedirectToAction("Article", new { slugArticle = article.Slug }));
            }
            return(View(article));
        }