示例#1
0
        public async Task <CommentPutDTO> PostComment(CommentPutDTO commentPostDTO)
        {
            if (commentPostDTO == null)
            {
                throw new ArgumentNullException(nameof(commentPostDTO));
            }

            var commentResult = _context.Comments.Add(new Comment()
            {
                CommentText = commentPostDTO.CommentText,
                Date        = commentPostDTO.Date,
                MovieId     = commentPostDTO.MovieId,
                UserId      = commentPostDTO.UserId
            });

            await _context.SaveChangesAsync().ConfigureAwait(false);

            commentPostDTO.Id = commentResult.Entity.Id;

            return(commentPostDTO);
        }
示例#2
0
 public Task <CommentPutDTO> PutComment(int id, CommentPutDTO commentPutDTO)
 {
     throw new NotImplementedException();
 }
示例#3
0
        public async Task <ActionResult <Comment> > PostComment(CommentPutDTO commentPutDTO)
        {
            var commentResult = await _commentRepository.PostComment(commentPutDTO).ConfigureAwait(false);

            return(CreatedAtAction("GetComment", new { id = commentResult.Id }, commentResult));
        }