public void Report_Click(object sender, EventArgs e)
        {
            IQueryable<ISong> songs;

            var link = (LinkButton)sender;

            if (link.CommandArgument.Length == 1)
            {
                songs = songService.GetSongsByFirstLetter(link.CommandArgument);
            }
            else
            {
                songs = songService.GetSongsByAlbum(link.CommandArgument);
            }

            var results = new FavoriteLiveSongList().GenerateFavoriteLiveSongList(songs);

            if (results == null || results.Count() <= 0)
                return;

            var final = FavoriteLiveSongList.GetRepeaterUsableList(results);

            if (link.CommandName == "Favorite")
            {
                SetFavorites(final);
            }
            else if (link.CommandName == "Highest")
            {
                SetHighest(final);
            }
        }
Exemple #2
0
        private FavoriteLiveSongList GetAnalysisPart(Song song)
        {
            var setSongService  = new SetSongService(Ioc.GetInstance <ISetSongRepository>());
            var analysisService = new AnalysisService(Ioc.GetInstance <IAnalysisRepository>());
            var songService     = new SongService(Ioc.GetInstance <ISongRepository>());

            //Get all Analysis for that Song but in groups of SetSong
            var analysis = analysisService.GetAnalysisBySong(song.SongId).GroupBy(x => x.SetSongId);

            double      highestRating = 0;
            double?     rating        = 0;
            List <Guid> setSongIds    = new List <Guid>();

            //If there are no analysis then there is nothing to see here
            if (analysis.Count() == 0)
            {
                return(null);
            }

            var fave = new FavoriteLiveSongList(SetSong.FromSong(song));

            //If there are 1 or more analysis then we need to find out which is the highest ranked
            foreach (var a in analysis)
            {
                rating = a.Average(x => x.Rating);
                var setSongId = a.First().SetSongId;

                if (rating.HasValue && rating.Value > highestRating)
                {
                    highestRating          = rating.Value;
                    fave.HighestRatedShows = new List <Show>();

                    var setSong = (SetSong)setSongService.GetSetSong(setSongId);
                    var show    = GetShowFromSetSong(setSongId);
                    fave.HighestRatedShows.Add(show);
                }
                else if (rating.HasValue && rating.Value == highestRating)
                {
                    var setSong = (SetSong)setSongService.GetSetSong(setSongId);
                    var show    = GetShowFromSetSong(setSongId);

                    fave.HighestRatedShows.Add(show);
                }
            }

            fave.HighestRating = highestRating;

            return(fave);
        }
        private FavoriteLiveSongList GetAnalysisPart(Song song)
        {
            var setSongService = new SetSongService(Ioc.GetInstance<ISetSongRepository>());
            var analysisService = new AnalysisService(Ioc.GetInstance<IAnalysisRepository>());
            var songService = new SongService(Ioc.GetInstance<ISongRepository>());

            //Get all Analysis for that Song but in groups of SetSong
            var analysis = analysisService.GetAnalysisBySong(song.SongId).GroupBy(x => x.SetSongId);

            double highestRating = 0;
            double? rating = 0;
            List<Guid> setSongIds = new List<Guid>();

            //If there are no analysis then there is nothing to see here
            if (analysis.Count() == 0)
                return null;

            var fave = new FavoriteLiveSongList(SetSong.FromSong(song));

            //If there are 1 or more analysis then we need to find out which is the highest ranked
            foreach (var a in analysis)
            {
                rating = a.Average(x => x.Rating);
                var setSongId = a.First().SetSongId;

                if (rating.HasValue && rating.Value > highestRating)
                {
                    highestRating = rating.Value;
                    fave.HighestRatedShows = new List<Show>();

                    var setSong = (SetSong)setSongService.GetSetSong(setSongId);
                    var show = GetShowFromSetSong(setSongId);
                    fave.HighestRatedShows.Add(show);
                }
                else if (rating.HasValue && rating.Value == highestRating)
                {
                    var setSong = (SetSong)setSongService.GetSetSong(setSongId);
                    var show = GetShowFromSetSong(setSongId);

                    fave.HighestRatedShows.Add(show);
                }
            }

            fave.HighestRating = highestRating;

            return fave;
        }
        public List<FavoriteLiveSongList> GenerateFavoriteLiveSongList(IQueryable<ISong> songs)
        {
            var songService = new SongService(Ioc.GetInstance<ISongRepository>());
            var favoriteVersionService = new FavoriteVersionService(Ioc.GetInstance<IFavoriteVersionRepository>());

            List<FavoriteLiveSongList> songLists = new List<FavoriteLiveSongList>();

            foreach (var song in songs)
            {
                var versions = favoriteVersionService.GetAllFavoriteVersions().Where(s => s.SongId == song.SongId).GroupBy(g => g.SetSongId).ToList();

                //If there aren't any favorites chosen for that song then just add the song to be displayed and continue
                if (versions == null || versions.Count() <= 0)
                {
                    var fave = GetAnalysisPart((Song)song);
                    if (fave != null)
                    {
                        songLists.Add(fave);
                    }
                    else
                    {
                        songLists.Add(new FavoriteLiveSongList(SetSong.FromSong((Song)song)));
                    }

                    continue;
                }

                //If there is only 1 favorite version then just use the first one in the collection
                if (versions.Count() == 1)
                {
                    var version = versions[0].First();
                    var setSongId = version.SetSongId.Value;
                    var setSong = (SetSong)setSongService.GetSetSong(setSongId);
                    var show = GetShowFromSetSong(setSongId);

                    var fave = GetAnalysisPart(setSong);
                    if (fave != null)
                    {
                        fave.FavoriteLiveShows.Add(show);
                    }
                    else
                    {
                        fave = new FavoriteLiveSongList(setSong, show);
                    }

                    songLists.Add(fave);
                }
                //There is a lot to check
                else
                {
                    int count = 0;

                    Guid? setSongId = null;

                    FavoriteLiveSongList songList = new FavoriteLiveSongList();

                    foreach (var version in versions)
                    {
                        //If this version has more votes then it needs to be added
                        if (version.Count() >= count)
                        {
                            if (version.Count() > count && count > 0)
                            {
                                //If its not the first time in the loop and this version is the most voted on then clear whatever is in there
                                songList.ClearShows();
                            }

                            //Change the count so that next time it will be right
                            count = version.Count();

                            setSongId = version.First().SetSongId;
                            var setSong = (SetSong)setSongService.GetSetSong(setSongId.Value);
                            var show = GetShowFromSetSong(setSongId.Value);
                            songList.AddFavorite(setSong, show);
                        }
                    }

                    var fave = GetAnalysisPart(setSongId);

                    if (fave != null)
                    {
                        songList.HighestRating = fave.HighestRating;
                        songList.HighestRatedShows = fave.HighestRatedShows;
                    }

                    songLists.Add(songList);
                }
            }

            return songLists;
        }
