aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/GamesService.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-05 23:03:08 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-05 23:03:08 -0400
commit863f123f3c8d26dc9fee050a9132857281caba84 (patch)
tree7e3f3ea0b6d420c33bf79ba9c2b2e0ef480f408f /MediaBrowser.Api/GamesService.cs
parent3fbf08b8825d7476e7cd87fb922e3aa9245253cc (diff)
updated nuget + subtitle changes
Diffstat (limited to 'MediaBrowser.Api/GamesService.cs')
-rw-r--r--MediaBrowser.Api/GamesService.cs39
1 files changed, 38 insertions, 1 deletions
diff --git a/MediaBrowser.Api/GamesService.cs b/MediaBrowser.Api/GamesService.cs
index 68b3fc9c84..799b9d7567 100644
--- a/MediaBrowser.Api/GamesService.cs
+++ b/MediaBrowser.Api/GamesService.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Dto;
+using System.Globalization;
+using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
@@ -36,6 +37,21 @@ namespace MediaBrowser.Api
}
/// <summary>
+ /// Class GetGameSystemSummaries
+ /// </summary>
+ [Route("/Games/PlayerIndex", "GET")]
+ [Api(Description = "Gets an index of players (1-x) and the number of games listed under each")]
+ public class GetPlayerIndex : IReturn<List<ItemIndex>>
+ {
+ /// <summary>
+ /// Gets or sets the user id.
+ /// </summary>
+ /// <value>The user id.</value>
+ [ApiMember(Name = "UserId", Description = "Optional. Filter by user id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public Guid? UserId { get; set; }
+ }
+
+ /// <summary>
/// Class GamesService
/// </summary>
public class GamesService : BaseApiService
@@ -100,6 +116,27 @@ namespace MediaBrowser.Api
return ToOptimizedResult(result);
}
+ private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
+
+ public object Get(GetPlayerIndex request)
+ {
+ var games = GetAllLibraryItems(request.UserId, _userManager, _libraryManager)
+ .OfType<Game>()
+ .ToList();
+
+ var lookup = games
+ .ToLookup(i => i.PlayersSupported ?? -1)
+ .OrderBy(i => i.Key)
+ .Select(i => new ItemIndex
+ {
+ ItemCount = i.Count(),
+ Name = i.Key == -1 ? string.Empty : i.Key.ToString(UsCulture)
+ })
+ .ToList();
+
+ return ToOptimizedResult(lookup);
+ }
+
/// <summary>
/// Gets the summary.
/// </summary>