Esempio n. 1
0
        public void ChangeSort(AlbumSort sort)
        {
            ViewSource = new CollectionViewSource {
                IsSourceGrouped = sort != AlbumSort.DateAdded
            };
            _settingsUtility.Write(ApplicationSettingsConstants.AlbumSort, sort, SettingsStrategy.Roam);

            switch (sort)
            {
            case AlbumSort.AtoZ:
                ViewSource.Source = _libraryCollectionService.AlbumsByTitle;
                break;

            case AlbumSort.DateAdded:
                ViewSource.Source = _libraryCollectionService.AlbumsByDateAdded;
                break;

            case AlbumSort.Artist:
                ViewSource.Source = _libraryCollectionService.AlbumsByArtist;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(sort), sort, null);
            }
        }
Esempio n. 2
0
        public ActionResult Albums(int id, int p = 1, AlbumSort sort = AlbumSort.ByDateHightToLow)
        {
            var category = db.Genres.Find(id);
            ViewData["Genre"] = category.Name;
            var albums = category.Albums.Sort(sort);

            if (albums != null)
                return View(albums.ToPagedList(pageNumber: p, pageSize: 10));
            else
                return HttpNotFound();
        }
Esempio n. 3
0
        public ActionResult Album(int genre      = 0,
                                  int p          = 1,
                                  AlbumSort sort = AlbumSort.ByDateHightToLow,
                                  string keyWord = "")
        {
            IEnumerable <Album> albums = null;

            albums = db.Albums.Where(album => genre == 0 || album.Genre.Id == genre)
                     .Where(album => String.IsNullOrEmpty(keyWord) ||
                            album.Name.IndexOf(keyWord) > -1 ||
                            album.Artist.Name.IndexOf(keyWord) > -1);

            return(View(albums.Sort(sort).ToPagedList(p, 20)));
        }
Esempio n. 4
0
        public ActionResult Album(int genre = 0,
                                   int p = 1,
                                   AlbumSort sort=AlbumSort.ByDateHightToLow,
                                   string keyWord = "")
        {
            IEnumerable<Album> albums = null;

            albums = db.Albums.Where(album => genre == 0 || album.Genre.Id == genre)
                              .Where(album => String.IsNullOrEmpty(keyWord) ||
                                              album.Name.IndexOf(keyWord) > -1 ||
                                              album.Artist.Name.IndexOf(keyWord) > -1);

            return View(albums.Sort(sort).ToPagedList(p, 20));
        }
