From c8a735bcb1ba71e9501d18b3044aa30793ff97ee Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 24 Oct 2014 00:54:35 -0400 Subject: add LocalFileInfo.Id --- .../Dto/DtoService.cs | 57 ++++++---------------- 1 file changed, 15 insertions(+), 42 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 3393876fc..75a174a64 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.IO; +using MediaBrowser.Common; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Drawing; @@ -40,8 +41,9 @@ namespace MediaBrowser.Server.Implementations.Dto private readonly Func _channelManagerFactory; private readonly ISyncManager _syncManager; + private readonly IApplicationHost _appHost; - public DtoService(ILogger logger, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor, IServerConfigurationManager config, IFileSystem fileSystem, IProviderManager providerManager, Func channelManagerFactory, ISyncManager syncManager) + public DtoService(ILogger logger, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor, IServerConfigurationManager config, IFileSystem fileSystem, IProviderManager providerManager, Func channelManagerFactory, ISyncManager syncManager, IApplicationHost appHost) { _logger = logger; _libraryManager = libraryManager; @@ -53,6 +55,7 @@ namespace MediaBrowser.Server.Implementations.Dto _providerManager = providerManager; _channelManagerFactory = channelManagerFactory; _syncManager = syncManager; + _appHost = appHost; } /// @@ -96,7 +99,10 @@ namespace MediaBrowser.Server.Implementations.Dto throw new ArgumentNullException("fields"); } - var dto = new BaseItemDto(); + var dto = new BaseItemDto + { + ServerId = _appHost.SystemId + }; dto.SupportsPlaylists = item.SupportsAddingToPlaylist; @@ -260,43 +266,6 @@ namespace MediaBrowser.Server.Implementations.Dto .Count(); } - public UserDto GetUserDto(User user) - { - if (user == null) - { - throw new ArgumentNullException("user"); - } - - var dto = new UserDto - { - Id = user.Id.ToString("N"), - Name = user.Name, - HasPassword = !String.IsNullOrEmpty(user.Password), - LastActivityDate = user.LastActivityDate, - LastLoginDate = user.LastLoginDate, - Configuration = user.Configuration - }; - - var image = user.GetImageInfo(ImageType.Primary, 0); - - if (image != null) - { - dto.PrimaryImageTag = GetImageCacheTag(user, image); - - try - { - AttachPrimaryImageAspectRatio(dto, user); - } - catch (Exception ex) - { - // Have to use a catch-all unfortunately because some .net image methods throw plain Exceptions - _logger.ErrorException("Error generating PrimaryImageAspectRatio for {0}", ex, user.Name); - } - } - - return dto; - } - /// /// Gets client-side Id of a server-side BaseItem /// @@ -893,9 +862,13 @@ namespace MediaBrowser.Server.Implementations.Dto } } - if (item.Parent != null && fields.Contains(ItemFields.ParentId)) + if (fields.Contains(ItemFields.ParentId)) { - dto.ParentId = GetDtoId(item.Parent); + var displayParent = item.DisplayParent; + if (displayParent != null) + { + dto.ParentId = GetDtoId(displayParent); + } } dto.ParentIndexNumber = item.ParentIndexNumber; -- cgit v1.2.3