using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using ServiceStack.ServiceHost;
namespace MediaBrowser.Api
{
///
/// Class GetSimilarGames
///
[Route("/Games/{Id}/Similar", "GET")]
[Api(Description = "Finds games similar to a given game.")]
public class GetSimilarGames : BaseGetSimilarItemsFromItem
{
}
///
/// Class GamesService
///
public class GamesService : BaseApiService
{
///
/// The _user manager
///
private readonly IUserManager _userManager;
///
/// The _user data repository
///
private readonly IUserDataRepository _userDataRepository;
///
/// The _library manager
///
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
///
/// Initializes a new instance of the class.
///
/// The user manager.
/// The user data repository.
/// The library manager.
/// The item repo.
public GamesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
}
///
/// Gets the specified request.
///
/// The request.
/// System.Object.
public object Get(GetSimilarGames request)
{
var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager,
_itemRepo,
_libraryManager,
_userDataRepository,
Logger,
request, item => item is Game,
SimilarItemsHelper.GetSimiliarityScore);
return ToOptimizedResult(result);
}
}
}