1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-25 17:27:59 +00:00
Radarr/NzbDrone.Api/RootFolders/RootFolderModule.cs
2013-03-07 21:39:52 +09:00

41 lines
No EOL
1.1 KiB
C#

using System.Linq;
using Nancy;
using NzbDrone.Api.Extensions;
using NzbDrone.Core.Providers;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Api.RootFolders
{
public class RootFolderModule : NzbDroneApiModule
{
private readonly RootFolderService _rootFolderService;
public RootFolderModule(RootFolderService rootFolderService)
: base("/rootfolder")
{
_rootFolderService = rootFolderService;
Get["/"] = x => GetRootFolders();
Post["/"] = x => AddRootFolder();
Delete["/{id}"] = x => DeleteRootFolder((int)x.id);
}
private Response AddRootFolder()
{
var dir = _rootFolderService.Add(Request.Body.FromJson<RootFolder>());
return dir.AsResponse(HttpStatusCode.Created);
}
private Response GetRootFolders()
{
return _rootFolderService.All().AsResponse();
}
private Response DeleteRootFolder(int folderId)
{
_rootFolderService.Remove(folderId);
return new Response { StatusCode = HttpStatusCode.OK };
}
}
}