public IActionResult CreatePost()
        {
            var forumCategories = this.forumCategoriesService.AllCategories <ForumCategoryDropDownViewModel>();
            var viewModel       = new ForumPostCreateInputModel
            {
                ForumCategories = forumCategories,
            };

            return(this.View(viewModel));
        }
Exemplo n.º 2
0
        public IActionResult Create()
        {
            var categories = this.categoriesService.GetAll <CategoryDropDownViewModel>();
            var viewModel  = new ForumPostCreateInputModel
            {
                Categories = categories,
            };

            return(this.View(viewModel));
        }
        public async Task <IActionResult> CreatePost(ForumPostCreateInputModel input)
        {
            var user = await this.userManager.GetUserAsync(this.User);

            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var postId = await this.forumPostsService.CreatePostAsync(input.Title, input.Content, input.ForumCategoryId, user.Id);

            this.TempData["InfoMessage"] = "Forum post created!";
            return(this.RedirectToAction(nameof(this.GetPostById), new { id = postId }));
        }