From b5119b6be15859b759f1767098c5d252ed9aa4f0 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Thu, 30 May 2024 18:27:36 +0200 Subject: [PATCH] Fixed server creation allocation loading --- .../Servers/UI/Views/Admin/Index.razor | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor index f8dac37c..c8f71e4e 100644 --- a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor +++ b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor @@ -68,14 +68,23 @@ .Include(x => x.Node); } - private IEnumerable LoadFreeAllocations(Repository repository, Server currentServer) + private IEnumerable LoadFreeAllocations(Repository repository, Server? currentServer) { - return currentServer.Allocations.Concat( - repository + if (currentServer == null) + { + return repository .Get() - .FromSqlRaw($"SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL AND ServerNodeId = {currentServer.Node.Id}") - .AsEnumerable() // => executes the sql - ); + .FromSqlRaw("SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL"); + } + else + { + return currentServer.Allocations.Concat( + repository + .Get() + .FromSqlRaw($"SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL AND ServerNodeId = {currentServer.Node.Id}") + .AsEnumerable() // => executes the sql + ); + } } private async Task CustomAdd(Server form) => await ServerService.Create(form);