Beispiel #1
0
        public async Task <ActionResult> GetSongGroup(string key, SongSort sort)
        {
            IGrouping <string, Track> group = default;
            bool hasPlaylists = await dataService.Exists <Playlist>(item => item.Type == (int)PlaylistTabs.Music);

            await musicService.GetSongGroups(sort).ContinueWith(task => group = task.Result.FirstOrDefault(item => item.Key == key));

            return(PartialView("~/Views/Music/SongGroup.cshtml", (Group: group, PlaylistCount: hasPlaylists)));
        }
        //toolstrip button method to merge sort the playlist
        private void sortPlaylistToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SongSort sorter = new SongSort();

            Song[] temp = new Song[numSongs];

            for (int i = 0; i < numSongs; i++)
            {
                temp[i] = playList[i];
            }

            temp = sorter.MergeSortSong(temp);

            for (int i = 0; i < numSongs; i++)
            {
                playList[i] = temp[i];
            }

            RefreshList();
        }
        //Search Results
        public ActionResult SearchResults(string NameSearchString, string ArtistSearchString, string AlbumSearchString, Int32[] SelectedGenres, SongSort SelectedSort, SortOrder SelectedSortOrder /*, TODO: Add parameter for Rating, once that is set up*/)
        {
            List <Song> SelectedSongs = new List <Song>();
            List <Song> AllSongs      = db.Songs.ToList();

            var query = from s in db.Songs
                        select s;

            var qtest = query;

            if (NameSearchString != null && NameSearchString != "")
            {
                query = query.Where(s => s.SongName.Contains(NameSearchString));
            }

            if (ArtistSearchString != null && ArtistSearchString != "")
            {
                query = query.Where(s => s.Artists.Any(a => a.ArtistName.Contains(ArtistSearchString)));
            }

            if (AlbumSearchString != null && AlbumSearchString != "")
            {
                query = query.Where(s => s.Album.AlbumName.Contains(AlbumSearchString));
            }

            if (qtest != query)
            {
                SelectedSongs = query.ToList();
            }

            //TODO: Add rating search once that functionality is live

            List <Song> SongsInGenre;

            if (SelectedGenres != null)
            {
                foreach (int id in SelectedGenres)
                {
                    Genre genre = db.Genres.Find(id);

                    SongsInGenre = query.Where(s => s.Genres.Any(g => g.GenreID.Equals(id))).ToList();
                    foreach (Song s in SongsInGenre)
                    {
                        if (SelectedSongs.Contains(s) == false)
                        {
                            SelectedSongs.Add(s);
                        }
                    }
                }
            }
            if (SelectedSongs.Count == 0)
            {
                SelectedSongs = db.Songs.ToList();
            }

            switch (SelectedSort)
            {
            case SongSort.Name:
                SelectedSongs = SelectedSongs.OrderBy(s => s.SongName).ToList(); break;

            case SongSort.Artist:
                SelectedSongs = SelectedSongs.OrderBy(s => s.Artists.First().ArtistName).ToList(); break;
                //TODO: Add song sort by rating case once that funtionality is live
                //case SongSort.Rating:
                //; break;
            }

            switch (SelectedSortOrder)
            {
            case SortOrder.Ascending:
                SelectedSongs = SelectedSongs; break;

            case SortOrder.Descending:
                SelectedSongs.Reverse(); break;
            }

            ViewBag.SongCount      = CountSongs(SelectedSongs);
            ViewBag.TotalSongCount = CountSongs(AllSongs);
            ViewBag.AllGenres      = GetAllGenres();

            return(View("Index", SelectedSongs));
        }
Beispiel #4
0
        public async Task <IEnumerable <IGrouping <string, Track> > > GetSongGroups(SongSort sort)
        {
            IEnumerable <IGrouping <string, Track> > groups = null;

            if (songs == null) /*then*/ songs {