예제 #1
0
        public ActionResult Add()
        {
            var addPostViewModel = new ModeratorAddPostViewModel
            {
                Categories = this.populator.GetCategories()
            };

            return(View(addPostViewModel));
        }
예제 #2
0
        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));
        }