You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/NzbDrone.Api/RootFolders/RootFolderModule.cs

42 lines
1.2 KiB

using System;
using System.Collections.Generic;
using NzbDrone.Core.RootFolders;
using NzbDrone.Api.Mapping;
namespace NzbDrone.Api.RootFolders
{
public class RootFolderModule : NzbDroneRestModule<RootFolderResource>
{
private readonly IRootFolderService _rootFolderService;
public RootFolderModule(IRootFolderService rootFolderService)
{
_rootFolderService = rootFolderService;
GetResourceAll = GetRootFolders;
GetResourceById = GetRootFolder;
CreateResource = CreateRootFolder;
DeleteResource = DeleteFolder;
}
private RootFolderResource GetRootFolder(int id)
{
return _rootFolderService.Get(id).InjectTo<RootFolderResource>();
}
private int CreateRootFolder(RootFolderResource rootFolderResource)
{
return GetNewId<RootFolder>(_rootFolderService.Add, rootFolderResource);
}
private List<RootFolderResource> GetRootFolders()
{
return ToListResource(_rootFolderService.AllWithUnmappedFolders);
}
private void DeleteFolder(int id)
{
_rootFolderService.Remove(id);
}
}
}