added ui structure for rootdirs.

This commit is contained in:
Keivan Beigi
2013-01-24 12:48:44 -08:00
committed by kay.one
parent ae61150b84
commit 157b559ed2
12 changed files with 133 additions and 8 deletions
+1
View File
@@ -89,6 +89,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="QualityProfiles\RootFolderModule.cs" />
<Compile Include="Series\SeriesModule.cs" />
<Compile Include="ErrorManagment\ApiException.cs" />
<Compile Include="Bootstrapper.cs" />
@@ -0,0 +1,32 @@
using Nancy;
using NzbDrone.Core.Providers;
using NzbDrone.Api.QualityType;
using NzbDrone.Core.Repository;
namespace NzbDrone.Api.QualityProfiles
{
public class RootFolderModule : NzbDroneApiModule
{
private readonly RootDirProvider _rootDirProvider;
public RootFolderModule(RootDirProvider rootDirProvider)
: base("//rootfolders")
{
_rootDirProvider = rootDirProvider;
Get["/"] = x => GetRootFolders();
Post["/"] = x => AddRootFolder();
}
private Response AddRootFolder()
{
_rootDirProvider.Add(Request.Body.FromJson<RootDir>());
return new Response { StatusCode = HttpStatusCode.Created };
}
private Response GetRootFolders()
{
return _rootDirProvider.AllWithFreeSpace().AsResponse();
}
}
}