Пример #1
0
 public ActionResult Create(Review review)
 {
     if (ModelState.IsValid) {
         reviewRepository.InsertOrUpdate(review);
         reviewRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleMovies = movieRepository.All;
         ViewBag.PossibleUsers = userRepository.All;
         return View();
     }
 }
Пример #2
0
        public ActionResult CreateFor(CreateReviewInputModel data)
        {
            var movie = _movieRepository.Find(data.MovieID);

            if (!CanReviewerReviewGenre(movie.Genres))
            {
                return View("InvalidGenre", PrepareInvalidGenreViewModel(movie.Genres));
            }

            var review = new Review
            {
                MovieID = data.MovieID,
                Comment = data.Comment,
                Stars = data.Stars,
                ReviewDate = DateTime.Now,
                UserID = _currentUser.Username
            };
            _reviewRepository.InsertOrUpdate(review);
            _reviewRepository.Save();
            return RedirectToAction("View", new { id = review.ID });
        }