public ActionResult Add() { var addPostViewModel = new ModeratorAddPostViewModel { Categories = this.populator.GetCategories() }; return(View(addPostViewModel)); }
public ActionResult Add(ModeratorAddPostViewModel viewModel) { if (viewModel != null && ModelState.IsValid) { var userId = this.User.Identity.GetUserId(); this.moderatorPosts.AddDbPost(viewModel, userId); this.TempData["Message"] = string.Format(GlobalConstants.SuccessMessage, " Added Post."); return(this.RedirectToAction("Index", "ModeratorPosts", new { area = "Moderator" })); } this.TempData["Message"] = string.Format(GlobalConstants.FailMessage, " Added Post."); viewModel.Categories = this.populator.GetCategories(); return(this.View(viewModel)); }