From 7cd41a6ed62c46006307add9de92e0b329bd0edc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 21 Feb 2014 00:04:11 -0500 Subject: easier user library setup --- .../Library/LibraryStructureService.cs | 96 ++-------------------- 1 file changed, 5 insertions(+), 91 deletions(-) (limited to 'MediaBrowser.Api/Library/LibraryStructureService.cs') diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index ff4f78c96..947da29fe 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -28,15 +28,8 @@ namespace MediaBrowser.Api.Library } [Route("/Library/VirtualFolders", "POST")] - [Route("/Users/{UserId}/VirtualFolders", "POST")] public class AddVirtualFolder : IReturnVoid { - /// - /// Gets or sets the user id. - /// - /// The user id. - public string UserId { get; set; } - /// /// Gets or sets the name. /// @@ -57,15 +50,8 @@ namespace MediaBrowser.Api.Library } [Route("/Library/VirtualFolders", "DELETE")] - [Route("/Users/{UserId}/VirtualFolders", "DELETE")] public class RemoveVirtualFolder : IReturnVoid { - /// - /// Gets or sets the user id. - /// - /// The user id. - public string UserId { get; set; } - /// /// Gets or sets the name. /// @@ -80,15 +66,8 @@ namespace MediaBrowser.Api.Library } [Route("/Library/VirtualFolders/Name", "POST")] - [Route("/Users/{UserId}/VirtualFolders/Name", "POST")] public class RenameVirtualFolder : IReturnVoid { - /// - /// Gets or sets the user id. - /// - /// The user id. - public string UserId { get; set; } - /// /// Gets or sets the name. /// @@ -109,15 +88,8 @@ namespace MediaBrowser.Api.Library } [Route("/Library/VirtualFolders/Paths", "POST")] - [Route("/Users/{UserId}/VirtualFolders/Paths", "POST")] public class AddMediaPath : IReturnVoid { - /// - /// Gets or sets the user id. - /// - /// The user id. - public string UserId { get; set; } - /// /// Gets or sets the name. /// @@ -138,15 +110,8 @@ namespace MediaBrowser.Api.Library } [Route("/Library/VirtualFolders/Paths", "DELETE")] - [Route("/Users/{UserId}/VirtualFolders/Paths", "DELETE")] public class RemoveMediaPath : IReturnVoid { - /// - /// Gets or sets the user id. - /// - /// The user id. - public string UserId { get; set; } - /// /// Gets or sets the name. /// @@ -275,18 +240,7 @@ namespace MediaBrowser.Api.Library var name = _fileSystem.GetValidFilename(request.Name); - string rootFolderPath; - - if (string.IsNullOrEmpty(request.UserId)) - { - rootFolderPath = _appPaths.DefaultUserViewsPath; - } - else - { - var user = _userManager.GetUserById(new Guid(request.UserId)); - - rootFolderPath = user.RootFolderPath; - } + var rootFolderPath = _appPaths.DefaultUserViewsPath; var virtualFolderPath = Path.Combine(rootFolderPath, name); @@ -344,18 +298,7 @@ namespace MediaBrowser.Api.Library throw new ArgumentNullException("request"); } - string rootFolderPath; - - if (string.IsNullOrEmpty(request.UserId)) - { - rootFolderPath = _appPaths.DefaultUserViewsPath; - } - else - { - var user = _userManager.GetUserById(new Guid(request.UserId)); - - rootFolderPath = user.RootFolderPath; - } + var rootFolderPath = _appPaths.DefaultUserViewsPath; var currentPath = Path.Combine(rootFolderPath, request.Name); var newPath = Path.Combine(rootFolderPath, request.NewName); @@ -417,18 +360,7 @@ namespace MediaBrowser.Api.Library throw new ArgumentNullException("request"); } - string rootFolderPath; - - if (string.IsNullOrEmpty(request.UserId)) - { - rootFolderPath = _appPaths.DefaultUserViewsPath; - } - else - { - var user = _userManager.GetUserById(new Guid(request.UserId)); - - rootFolderPath = user.RootFolderPath; - } + var rootFolderPath = _appPaths.DefaultUserViewsPath; var path = Path.Combine(rootFolderPath, request.Name); @@ -478,16 +410,7 @@ namespace MediaBrowser.Api.Library try { - if (string.IsNullOrEmpty(request.UserId)) - { - LibraryHelpers.AddMediaPath(_fileSystem, request.Name, request.Path, null, _appPaths); - } - else - { - var user = _userManager.GetUserById(new Guid(request.UserId)); - - LibraryHelpers.AddMediaPath(_fileSystem, request.Name, request.Path, user, _appPaths); - } + LibraryHelpers.AddMediaPath(_fileSystem, request.Name, request.Path, _appPaths); // Need to add a delay here or directory watchers may still pick up the changes var task = Task.Delay(1000); @@ -524,16 +447,7 @@ namespace MediaBrowser.Api.Library try { - if (string.IsNullOrEmpty(request.UserId)) - { - LibraryHelpers.RemoveMediaPath(_fileSystem, request.Name, request.Path, null, _appPaths); - } - else - { - var user = _userManager.GetUserById(new Guid(request.UserId)); - - LibraryHelpers.RemoveMediaPath(_fileSystem, request.Name, request.Path, user, _appPaths); - } + LibraryHelpers.RemoveMediaPath(_fileSystem, request.Name, request.Path, _appPaths); // Need to add a delay here or directory watchers may still pick up the changes var task = Task.Delay(1000); -- cgit v1.2.3