public async Task <PostCommentResponseDto> CreateAndReturnDtoAsync( NewCommentResponseDto commentResponseDto, int authorId, IFormFile file) { string imagePath; if (file != null) { imagePath = await _imageSaver .SaveAndReturnImagePath(file, "ResponseToCommentResponse", commentResponseDto.CommentId); } var responseToResponse = new ResponseToComment { Comment = new Models.Comment() { Content = commentResponseDto.Content, UserId = authorId, PostId = commentResponseDto.PostId, Date = DateTime.Now }, ResponseToCommentId = null, MainCommentId = commentResponseDto.CommentId }; _repository.ResponseToComment.Add(responseToResponse); await _repository.SaveAsync(); return(await _repository.ResponseToComment.GetByIdAsync(responseToResponse.Id, PostCommentResponseDto.Selector(authorId))); }
public async Task <IActionResult> Create( [FromBody] NewCommentResponseDto responseDto, [FromForm] IFormFile file, [FromHeader(Name = "userId")] int userId) { var createdEntry = await _commentResponseService.CreateAndReturnDtoAsync (responseDto, userId, file); return(CreatedAtAction("Create", createdEntry)); }