public void UpdateMovieStatus(User user, int movieId, State state)
 {
     var userMovie = user.UserMovies.FirstOrDefault(um => um.MovieId == movieId);
     userMovie.State = state;
     this.userMoviesRepository.Update(userMovie);
     this.userMoviesRepository.SaveChanges();
 }
 public void UpdateMovieRating(User user, int movieId, int rating)
 {
     var movie = movies.Find(movieId);
     var count = movie.CountRating + 1;
     var currentRating = movie.Rating;
     movie.Rating = (rating + currentRating) / count;
     this.movies.Update(movie);
     this.movies.SaveChanges();
 }
        public void Add(User user, int id, string text)
        {
            var newComment = new Comment()
            {
                MovieId = id,
                Text = text,
                DateAdded = DateTime.Now,
                UserId = user.Id
            };

            this.commentsRepository.Add(newComment);
            this.commentsRepository.SaveChanges();
        }
        public void Add(User user, int movieId, State state)
        {
            //validation if user already has this movie
            var newUserMovie = new UserMovies()
            {
                MovieId = movieId,
                State = state,
                UserId = user.Id,
                DateAdded = DateTime.Now
            };

            this.userMoviesRepository.Add(newUserMovie);
            this.userMoviesRepository.SaveChanges();
        }
 public void RemoveMovie(User user, int movieId)
 {
     var userMovie = user.UserMovies.FirstOrDefault(um => um.MovieId == movieId);
     this.userMoviesRepository.Delete(userMovie);
     this.userMoviesRepository.SaveChanges();
 }
 public Movie GetMovieById(int id, User user)
 {
     var userMovie = user.UserMovies.FirstOrDefault(um => um.MovieId == id);
     return userMovie.Movie;
 }
 public IQueryable<UserMovies> GetAllWatchedMoviesByUser(User user)
 {
     return this.GetAllMoviesByUser(user)
             .Where(userMovie => userMovie.State == State.Watched);
 }
 public IQueryable<UserMovies> GetAllMoviesByUser(User user)
 {
     return user.UserMovies.AsQueryable()
         .OrderByDescending(userMovie => userMovie.DateAdded);
 }