public IActionResult DeleteReview(UserReviewApiModel userReview)
        {
            var review         = context.Review.FirstOrDefault(a => a.IdReview == userReview.IdReview);
            var userReviewList = context.UserReview.Where(a => a.ReviewId == userReview.IdReview).ToList();
            var responseList   = context.Review.Where(a => a.IdResponse == userReview.IdReview).ToList();

            if (review != null)
            {
                if (userReviewList.Count > 0)
                {
                    foreach (var item in userReviewList)
                    {
                        context.Remove(item);
                    }
                }

                if (responseList.Count > 0)
                {
                    foreach (var item in responseList)
                    {
                        context.Remove(item);
                    }
                }
                context.Remove(review);

                context.SaveChanges();
                return(Ok("Opinia została usunięta"));
            }


            return(Ok("Opinia jest już usunięta"));
        }
        public async Task <ApiResponse <Review> > DownVote(UserReviewApiModel userReview)
        {
            var errorResponse = new ApiResponse <Review>
            {
                // Set error message
                ErrorMessage = "Coś poszło nie tak!"
            };

            if (userReview.Action == 0)
            {
                var review       = context.Review.Where(a => a.IdReview == userReview.IdReview).FirstOrDefault();
                var userIdentity = await mUserManager.FindByNameAsync(userReview.Username);

                review.Points -= 1;
                UserReview userDownvote = new UserReview();
                userDownvote.UserId   = userIdentity.Id;
                userDownvote.ReviewId = review.IdReview;
                userDownvote.Vote     = 2;

                context.UserReview.Add(userDownvote);

                context.SaveChanges();
                review.Vote = 2;

                return(new ApiResponse <Review>
                {
                    Response = new Review
                    {
                        Author = review.Author,
                        Review1 = review.Review1,
                        IdMovies = review.IdMovies,
                        Points = review.Points,
                        UserId = userIdentity.Id,
                        IdReview = review.IdReview,
                        Vote = review.Vote,
                        IdResponse = review.IdResponse
                    }
                });
            }
            else if (userReview.Action == 1)
            {
                var checkVote = (from a in context.UserReview
                                 join b in context.Users on a.User.UserName equals userReview.Username
                                 join c in context.Review on a.ReviewId equals userReview.IdReview
                                 select new
                {
                    checkVote = a,
                    userIdentity = a.User,
                    review = a.Review
                }).FirstOrDefault();

                checkVote.checkVote.Vote = 2;
                checkVote.review.Points -= 2;

                context.SaveChanges();
                checkVote.review.Vote = 2;

                return(new ApiResponse <Review>
                {
                    Response = new Review
                    {
                        Author = checkVote.review.Author,
                        Review1 = checkVote.review.Review1,
                        IdMovies = checkVote.review.IdMovies,
                        Points = checkVote.review.Points,
                        UserId = checkVote.userIdentity.Id,
                        IdReview = checkVote.review.IdReview,
                        Vote = checkVote.review.Vote,
                        IdResponse = checkVote.review.IdResponse
                    }
                });
            }
            else if (userReview.Action == 2)
            {
                var checkVote = (from a in context.UserReview
                                 join b in context.Users on a.User.UserName equals userReview.Username
                                 join c in context.Review on a.ReviewId equals userReview.IdReview
                                 select new
                {
                    checkVote = a,
                    userIdentity = a.User,
                    review = a.Review
                }).FirstOrDefault();

                context.UserReview.Remove(checkVote.checkVote);
                checkVote.review.Points += 1;
                context.SaveChanges();
                checkVote.review.Vote = 0;

                return(new ApiResponse <Review>
                {
                    Response = new Review
                    {
                        Author = checkVote.review.Author,
                        Review1 = checkVote.review.Review1,
                        IdMovies = checkVote.review.IdMovies,
                        Points = checkVote.review.Points,
                        UserId = checkVote.userIdentity.Id,
                        IdReview = checkVote.review.IdReview,
                        Vote = checkVote.review.Vote,
                        IdResponse = checkVote.review.IdResponse
                    }
                });
            }

            return(errorResponse);
        }