Esempio n. 1
0
        public void Rate(View.Rating rating)
        {
            // Find movie
            var movie = DB.Movies
                        .Include(m => m.Ratings)
                        .FirstOrDefault(m => m.Id == rating.MovieId);

            // If the movie exists add the rating
            if (movie != null)
            {
                var rat = movie.Ratings.FirstOrDefault(r => r.Username == rating.Username);
                if (rat == null)
                {
                    movie.Ratings.Add(new Rating()
                    {
                        Username    = rating.Username,
                        MovieId     = rating.MovieId,
                        RatingValue = rating.Value,
                        Date        = rating.Date,
                    });
                }
                else
                {
                    rat.Date        = rating.Date;
                    rat.RatingValue = rating.Value;
                }
            }
            DB.SaveChanges();
        }
Esempio n. 2
0
 public void Rate(View.Rating rating)
 {
     throw new NotImplementedException();
 }