aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-04-12 10:32:04 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-04-12 10:32:04 -0400
commitb789550a5639a65e5b9cf0908ab8a577bd891589 (patch)
treecbcd9146881607dfcfc86a6770498285d6564079
parent192e1676a4d8db48a15316eede2041f0b1c9b48f (diff)
Added budget as a sort order
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs2
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs2
-rw-r--r--MediaBrowser.Model/Querying/ItemSortBy.cs4
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj1
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/BudgetComparer.cs29
5 files changed, 36 insertions, 2 deletions
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index dc29ba341..aed84e07f 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -29,7 +29,7 @@ namespace MediaBrowser.Api.UserLibrary
/// What to sort the results by
/// </summary>
/// <value>The sort by.</value>
- [ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, CommunityRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
+ [ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string SortBy { get; set; }
/// <summary>
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 15963a807..2cb8ac794 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -567,7 +567,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
- public double Budget { get; set; }
+ public double? Budget { get; set; }
/// <summary>
/// Gets or sets the production locations.
diff --git a/MediaBrowser.Model/Querying/ItemSortBy.cs b/MediaBrowser.Model/Querying/ItemSortBy.cs
index c85ed8780..b1ad7c550 100644
--- a/MediaBrowser.Model/Querying/ItemSortBy.cs
+++ b/MediaBrowser.Model/Querying/ItemSortBy.cs
@@ -19,6 +19,10 @@ namespace MediaBrowser.Model.Querying
/// </summary>
public const string Artist = "Artist";
/// <summary>
+ /// The budget
+ /// </summary>
+ public const string Budget = "Budget";
+ /// <summary>
/// The date created
/// </summary>
public const string DateCreated = "DateCreated";
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index a4c4fc614..ba79ff5d5 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -160,6 +160,7 @@
<Compile Include="Sorting\AlbumArtistComparer.cs" />
<Compile Include="Sorting\AlbumComparer.cs" />
<Compile Include="Sorting\ArtistComparer.cs" />
+ <Compile Include="Sorting\BudgetComparer.cs" />
<Compile Include="Sorting\CommunityRatingComparer.cs" />
<Compile Include="Sorting\DateCreatedComparer.cs" />
<Compile Include="Sorting\DatePlayedComparer.cs" />
diff --git a/MediaBrowser.Server.Implementations/Sorting/BudgetComparer.cs b/MediaBrowser.Server.Implementations/Sorting/BudgetComparer.cs
new file mode 100644
index 000000000..3637f2939
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Sorting/BudgetComparer.cs
@@ -0,0 +1,29 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Sorting;
+using MediaBrowser.Model.Querying;
+
+namespace MediaBrowser.Server.Implementations.Sorting
+{
+ public class BudgetDateComparer : IBaseItemComparer
+ {
+ /// <summary>
+ /// Compares the specified x.
+ /// </summary>
+ /// <param name="x">The x.</param>
+ /// <param name="y">The y.</param>
+ /// <returns>System.Int32.</returns>
+ public int Compare(BaseItem x, BaseItem y)
+ {
+ return (x.Budget ?? 0).CompareTo(y.Budget ?? 0);
+ }
+
+ /// <summary>
+ /// Gets the name.
+ /// </summary>
+ /// <value>The name.</value>
+ public string Name
+ {
+ get { return ItemSortBy.Budget; }
+ }
+ }
+}