Esempio n. 5
0
        public ActionResult Albums(int id, int p = 1, AlbumSort sort = AlbumSort.ByDateHightToLow)
        {
            var category = db.Genres.Find(id);

            ViewData["Genre"] = category.Name;
            var albums = category.Albums.Sort(sort);

            if (albums != null)
            {
                return(View(albums.ToPagedList(pageNumber: p, pageSize: 10)));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Esempio n. 6
0
        public AlbumResultsPageModel GetAlbums(int offset, int limit, AlbumSort sort = AlbumSort.Artflow,
                                               string[] tags = null, string search = null, string artistId = null, string genreId = null, string trackId = null, string albumId = null)
        {
            var args = new List <object> {
                "albums", offset, limit, "sort:" + Enum.GetName(typeof(AlbumSort), sort).ToString().ToLower()
            };

            if (!string.IsNullOrWhiteSpace(search))
            {
                //TODO: what about special characters and spaces?
                args.Add("search:" + search);
            }

            if (!string.IsNullOrWhiteSpace(artistId))
            {
                args.Add("artist_id:" + artistId);
            }

            if (!string.IsNullOrWhiteSpace(trackId))
            {
                args.Add("track_id:" + trackId);
            }

            if (!string.IsNullOrWhiteSpace(albumId))
            {
                args.Add("album_id:" + albumId);
            }

            if (!string.IsNullOrWhiteSpace(genreId))
            {
                args.Add("genre_id:" + genreId);
            }

            if (tags != null && tags.Length > 0)
            {
                args.Add(string.Concat("tags:", string.Concat(tags)));
            }

            var request = new SlimJsonRpcRequest(string.Empty, args.ToArray());
            var json    = PostJsonRpcRequest(request);

            return(JsonConvert.DeserializeObject <ResponseModel <AlbumResultsPageModel> > (json).Result);
        }
Esempio n. 7
0
        //唱片排序的DropDowmSelect
        public ActionResult AlbumSortSelect(AlbumSort sort = AlbumSort.ByDateHightToLow)
        {
            var selectList = new SelectList(GetSortSelectList(), "Value", "Text", sort);

            return(PartialView("SortSelect", selectList));
        }
Esempio n. 8
0
        public void ChangeSort(AlbumSort sort)
        {
            ViewSource = new CollectionViewSource { IsSourceGrouped = sort != AlbumSort.DateAdded };
            _settingsUtility.Write(ApplicationSettingsConstants.AlbumSort, sort, SettingsStrategy.Roam);

            switch (sort)
            {
                case AlbumSort.AtoZ:
                    ViewSource.Source = _libraryCollectionService.AlbumsByTitle;
                    break;
                case AlbumSort.DateAdded:
                    ViewSource.Source = _libraryCollectionService.AlbumsByDateAdded;
                    break;
                case AlbumSort.Artist:
                    ViewSource.Source = _libraryCollectionService.AlbumsByArtist;
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(sort), sort, null);
            }
        }
        //Search Results
        public ActionResult SearchResults(string NameSearchString, string ArtistSearchString, Int32[] SelectedGenres, AlbumSort SelectedSort, SongsController.SortOrder SelectedSortOrder /*, TODO: Add parameter for Rating, once that is set up*/)
        {
            List <Album> SelectedAlbums = new List <Album>();
            List <Album> AllAlbums      = db.Albums.ToList();

            var query = from a in db.Albums
                        select a;

            var qtest = query;

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

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

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

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

            List <Album> AlbumsInGenre;

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

                    AlbumsInGenre = query.Where(a => a.Genres.Any(g => g.GenreID.Equals(id))).ToList();
                    foreach (Album a in AlbumsInGenre)
                    {
                        if (SelectedAlbums.Contains(a) == false)
                        {
                            SelectedAlbums.Add(a);
                        }
                    }
                }
            }

            //TODO: Add Ascending/Descending for name, artist, rating

            switch (SelectedSort)
            {
            case AlbumSort.Name:
                SelectedAlbums = SelectedAlbums.OrderBy(s => s.AlbumName).ToList(); break;

            case AlbumSort.Artist:
                SelectedAlbums = SelectedAlbums.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 SongsController.SortOrder.Ascending:
                SelectedAlbums = SelectedAlbums; break;

            case SongsController.SortOrder.Descending:
                SelectedAlbums.Reverse(); break;
            }

            ViewBag.AlbumCount      = CountAlbums(SelectedAlbums);
            ViewBag.TotalAlbumCount = CountAlbums(AllAlbums);

            return(View("Index", SelectedAlbums));
        }
Esempio n. 10
0
        public static IOrderedEnumerable <Album> Sort(this IEnumerable <Album> albums, AlbumSort sort)
        {
            switch (sort)
            {
            case AlbumSort.ByTitleHightToLow:
                return(albums.OrderByDescending(album => album.Name));

            case AlbumSort.ByTitleLowToHight:
                return(albums.OrderBy(album => album.Name));

            case AlbumSort.ByDateHightToLow:
                return(albums.OrderByDescending(album => album.PublicDate));

            case AlbumSort.ByDateLowToHight:
                return(albums.OrderBy(album => album.PublicDate));

            case AlbumSort.ByPopularHightToLow:
                return(albums.OrderByDescending(album => album.Popular));

            case AlbumSort.ByPopularLowToHight:
                return(albums.OrderBy(album => album.Popular));

            default:
                return(albums.OrderBy(album => album.Name));
            }
        }
Esempio n. 11
0
 //唱片排序的DropDowmSelect
 public ActionResult AlbumSortSelect(AlbumSort sort=AlbumSort.ByDateHightToLow)
 {
     var selectList=new SelectList(GetSortSelectList(), "Value", "Text", sort);
     return PartialView("SortSelect",selectList);
 }