Esempio n. 1
0
        public static IQueryable <Artist> OrderBy(
            this IQueryable <Artist> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference)
        {
            switch (sortRule)
            {
            case ArtistSortRule.Name:
                return(FindHelpers.AddNameOrder(criteria, languagePreference));

            case ArtistSortRule.AdditionDate:
                return(criteria.OrderByDescending(a => a.CreateDate));

            case ArtistSortRule.AdditionDateAsc:
                return(criteria.OrderBy(a => a.CreateDate));

            case ArtistSortRule.SongCount:
                return(criteria.OrderByDescending(a => a.AllSongs.Count()));

            case ArtistSortRule.SongRating:
                return(criteria.OrderByDescending(a => a.AllSongs
                                                  .Where(s => !s.Song.Deleted)
                                                  .Sum(s => s.Song.RatingScore)));

            case ArtistSortRule.FollowerCount:
                return(criteria.OrderByDescending(a => a.Users.Count));
            }

            return(criteria);
        }
Esempio n. 2
0
        public static IQueryable <Artist> OrderByArtistRule(this IQueryable <Artist> criteria, ArtistSortRule sortRule, ContentLanguagePreference languagePreference)
        {
            switch (sortRule)
            {
            case ArtistSortRule.Name:
                return(FindHelpers.AddNameOrder(criteria, languagePreference));

            case ArtistSortRule.AdditionDate:
                return(criteria.OrderByDescending(a => a.CreateDate));
            }

            return(criteria);
        }
Esempio n. 3
0
        public static IQueryable <Album> OrderBy(this IQueryable <Album> criteria, AlbumSortRule sortRule, ContentLanguagePreference languagePreference)
        {
            switch (sortRule)
            {
            case AlbumSortRule.Name:
                return(FindHelpers.AddNameOrder(criteria, languagePreference));

            case AlbumSortRule.CollectionCount:
                return(criteria.OrderByDescending(a => a.UserCollections.Count));

            case AlbumSortRule.ReleaseDate:
                return(criteria
                       .WhereHasReleaseDate()
                       .OrderByReleaseDate());

            case AlbumSortRule.ReleaseDateWithNulls:
                return(criteria.OrderByReleaseDate());

            case AlbumSortRule.AdditionDate:
                return(criteria.OrderByDescending(a => a.CreateDate));

            case AlbumSortRule.RatingAverage:
                return(criteria.OrderByDescending(a => a.RatingAverageInt)
                       .ThenByDescending(a => a.RatingCount));

            case AlbumSortRule.RatingTotal:
                return(criteria.OrderByDescending(a => a.RatingTotal)
                       .ThenByDescending(a => a.RatingAverageInt));

            case AlbumSortRule.NameThenReleaseDate:
                return(FindHelpers.AddNameOrder(criteria, languagePreference)
                       .ThenBy(a => a.OriginalRelease.ReleaseDate.Year)
                       .ThenBy(a => a.OriginalRelease.ReleaseDate.Month)
                       .ThenBy(a => a.OriginalRelease.ReleaseDate.Day));
            }

            return(criteria);
        }
Esempio n. 4
0
 public static IOrderedQueryable <T> AddNameOrder <T>(this IQueryable <T> criteria, ContentLanguagePreference languagePreference)
     where T : IEntryWithNames
 {
     return(FindHelpers.AddNameOrder(criteria, languagePreference));
 }