Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ArticlesController : Controller
- {
- private readonly IArticleService articleService;
- public ArticlesController(IArticleService articleService)
- => this.articleService = articleService;
- [HttpGet]
- [Authorize]
- public IActionResult Create() => this.View();
- [HttpPost]
- [Authorize]
- public async Task<IActionResult> Create(ArticleFormModel article)
- {
- if (this.ModelState.IsValid)
- {
- await this.articleService.Add(article.Title, article.Content, this.User.GetId());
- this.TempData.Add(ControllerConstants.SuccessMessage, "Article created successfully it is waiting for approval!");
- return this.RedirectToAction(nameof(UsersController.Mine), ControllerConstants.Users);
- }
- return this.View(article);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement