add new API: GetAllFoldersAndInstallations

This commit is contained in:
ig 2023-03-08 13:40:34 +01:00
parent faf35be6cf
commit 72293807ee
1 changed files with 19 additions and 0 deletions

View File

@ -184,6 +184,25 @@ public class Controller
.ToList(); // important! .ToList(); // important!
} }
[Returns<TreeNode[]>] // assuming swagger knows about arrays but not lists (JSON)
[Returns(HttpStatusCode.Unauthorized)]
[HttpGet($"{nameof(GetAllFoldersAndInstallations)}/")]
public Object GetAllFoldersAndInstallations()
{
var caller = GetCaller();
if (caller == null)
return new HttpResponseMessage(HttpStatusCode.Unauthorized);
using var db = Db.Connect();
var folders = db.GetAllAccessibleFolders(caller) as IEnumerable<TreeNode>;
var installations = db.GetAllAccessibleInstallations(caller);
return folders
.Concat(installations)
.ToList(); // important!
}
private static Folder PopulateChildren(Db db, Folder folder, HashSet<Int64>? hs = null) private static Folder PopulateChildren(Db db, Folder folder, HashSet<Int64>? hs = null)
{ {
// TODO: remove cycle detector // TODO: remove cycle detector