public async Task <IActionResult> Create(PublishOrEditArticleFormModel model) { model.Content = this.htmlService.Sanitize(model.Content); var userId = this.userManager.GetUserId(User); await this.articleService.CreateAsync(model.Title, model.Content, userId); TempData.AddSuccessMessage($"Successfully created new article {model.Title}."); await this.logService.CreateLogAsync(User.Identity.Name, LogType.CreateArticle, model.Title); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, PublishOrEditArticleFormModel model) { var article = await this.articleService.ById(id); if (article == null) { return(RedirectToAction(nameof(Index))); } var oldTitle = article.Title; await this.articleService.UpdateArticleAsync(id, model.Title, model.Content); TempData.AddSuccessMessage($"Successfully edited article {oldTitle}."); await this.logService.CreateLogAsync(User.Identity.Name, LogType.EditArticle, model.Title); return(RedirectToAction(nameof(Details), new { id = id })); }