public async Task <IActionResult> Edit(PublishArticleBindingModel model) { var userId = this.userManager.GetUserId(this.User); var userPermissions = await this.articlesService.IsArticleFromUserAsync(model.Id, userId); if (!userPermissions) { TempData.AddInfoMessage(WebConstants.UserNoPermissionsEdit); return(this.RedirectToAction(nameof(Index))); } model.Content = this.htmlServise.Sanitize(model.Content); var article = this.mapper.Map <ArticleFormModel>(model); var result = await this.articlesService.EditAsync(article); if (!result) { TempData.AddErrorMessage(WebConstants.PublishArticleError); return(this.View(model)); } TempData.AddSuccessMessage(WebConstants.PublishArticleSuccess); return(this.RedirectToAction( nameof(TeachTheChild.Web.Controllers.ArticlesController.Details), "Articles", new { area = "", id = model.Id, title = model.Title.ToFriendlyUrl() })); }
public ActionResult Wizard(SampleWizardModel model) { if (ModelState.IsValid) { TempData.AddSuccessMessage("Model was saved successfully"); TempData.AddErrorMessage("Model wasn't saved successfully"); TempData.AddInfoMessage("This is just information"); return(RedirectToAction("Wizard")); } return(View(model)); }
public async Task <IActionResult> Edit(int id) { var userId = this.userManager.GetUserId(this.User); var userPermissions = await this.articlesService.IsArticleFromUserAsync(id, userId); if (!userPermissions) { TempData.AddInfoMessage(WebConstants.UserNoPermissionsEdit); return(this.RedirectToAction(nameof(Index))); } var article = await this.articlesService.GetByIdAsync(id); if (article == null) { return(this.NotFound()); } var model = this.mapper.Map <PublishArticleBindingModel>(article); return(this.View(model)); }