1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-19 10:54:05 +02:00
Sonarr/NzbDrone.Api/Directories/DirectoryModule.cs

34 lines
957 B
C#
Raw Normal View History

2013-08-04 10:26:37 -07:00
using System.Collections.Generic;
using System.Linq;
using Nancy;
2013-02-23 12:35:26 -08:00
using NzbDrone.Api.Extensions;
using NzbDrone.Common;
namespace NzbDrone.Api.Directories
{
public class DirectoryModule : NzbDroneApiModule
{
private readonly IDirectoryLookupService _directoryLookupService;
public DirectoryModule(IDirectoryLookupService directoryLookupService)
: base("/directories")
{
_directoryLookupService = directoryLookupService;
2013-02-15 15:38:53 -08:00
Get["/"] = x => GetDirectories();
}
private Response GetDirectories()
{
2013-02-15 15:38:53 -08:00
if (!Request.Query.query.HasValue)
return new List<string>().AsResponse();
2013-02-15 15:38:53 -08:00
string query = Request.Query.query.Value;
2013-08-04 10:26:37 -07:00
var dirs = _directoryLookupService.LookupSubDirectories(query)
.Select(p => p.GetActualCasing())
.ToList();
return dirs.AsResponse();
}
}
}