Radarr/NzbDrone.Api/QualityProfiles/RootFolderModule.cs

40 lines
1.1 KiB
C#
Raw Normal View History

2013-01-24 20:48:44 +00:00
using Nancy;
using NzbDrone.Api.Extentions;
2013-01-24 20:48:44 +00:00
using NzbDrone.Core.Providers;
using NzbDrone.Api.QualityType;
using NzbDrone.Core.Repository;
namespace NzbDrone.Api.QualityProfiles
{
public class RootDirModule : NzbDroneApiModule
2013-01-24 20:48:44 +00:00
{
private readonly RootDirProvider _rootDirProvider;
public RootDirModule(RootDirProvider rootDirProvider)
: base("//rootdir")
2013-01-24 20:48:44 +00:00
{
_rootDirProvider = rootDirProvider;
Get["/"] = x => GetRootFolders();
Post["/"] = x => AddRootFolder();
Delete["/{id}"] = x => DeleteRootFolder((int)x.id);
2013-01-24 20:48:44 +00:00
}
private Response AddRootFolder()
{
var dir = _rootDirProvider.Add(Request.Body.FromJson<RootDir>());
return dir.AsResponse(HttpStatusCode.Created);
2013-01-24 20:48:44 +00:00
}
private Response GetRootFolders()
{
return _rootDirProvider.AllWithFreeSpace().AsResponse();
}
private Response DeleteRootFolder(int folderId)
{
_rootDirProvider.Remove(folderId);
return new Response { StatusCode = HttpStatusCode.OK };
}
2013-01-24 20:48:44 +00:00
}
}