public async Task <IActionResult> Create() { var viewModel = new PostsCreateInputModel { Tags = await this.tagsService.GetAllAsync <PostsTagsDetailsViewModel>(), Categories = await this.categoriesService.GetAllAsync <PostsCategoryDetailsViewModel>() }; return(this.View(viewModel)); }
public async Task <IActionResult> Create(PostsCreateInputModel input) { if (!this.ModelState.IsValid) { input.Categories = await this.categoriesService.GetAllAsync <PostsCategoryDetailsViewModel>(); input.Tags = await this.tagsService.GetAllAsync <PostsTagsDetailsViewModel>(); return(this.View(input)); } var postId = await this.postsService.CreateAsync( input.Title, input.PostType, input.Description, this.User.GetId(), input.CategoryId, input.TagIds); return(this.RedirectToAction(nameof(Details), new { id = postId })); }