Exemple #5
0
        public List <FavoriteLiveSongList> GenerateFavoriteLiveSongList(IQueryable <ISong> songs)
        {
            var songService            = new SongService(Ioc.GetInstance <ISongRepository>());
            var favoriteVersionService = new FavoriteVersionService(Ioc.GetInstance <IFavoriteVersionRepository>());

            List <FavoriteLiveSongList> songLists = new List <FavoriteLiveSongList>();

            foreach (var song in songs)
            {
                var versions = favoriteVersionService.GetAllFavoriteVersions().Where(s => s.SongId == song.SongId).GroupBy(g => g.SetSongId).ToList();

                //If there aren't any favorites chosen for that song then just add the song to be displayed and continue
                if (versions == null || versions.Count() <= 0)
                {
                    var fave = GetAnalysisPart((Song)song);
                    if (fave != null)
                    {
                        songLists.Add(fave);
                    }
                    else
                    {
                        songLists.Add(new FavoriteLiveSongList(SetSong.FromSong((Song)song)));
                    }

                    continue;
                }

                //If there is only 1 favorite version then just use the first one in the collection
                if (versions.Count() == 1)
                {
                    var version   = versions[0].First();
                    var setSongId = version.SetSongId.Value;
                    var setSong   = (SetSong)setSongService.GetSetSong(setSongId);
                    var show      = GetShowFromSetSong(setSongId);

                    var fave = GetAnalysisPart(setSong);
                    if (fave != null)
                    {
                        fave.FavoriteLiveShows.Add(show);
                    }
                    else
                    {
                        fave = new FavoriteLiveSongList(setSong, show);
                    }

                    songLists.Add(fave);
                }
                //There is a lot to check
                else
                {
                    int count = 0;

                    Guid?setSongId = null;

                    FavoriteLiveSongList songList = new FavoriteLiveSongList();

                    foreach (var version in versions)
                    {
                        //If this version has more votes then it needs to be added
                        if (version.Count() >= count)
                        {
                            if (version.Count() > count && count > 0)
                            {
                                //If its not the first time in the loop and this version is the most voted on then clear whatever is in there
                                songList.ClearShows();
                            }

                            //Change the count so that next time it will be right
                            count = version.Count();

                            setSongId = version.First().SetSongId;
                            var setSong = (SetSong)setSongService.GetSetSong(setSongId.Value);
                            var show    = GetShowFromSetSong(setSongId.Value);
                            songList.AddFavorite(setSong, show);
                        }
                    }

                    var fave = GetAnalysisPart(setSongId);

                    if (fave != null)
                    {
                        songList.HighestRating     = fave.HighestRating;
                        songList.HighestRatedShows = fave.HighestRatedShows;
                    }

                    songLists.Add(songList);
                }
            }

            return(songLists);
        }