Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateReview(ReviewRequestModel updateReview)
        {
            updateReview.UserId = (int)_currentUserService.UserId;
            var review = await _userService.UpdateReview(updateReview);

            return(Ok(review));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> WriteReview([FromBody] ReviewRequestModel model)
        {
            model.UserId = _currentUserService.Id ?? 0;
            var review = await _reviewService.WriteReview(model);

            return(Ok(review));
        }
Ejemplo n.º 3
0
        public async Task AddMovieReview(ReviewRequestModel reviewRequest)
        {
            var rev = new Review();

            PropertyCopy.Copy(rev, reviewRequest);
            var res = await _reviewRepo.AddAsync(rev);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Audit(int id, [FromBody] ReviewRequestModel model)
        {
            if (id <= 0 || model == null)
            {
                return(BadRequest(ResultModel.Fail <ReviewRequestModel>("请求参数异常")));
            }
            //
            //if (model.State == ReviewState.UnReviewed)
            //{
            //    return BadRequest(ResultModel.Fail<ReviewRequestModel>("审核状态不能为待审核"));
            //}

            var merchant = await _repository.FindAsync(id);

            if (null == merchant)
            {
                return(NotFound(ResultModel.Fail <ReviewRequestModel>($"商户不存在, Id:{id}")));
            }

            merchant.State  = model.State;
            merchant.Remark = model.Remark;

            await _repository.UpdateAsync(merchant);

            return(Ok(ResultModel.Success(model)));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> AddReview(ReviewRequestModel newReview)
        {
            newReview.UserId = (int)_currentUserService.UserId;
            var review = await _userService.AddReview(newReview);

            return(Ok(review));
        }
Ejemplo n.º 6
0
        public async Task <Review> UpdateReview(ReviewRequestModel review)
        {
            var updateReview = new Review {
                MovieId = review.MovieId, UserId = review.UserId, ReviewText = review.ReviewText, Rating = review.Rating
            };

            return(await _reviewRepository.UpdateAsync(updateReview));
        }
Ejemplo n.º 7
0
        public async Task Review(ReviewRequestModel requestModel)
        {
            // var userId = Convert.ToInt32(HttpContext.User.Claims
            //     .FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value);
            var userId = _currentUserService.Id ?? 0;

            requestModel.UserId = userId;
            await _reviewService.WriteReview(requestModel);
        }
Ejemplo n.º 8
0
        public async Task <Review> UpdateReview(ReviewRequestModel requestModel)
        {
            var review = new Review
            {
                UserId     = requestModel.UserId, MovieId = requestModel.MovieId, Rating = requestModel.Rating,
                ReviewText = requestModel.ReviewText
            };

            return(await _reviewRepository.UpdateAsync(review));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> UserUpdateReview(ReviewRequestModel model)
        {
            if (ModelState.IsValid)
            {
                await _userService.UpdateMovieReview(model);

                return(Ok());
            }
            return(BadRequest("Please check the info you entered"));
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> UpdateReview(ReviewRequestModel reviewRequest)
        {
            if (ModelState.IsValid)
            {
                await _userService.UpdateMovieReview(reviewRequest);

                return(Ok());
            }
            return(BadRequest(new { message = "please correct the input information" }));
        }
Ejemplo n.º 11
0
        public async Task UpdateMovieReview(ReviewRequestModel reviewRequest)
        {
            var res = await _reviewRepo.ListAsync(f => f.UserId == reviewRequest.UserId && f.MovieId == reviewRequest.MovieId);

            Review rev = res.First();

            rev.ReviewText = reviewRequest.ReviewText;
            rev.Rating     = reviewRequest.Rating;
            await _reviewRepo.UpdateAsync(rev);
        }
Ejemplo n.º 12
0
        public async Task AddMovieReview(ReviewRequestModel reviewRequest)
        {
            if (_currentUserService.UserId != reviewRequest.UserId)
            {
                throw new HttpException(HttpStatusCode.Unauthorized, "You are not Authorized to Review");
            }

            var review = _mapper.Map <Review>(reviewRequest);
            await _reviewRepository.AddAsync(review);
        }
Ejemplo n.º 13
0
        public async Task UpdateMovieReview(ReviewRequestModel reviewRequest)
        {
            var dbReview = await _reviewRepository.ListAsync(r => r.UserId == reviewRequest.UserId && r.MovieId == reviewRequest.MovieId);

            Review review = dbReview.FirstOrDefault();

            review.Rating     = reviewRequest.Rating;
            review.ReviewText = reviewRequest.ReviewText;
            await _reviewRepository.UpdateAsync(review);
        }
Ejemplo n.º 14
0
 public async Task UpdateMovieReview(ReviewRequestModel reviewRequest)
 {
     var review = new Review
     {
         MovieId    = reviewRequest.MovieId,
         UserId     = reviewRequest.UserId,
         Rating     = reviewRequest.Rating,
         ReviewText = reviewRequest.ReviewText
     };
     await _reviewRepository.UpdateAsync(review);
 }
Ejemplo n.º 15
0
 public async Task AddMovieReview(ReviewRequestModel reviewRequest)
 {
     var review = new Review()
     {
         MovieId    = reviewRequest.MovieId,
         Rating     = (decimal)reviewRequest.Rating,
         ReviewText = reviewRequest.ReviewText,
         UserId     = reviewRequest.UserId
     };
     await _reviewRepository.AddAsync(review);
 }
Ejemplo n.º 16
0
        public async Task <IActionResult> Review(ReviewRequestModel reviewRequestModel)
        {
            reviewRequestModel.UserId = Convert.ToInt32(HttpContext.User.Claims.
                                                        FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);

            var movie = await _movieService.GetMovieById(reviewRequestModel.MovieId);

            var movieReview = await _userService.Review(reviewRequestModel);

            return(LocalRedirect("~/User/Reviews"));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> UpdateReview(ReviewRequestModel reviewRequestModel)
        {
            if (ModelState.IsValid)
            {
                var review = await _userService.UpdateMovieReview(reviewRequestModel);

                return(Ok(review));
            }

            return(BadRequest(new { Message = "Incorrect data in Review" }));
        }
Ejemplo n.º 18
0
 public async Task AddMovieReview(ReviewRequestModel reviewRequest)
 {
     var movieReview = new Review
     {
         UserId     = reviewRequest.UserId,
         MovieId    = reviewRequest.MovieId,
         Rating     = reviewRequest.Rating,
         ReviewText = reviewRequest.ReviewText
     };
     await _reviewRepository.AddAsync(movieReview);
 }
Ejemplo n.º 19
0
 public async Task AddReview(ReviewRequestModel reviewRequestModel)
 {
     var review = new Review
     {
         MovieId    = reviewRequestModel.MovieId,
         UserId     = reviewRequestModel.UserId,
         Rating     = reviewRequestModel.Rating,
         ReviewText = reviewRequestModel.ReviewText,
     };
     await _reviewRepository.AddAsync(review);
 }
Ejemplo n.º 20
0
 public async Task AddMovieReview(ReviewRequestModel reviewRequest)
 {
     var review = new Review
     {
         MovieId    = reviewRequest.MovieId,
         UserId     = reviewRequest.UserId,
         Rating     = reviewRequest.Rating,
         ReviewText = reviewRequest.ReviewText
     };
     var createdReview = await _reviewRepository.AddAsync(review);
 }
Ejemplo n.º 21
0
        public async Task <IActionResult> Review(ReviewRequestModel reviewRequestModel, string returnUrl = null)
        {
            returnUrl ??= Url.Content("~/");
            if (!ModelState.IsValid)
            {
                return(View());
            }
            await _userService.AddMovieReview(reviewRequestModel);

            return(LocalRedirect(returnUrl));
        }
Ejemplo n.º 22
0
        public async Task UpdateMovieReview(ReviewRequestModel reviewRequest)
        {
            var rev = new Review
            {
                UserId     = reviewRequest.userId,
                MovieId    = reviewRequest.movieId,
                Rating     = (decimal?)reviewRequest.rating,
                ReviewText = reviewRequest.reviewTest
            };

            await _reviewRepository.UpdateAsync(rev);
        }
Ejemplo n.º 23
0
        public async Task <bool> ReviewMovie(ReviewRequestModel reviewRequestModel, int userId, int movieId)
        {
            var newReview = new Review
            {
                MovieId    = movieId,
                UserId     = userId,
                ReviewText = reviewRequestModel.ReviewText,
                Rating     = reviewRequestModel.Rating
            };
            var result = await _reviewRepository.AddAsync(newReview);

            return(result != null);
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> Review(int id)
        {
            var movie = await _movieService.GetMovieById(id);

            ReviewRequestModel reviewRequestModel = new ReviewRequestModel
            {
                MovieId = movie.Id,
                PostUrl = movie.PosterUrl,
                Title   = movie.Title
            };

            return(View(reviewRequestModel));
        }
Ejemplo n.º 25
0
 public async Task AddMovieReview(ReviewRequestModel reviewRequest)
 {
     /*
      * if (_currentUserService.UserId != id)
      *     throw new HttpException(HttpStatusCode.Unauthorized, "You are not Authorized to View Purchases");
      */
     var review = new Review {
         UserId     = reviewRequest.UserId,
         MovieId    = reviewRequest.MovieId,
         ReviewText = reviewRequest.reviewText,
         Rating     = reviewRequest.Rating
     };
     await _reviewRepository.AddAsync(review);
 }
Ejemplo n.º 26
0
 public async Task AddMovieReview(ReviewRequestModel reviewRequestModel)
 {
     if (_currentLogedInUser.UserId != reviewRequestModel.UserId)
     {
         throw new ConfilictException("You are not Authorized to Review");
     }
     var review = new Review
     {
         MovieId    = reviewRequestModel.MovieId,
         UserId     = reviewRequestModel.UserId,
         Rating     = reviewRequestModel.Rating,
         ReviewText = reviewRequestModel.ReviewText,
     };
     await _reviewRepository.AddAsync(review);
 }
Ejemplo n.º 27
0
        public async Task UpdateMovieReview(ReviewRequestModel reviewRequest)
        {
            if (_currentUserService.UserId != reviewRequest.UserId)
            {
                throw new HttpException(HttpStatusCode.Unauthorized, "You are not Authorized to Review");
            }
            var review = new Review()
            {
                MovieId    = reviewRequest.MovieId,
                UserId     = reviewRequest.UserId,
                Rating     = reviewRequest.Rating,
                ReviewText = reviewRequest.ReviewText,
            };

            await _reviewRepository.UpdateAsync(review);
        }
Ejemplo n.º 28
0
        private Review ReviewRequestToRev(ReviewRequestModel reviewRequest)
        {
            if (reviewRequest == null)
            {
                return(null);
            }
            Review ret = new Review
            {
                MovieId    = reviewRequest.MovieId,
                UserId     = reviewRequest.UserId,
                Rating     = reviewRequest.Rating,
                ReviewText = reviewRequest.ReviewText
            };

            return(ret);
        }
Ejemplo n.º 29
0
        public async Task EditReview(ReviewRequestModel reviewRequestModel)
        {
            var dbReview = _reviewRepository.GetExistsAsync(r => r.MovieId == reviewRequestModel.MovieId && r.UserId == reviewRequestModel.UserId).Result;

            if (!dbReview)
            {
                throw new NotFoundException("Review Not exists");
            }
            var review = new Review
            {
                UserId     = reviewRequestModel.UserId,
                MovieId    = reviewRequestModel.MovieId,
                Rating     = reviewRequestModel.Rating,
                ReviewText = reviewRequestModel.ReviewText,
            };
            await _reviewRepository.UpdateAsync(review);
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> Review(ReviewRequestModel reviewRequestModel, int movieId)
        {
            try
            {
                int  userId = _currentLogedInUser.UserId;
                bool result = await _userService.ReviewMovie(reviewRequestModel, userId, movieId);

                if (result)
                {
                    return(View("ReviewSuccess"));
                }
                return(View("ReviewFail"));
            }
            catch (Exception e)
            {
                return(View("ReviewFail"));
            }
        }