Exemple #1
0
        public async Task CreateCommentAsync(string creatorId, CommentCreationBindingModel model)
        {
            var comment = this.Mapper.Map <Comment>(model);

            comment.CreatorId = creatorId;

            await this.Context.Comments.AddAsync(comment);

            this.Context.SaveChanges();
        }
Exemple #2
0
        public async Task <IActionResult> Add(CommentCreationBindingModel model)
        {
            var userId = this.userManager.GetUserId(this.User);

            await this.commentService.CreateCommentAsync(userId, model);

            this.TempData.Put("__Message", new MessageModel()
            {
                Type    = MessageType.Info,
                Message = "Comment created successfully"
            });

            return(RedirectToPage("/Comments/All", new { id = model.PostId }));
        }
Exemple #3
0
        public async Task <IActionResult> Add(int id)
        {
            var post = await this.postService.GetPostAsync(id);

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

            var model = new CommentCreationBindingModel()
            {
                PostId   = post.Id,
                PostName = post.Name
            };

            return(View(model));
        }