Ejemplo n.º 1
0
        public IActionResult Create(int id)
        {
            var post = this.postsService.GetById <ReplyPostViewModel>(id);

            if (post == null)
            {
                return(this.NotFound());
            }

            var viewModel = new ReplyCreateViewModel
            {
                Post = post,
            };

            return(this.View(viewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(ReplyCreateViewModel input)
        {
            if (!this.ModelState.IsValid)
            {
                var post = this.postsService.GetById <ReplyPostViewModel>(input.PostId);

                input.Post = post;

                return(this.View(input));
            }

            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            await this.repliesService.CreateAsync(input.PostId, userId, input.Content);

            this.TempData["InfoMessage"] = "Reply created successfully!";
            return(this.RedirectToAction("ByName", "Posts", new { name = input.PostUrl }));
        }