1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-21 01:49:57 +02:00
Sonarr/NzbDrone.Api/Directories/DirectoryModule.cs

34 lines
957 B
C#
Raw Normal View History

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