From b07a1e67c26a595b906dccc135dfff62d9883e65 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Sep 2013 16:45:27 -0400 Subject: Added episodes page --- .../Sorting/SeriesSortNameComparer.cs | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs (limited to 'MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs') diff --git a/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs new file mode 100644 index 000000000..4efc3218b --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs @@ -0,0 +1,57 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; +using System; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + class SeriesSortNameComparer : IBaseItemComparer + { + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase); + } + + private string GetValue(BaseItem item) + { + Series series = null; + + var season = item as Season; + + if (season != null) + { + series = season.Series; + } + + var episode = item as Episode; + + if (episode != null) + { + series = episode.Series; + } + + if (series == null) + { + series = item as Series; + } + + return series != null ? series.SortName : null; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.SeriesSortName; } + } + } +} -- cgit v1.2.3