Exemple #1
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            var dto = ObjectMapper.Map <CreateEditCommentViewModel, CreateUpdateCommentDto>(ViewModel);
            await _service.CreateAsync(dto);

            return(NoContent());
        }
        public async Task Should_Create_A_Comment()
        {
            var postId  = (await _postRepository.GetListAsync()).First().Id;
            var content = "test content";

            var commentWithDetailsDto = await _commentAppService.CreateAsync(new CreateCommentDto()
            {
                PostId = postId, Text = content
            });

            UsingDbContext(context =>
            {
                var comment = context.Comments.FirstOrDefault(q => q.Id == commentWithDetailsDto.Id);
                comment.ShouldNotBeNull();
                comment.Text.ShouldBe(commentWithDetailsDto.Text);
            });
        }
 public Task <CommentWithDetailsDto> CreateAsync(CreateCommentDto input)
 {
     return(_commentAppService.CreateAsync(input));
 }
 public Task <CommentDto> CreateAsync(CreateUpdateCommentDto input)
 {
     return(_service.CreateAsync(input));
 }