From 1fcf696bd540bca6fc541f8b96b28e031c24f5f7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 30 Mar 2013 10:57:30 -0400 Subject: Added filters to the item list page --- .../Sorting/PlayCountComparer.cs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Sorting/PlayCountComparer.cs (limited to 'MediaBrowser.Server.Implementations/Sorting') diff --git a/MediaBrowser.Server.Implementations/Sorting/PlayCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/PlayCountComparer.cs new file mode 100644 index 000000000..9cd5281c3 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/PlayCountComparer.cs @@ -0,0 +1,50 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + /// + /// Class PlayCountComparer + /// + public class PlayCountComparer : IUserBaseItemComparer + { + /// + /// Gets or sets the user. + /// + /// The user. + public User User { get; set; } + + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return GetValue(x).CompareTo(GetValue(y)); + } + + /// + /// Gets the date. + /// + /// The x. + /// DateTime. + private int GetValue(BaseItem x) + { + var userdata = x.GetUserData(User, false); + + return userdata == null ? 0 : userdata.PlayCount; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.PlayCount; } + } + } +} -- cgit v1.2.3