Completed server variables in server crud

This commit is contained in:
2024-12-23 23:51:01 +01:00
parent 2b697dffb7
commit 4326af2925
8 changed files with 159 additions and 27 deletions

View File

@@ -146,11 +146,13 @@ public class ServersController : Controller
// Variables
foreach (var variable in star.Variables)
{
var requestVar = request.Variables.FirstOrDefault(x => x.Key == variable.Key);
var serverVar = new ServerVariable()
{
Key = variable.Key,
Value = request.Variables.TryGetValue(variable.Key, out var value)
? value
Value = requestVar != null
? requestVar.Value
: variable.DefaultValue
};
@@ -207,6 +209,22 @@ public class ServersController : Controller
// Set allocations
server.Allocations = allocations;
// Process variables
foreach (var variable in request.Variables)
{
// Search server variable associated to the variable in the request
var serverVar = server.Variables
.FirstOrDefault(x => x.Key == variable.Key);
if(serverVar == null)
continue;
// Update value
serverVar.Value = variable.Value;
}
// TODO: Call node
ServerRepository.Update(server);
return CrudHelper.MapToResult(server);