Ejemplo n.º 1
0
        private ItemCounts GetItemCounts(IDataReader reader, int countStartColumn, List<string> typesToCount)
        {
            var counts = new ItemCounts();

            if (typesToCount.Count == 0)
            {
                return counts;
            }

            var typeString = reader.IsDBNull(countStartColumn) ? null : reader.GetString(countStartColumn);

            if (string.IsNullOrWhiteSpace(typeString))
            {
                return counts;
            }

            var allTypes = typeString.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                .ToLookup(i => i).ToList();

            foreach (var type in allTypes)
            {
                var value = type.ToList().Count;
                var typeName = type.Key;

                if (string.Equals(typeName, typeof(Series).FullName, StringComparison.OrdinalIgnoreCase))
                {
                    counts.SeriesCount = value;
                }
                else if (string.Equals(typeName, typeof(Episode).FullName, StringComparison.OrdinalIgnoreCase))
                {
                    counts.EpisodeCount = value;
                }
                else if (string.Equals(typeName, typeof(Movie).FullName, StringComparison.OrdinalIgnoreCase))
                {
                    counts.MovieCount = value;
                }
                else if (string.Equals(typeName, typeof(MusicAlbum).FullName, StringComparison.OrdinalIgnoreCase))
                {
                    counts.AlbumCount = value;
                }
                else if (string.Equals(typeName, typeof(Audio).FullName, StringComparison.OrdinalIgnoreCase))
                {
                    counts.SongCount = value;
                }
                else if (string.Equals(typeName, typeof(Game).FullName, StringComparison.OrdinalIgnoreCase))
                {
                    counts.GameCount = value;
                }
                else if (string.Equals(typeName, typeof(Trailer).FullName, StringComparison.OrdinalIgnoreCase))
                {
                    counts.TrailerCount = value;
                }
                counts.ItemCount += value;
            }

            return counts;
        }
        private IEnumerable<TabItem> GetFavoriteTabs(ItemCounts counts)
        {
            var list = new List<TabItem>();

            if (counts.MovieCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Movies (" + counts.MovieCount + ")",
                    Name = "Movie"
                });
            }

            if (counts.BoxSetCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Box Sets (" + counts.BoxSetCount + ")",
                    Name = "BoxSet"
                });
            }

            if (counts.SeriesCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "TV Shows (" + counts.SeriesCount + ")",
                    Name = "Series"
                });
            }

            if (counts.EpisodeCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Episodes (" + counts.EpisodeCount + ")",
                    Name = "Episode"
                });
            }

            if (counts.PersonCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "People (" + counts.PersonCount + ")",
                    Name = "Person"
                });
            }

            if (counts.ArtistCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Artists (" + counts.ArtistCount + ")",
                    Name = "Artist"
                });
            }

            if (counts.AlbumCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Albums (" + counts.AlbumCount + ")",
                    Name = "MusicAlbum"
                });
            }

            if (counts.SongCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Songs (" + counts.SongCount + ")",
                    Name = "Audio"
                });
            }

            if (counts.MusicVideoCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Music Videos (" + counts.MusicVideoCount + ")",
                    Name = "MusicVideo"
                });
            }

            if (counts.GameCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Games (" + counts.GameCount + ")",
                    Name = "Game"
                });
            }

            if (counts.BookCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Books (" + counts.BookCount + ")",
                    Name = "Book"
                });
            }

            if (counts.AdultVideoCount > 0)
            {
                list.Add(new TabItem
                {
                    DisplayName = "Adult Videos (" + counts.AdultVideoCount + ")",
                    Name = "AdultVideo"
                });
            }

            return list;
        }