public void InsertOrUpdate(Review review)
 {
     if (review.ID == default(int)) {
         // New entity
         context.Reviews.Add(review);
     } else {
         // Existing entity
         context.Entry(review).State = EntityState.Modified;
     }
 }
 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();
     }
 }
        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();
            ReviewCreated(this, new MovieReviewUpdatedEventArgs { MovieID = data.MovieID });
            return RedirectToAction("View", new { id = review.ID });
        }