public void InsertMovie(Int32 movieId, User user)
 {
     using (var ctx = new DatabaseContext())
     {
         user = ctx.User.Where(x => x.Email.ToLower().Equals(user.Email.ToLower())).FirstOrDefault();
         ctx.UserCollection.Add(new UserCollection() { User = user, MovieId = movieId });
         ctx.SaveChanges();
     }
 }
 public void InsertMovieCommentary(User user, int movieId, int rate, string comment)
 {
     using (var ctx = new DatabaseContext())
     {
         user = ctx.User.Where(x => x.Email.ToLower().Equals(user.Email.ToLower())).FirstOrDefault();
         ctx.Review.Add(new Review() { User = user, MovieId = movieId, Note = rate, Commentary = comment, ReviewDate = DateTime.Now });
         ctx.SaveChanges();
     }
 }
        public bool Insert(User user)
        {
            using (var ctx = new DatabaseContext())
            {
                ctx.User.Add(user);
                int result = ctx.SaveChanges();

                return result >= 1;
            }
        }
        public void RemoveMovieFromUser(int id, User user)
        {
            using (var ctx = new DatabaseContext())
            {
                var item = ctx.UserCollection.Where(x => x.User.Id == user.Id && x.MovieId == id).FirstOrDefault();

                if (item == null)
                    throw new MovieRepositoryException("Filme não encontrado na lista.");

                ctx.UserCollection.Remove(item);
                ctx.SaveChanges();
            }
        }