Esempio n. 1
0
        public async Task <ActionResult <int> > Delete(int reviewCommentId)
        {
            int applicationUserId = int.Parse(User.Claims.First(i => i.Type == JwtRegisteredClaimNames.NameId).Value);

            var foundReviewComment = await _reviewCommentRepository.GetAsync(reviewCommentId);

            if (foundReviewComment == null)
            {
                return(BadRequest("Comment does not exist."));
            }

            if (foundReviewComment.ApplicationUserId == applicationUserId)
            {
                var affectedRows = await _reviewCommentRepository.DeleteAsync(reviewCommentId);

                return(Ok(affectedRows));
            }
            else
            {
                return(BadRequest("This comment was not created by the current user."));
            }
        }
Esempio n. 2
0
 public async Task DeleteAsync(int id)
 {
     await repo.DeleteAsync(id);
 }