sonarr-repo-only/NzbDrone.Api/Directories/DirectoryModule.cs

34 lines
957 B
C#
Raw Normal View History

2013-08-04 17:26:37 +00:00
using System.Collections.Generic;
using System.Linq;
using Nancy;
2013-02-23 20:35:26 +00: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 23:38:53 +00:00
Get["/"] = x => GetDirectories();
}
private Response GetDirectories()
{
2013-02-15 23:38:53 +00:00
if (!Request.Query.query.HasValue)
return new List<string>().AsResponse();
2013-02-15 23:38:53 +00:00
string query = Request.Query.query.Value;
2013-08-04 17:26:37 +00:00
var dirs = _directoryLookupService.LookupSubDirectories(query)
.Select(p => p.GetActualCasing())
.ToList();
return dirs.AsResponse();
}
}
}