prevent direct repo access

pull/702/head
Luke Pulverenti 11 years ago
parent 84a702e6e3
commit fca5a40601

@ -500,7 +500,7 @@ namespace MediaBrowser.Api
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList(); .ToList();
var dtos = item.ThemeSongIds.Select(_itemRepo.RetrieveItem) var dtos = item.ThemeSongIds.Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); .Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
@ -547,7 +547,7 @@ namespace MediaBrowser.Api
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList(); .ToList();
var dtos = item.ThemeVideoIds.Select(_itemRepo.RetrieveItem) var dtos = item.ThemeVideoIds.Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); .Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));

@ -387,8 +387,6 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary> /// </summary>
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly ISessionManager _sessionManager; private readonly ISessionManager _sessionManager;
private readonly IDtoService _dtoService; private readonly IDtoService _dtoService;
@ -398,16 +396,14 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="userManager">The user manager.</param> /// <param name="userManager">The user manager.</param>
/// <param name="libraryManager">The library manager.</param> /// <param name="libraryManager">The library manager.</param>
/// <param name="userDataRepository">The user data repository.</param> /// <param name="userDataRepository">The user data repository.</param>
/// <param name="itemRepo">The item repo.</param>
/// <param name="sessionManager">The session manager.</param> /// <param name="sessionManager">The session manager.</param>
/// <param name="dtoService">The dto service.</param> /// <param name="dtoService">The dto service.</param>
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception> /// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, ISessionManager sessionManager, IDtoService dtoService) public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, ISessionManager sessionManager, IDtoService dtoService)
{ {
_userManager = userManager; _userManager = userManager;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_userDataRepository = userDataRepository; _userDataRepository = userDataRepository;
_itemRepo = itemRepo;
_sessionManager = sessionManager; _sessionManager = sessionManager;
_dtoService = dtoService; _dtoService = dtoService;
} }
@ -442,7 +438,7 @@ namespace MediaBrowser.Api.UserLibrary
var movie1 = movie; var movie1 = movie;
var dtos = movie.SpecialFeatureIds var dtos = movie.SpecialFeatureIds
.Select(_itemRepo.RetrieveItem) .Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, movie1)); .Select(i => _dtoService.GetBaseItemDto(i, fields, user, movie1));
@ -502,7 +498,7 @@ namespace MediaBrowser.Api.UserLibrary
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList(); var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var dtos = item.LocalTrailerIds var dtos = item.LocalTrailerIds
.Select(_itemRepo.RetrieveItem) .Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); .Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));

@ -1,7 +1,6 @@
using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using ServiceStack.ServiceHost; using ServiceStack.ServiceHost;
using System; using System;
@ -26,15 +25,12 @@ namespace MediaBrowser.Api
public class VideosService : BaseApiService public class VideosService : BaseApiService
{ {
private readonly IItemRepository _itemRepo;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IDtoService _dtoService; private readonly IDtoService _dtoService;
public VideosService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, IDtoService dtoService) public VideosService( ILibraryManager libraryManager, IUserManager userManager, IDtoService dtoService)
{ {
_itemRepo = itemRepo;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_userManager = userManager; _userManager = userManager;
_dtoService = dtoService; _dtoService = dtoService;
@ -62,7 +58,7 @@ namespace MediaBrowser.Api
var video = (Video)item; var video = (Video)item;
var items = video.AdditionalPartIds.Select(_itemRepo.RetrieveItem) var items = video.AdditionalPartIds.Select(_libraryManager.GetItemById)
.OrderBy(i => i.SortName) .OrderBy(i => i.SortName)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, video)) .Select(i => _dtoService.GetBaseItemDto(i, fields, user, video))
.ToArray(); .ToArray();

Loading…
Cancel
Save