2013-05-25 19:52:41 -04:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.Persistence;
|
|
|
|
|
using ServiceStack.ServiceHost;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GetSimilarGames
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Games/{Id}/Similar", "GET")]
|
|
|
|
|
[Api(Description = "Finds games similar to a given game.")]
|
2013-08-09 11:55:22 -04:00
|
|
|
|
public class GetSimilarGames : BaseGetSimilarItemsFromItem
|
2013-05-25 19:52:41 -04:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GamesService
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class GamesService : BaseApiService
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _user manager
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly IUserManager _userManager;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _user data repository
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly IUserDataRepository _userDataRepository;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _library manager
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
|
|
2013-06-18 15:16:27 -04:00
|
|
|
|
private readonly IItemRepository _itemRepo;
|
|
|
|
|
|
2013-05-25 19:52:41 -04:00
|
|
|
|
/// <summary>
|
2013-06-18 15:16:27 -04:00
|
|
|
|
/// Initializes a new instance of the <see cref="GamesService" /> class.
|
2013-05-25 19:52:41 -04:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userManager">The user manager.</param>
|
|
|
|
|
/// <param name="userDataRepository">The user data repository.</param>
|
|
|
|
|
/// <param name="libraryManager">The library manager.</param>
|
2013-06-18 15:16:27 -04:00
|
|
|
|
/// <param name="itemRepo">The item repo.</param>
|
|
|
|
|
public GamesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo)
|
2013-05-25 19:52:41 -04:00
|
|
|
|
{
|
|
|
|
|
_userManager = userManager;
|
|
|
|
|
_userDataRepository = userDataRepository;
|
|
|
|
|
_libraryManager = libraryManager;
|
2013-06-18 15:16:27 -04:00
|
|
|
|
_itemRepo = itemRepo;
|
2013-05-25 19:52:41 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
|
|
|
|
public object Get(GetSimilarGames request)
|
|
|
|
|
{
|
2013-08-08 16:18:05 -04:00
|
|
|
|
var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager,
|
2013-06-18 15:16:27 -04:00
|
|
|
|
_itemRepo,
|
2013-05-25 19:52:41 -04:00
|
|
|
|
_libraryManager,
|
|
|
|
|
_userDataRepository,
|
|
|
|
|
Logger,
|
2013-06-23 11:02:53 -04:00
|
|
|
|
request, item => item is Game,
|
2013-05-25 19:52:41 -04:00
|
|
|
|
SimilarItemsHelper.GetSimiliarityScore);
|
|
|
|
|
|
|
|
|
|
return ToOptimizedResult(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|