Esempio n. 1
0
        public MediaVote GetMediaFilm(int idFilm)
        {
            ServiceVote = new VoteService(_context);
            MediaVote media = ServiceVote.GetMovieScoreMedia(idFilm);

            return(media);
        }
Esempio n. 2
0
        public List <MediaVote> GetMoviesScoreMedia()
        {
            var votes = _context.Votes.ToList();

            _context.Actors.ToList();
            _context.Directors.ToList();
            List <MediaVote> listMedia = new List <MediaVote>();
            MediaVote        media;
            var films = _context.Films.ToList();

            foreach (var film in films)
            {
                var mediaVotos = votes
                                 .Where(x => x.Film.Id == film.Id)
                                 .Average(x => (int)x.Classification);
                media             = new MediaVote();
                media.Film        = film;
                media.Punctuation = Math.Round(mediaVotos);

                listMedia.Add(media);
            }

            var listaOrdenada = listMedia.GroupBy(x => new { x.Film.Name, x.Punctuation })
                                .Select(group => new
            {
                group.Key.Name,
                group.Key.Punctuation
            })
                                .OrderBy(ord => new { ord.Name, ord.Punctuation });

            return(listMedia);
        }
Esempio n. 3
0
        public MediaVote GetMovieScoreMedia(int idFilm)
        {
            var votes = _context.Votes
                        .Where(f => f.Film.Id == idFilm).ToList();

            var mediaVotes = votes.Average(x => (int)x.Classification);

            _context.Actors.ToList();
            _context.Directors.ToList();

            MediaVote media = new MediaVote();

            media.Punctuation = Math.Round(mediaVotes);
            media.Film        = _context.Films
                                .FirstOrDefault(f => f.Id == idFilm);
            return(media);
        }