From 2703dd1e110a10d19eb3c2b111f8b10f00db3db7 Mon Sep 17 00:00:00 2001 From: Kim Date: Thu, 9 Mar 2023 16:37:36 +0100 Subject: [PATCH] adds newly created inst and folders to accessible --- csharp/App/Backend/Controllers/Controller.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/csharp/App/Backend/Controllers/Controller.cs b/csharp/App/Backend/Controllers/Controller.cs index 10d4ba578..2351d5e92 100644 --- a/csharp/App/Backend/Controllers/Controller.cs +++ b/csharp/App/Backend/Controllers/Controller.cs @@ -252,13 +252,9 @@ public class Controller if (caller == null || !caller.HasWriteAccess) return new HttpResponseMessage(HttpStatusCode.Unauthorized); - db.CreateInstallation(installation); - if (db.GetInstallationById(1)!.Name != installation.Name) - { - return new HttpResponseMessage(HttpStatusCode.BadRequest); - } + var id = db.CreateInstallation(installation); - return db.AddToAccessibleInstallations(caller.Id, 1); + return db.AddToAccessibleInstallations(caller.Id, id); } @@ -269,11 +265,11 @@ public class Controller { var caller = GetCaller(); using var db = Db.Connect(); - if (caller == null || !caller.HasWriteAccess || db.GetInstallationByName(folder.Name) != null) + if (caller == null || !caller.HasWriteAccess) return new HttpResponseMessage(HttpStatusCode.Unauthorized); - db.CreateFolder(folder); - return db.AddToAccessibleInstallations(caller.Id, db.GetInstallationByName(folder.Name)!.Id); + var id = db.CreateFolder(folder); + return db.AddToAccessibleFolders(caller.Id, id); }