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