public async Task <IActionResult> Create(int articleId, CreateSubarticleViewModel model) { if (ModelState.IsValid) { var identityUser = await _userManager.GetUserAsync(HttpContext.User); var userRoles = await _userManager.GetRolesAsync(identityUser); var result = await Mediator.Send(new CreateSubarticleCommand() { ArticleId = articleId, Content = model.Content, Title = model.Title, UserRoles = userRoles, }); if (result.IsSuccessful) { return(RedirectToAction("GetArticle", "Article", new { id = articleId })); } else { ModelState.AddModelError("", result.Message); } } return(View()); }
public IActionResult Create(int articleId) { CreateSubarticleViewModel model = new CreateSubarticleViewModel { ArticleId = articleId, }; return(View(model)); }