2013-04-22 03:18:08 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-02-04 04:18:59 +00:00
|
|
|
|
using NzbDrone.Core.RootFolders;
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
2013-01-29 01:59:18 +00:00
|
|
|
|
namespace NzbDrone.Api.RootFolders
|
2013-01-24 20:48:44 +00:00
|
|
|
|
{
|
2013-04-22 03:18:08 +00:00
|
|
|
|
public class RootFolderModule : NzbDroneRestModule<RootFolderResource>
|
2013-01-24 20:48:44 +00:00
|
|
|
|
{
|
2013-02-04 04:18:59 +00:00
|
|
|
|
private readonly RootFolderService _rootFolderService;
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
2013-02-18 01:45:14 +00:00
|
|
|
|
public RootFolderModule(RootFolderService rootFolderService)
|
2013-01-24 20:48:44 +00:00
|
|
|
|
{
|
2013-02-04 04:18:59 +00:00
|
|
|
|
_rootFolderService = rootFolderService;
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
2013-04-22 03:18:08 +00:00
|
|
|
|
GetResourceAll = GetRootFolders;
|
|
|
|
|
CreateResource = CreateRootFolder;
|
|
|
|
|
DeleteResource = DeleteFolder;
|
2013-01-24 20:48:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-22 03:18:08 +00:00
|
|
|
|
private RootFolderResource CreateRootFolder(RootFolderResource rootFolderResource)
|
2013-01-24 20:48:44 +00:00
|
|
|
|
{
|
2013-04-22 03:18:08 +00:00
|
|
|
|
return Apply<RootFolder>(_rootFolderService.Add, rootFolderResource);
|
2013-01-24 20:48:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-22 03:18:08 +00:00
|
|
|
|
private List<RootFolderResource> GetRootFolders()
|
2013-01-24 20:48:44 +00:00
|
|
|
|
{
|
2013-04-22 03:18:08 +00:00
|
|
|
|
return Apply(_rootFolderService.All);
|
2013-01-24 20:48:44 +00:00
|
|
|
|
}
|
2013-01-25 01:22:14 +00:00
|
|
|
|
|
2013-04-22 03:18:08 +00:00
|
|
|
|
private void DeleteFolder(int id)
|
2013-01-25 01:22:14 +00:00
|
|
|
|
{
|
2013-04-22 03:18:08 +00:00
|
|
|
|
_rootFolderService.Remove(id);
|
2013-01-25 01:22:14 +00:00
|
|
|
|
}
|
2013-01-24 20:48:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|