//id - article id public ActionResult Edit(int id, ArticleFormViewModel model) { UserEntity currentUser = userService.GetByLogin(Request.GetCurrentUserLogin()); if (currentUser.Ban) return RedirectToAction("BanPage", "Account"); if (User.IsInRole("Admin")||articleService.IsUserAuthor(id, currentUser.Id)) { articleService.Edit(new ArticleEntity() { Content = model.Content, Id = id,Title=model.Title }, model.Tags); return RedirectToAction("Show", "Article", new { id = id }); } return RedirectToAction("Index", "Home"); }
public ActionResult Create(ArticleFormViewModel articleModel) { if (ModelState.IsValid) { UserEntity currentUser = userService.GetByLogin(Request.GetCurrentUserLogin()); if (currentUser.Ban) return RedirectToAction("BanPage", "Account"); articleService.CreateArticle( new ArticleEntity() { AuthorId = currentUser.Id, Content = articleModel.Content, Title = articleModel.Title, }, articleModel.Tags); return RedirectToAction("Index", "Home"); } return View(articleModel); }