@using System.Collections.ObjectModel @using LANCommander.SDK.Enums @inject ServerConsoleService ServerConsoleService @inject IMessageService MessageService @inject ILogger Logger @if (_consoles == null || _consoles.Count == 0) { } @foreach (var console in _consoles) { @if (console.Type == ServerConsoleType.RCON) { @code { [Parameter] public Guid ServerId { get; set; } ObservableCollection _consoles = new(); protected override async Task OnInitializedAsync() => await LoadConsoles(); async Task LoadConsoles() { _consoles = new ObservableCollection(await ServerConsoleService.GetAsync(c => c.ServerId == ServerId)); } public async Task Save() { try { foreach (var console in _consoles) { if (console.Id == Guid.Empty) await ServerConsoleService.AddAsync(console); else await ServerConsoleService.UpdateAsync(console); } await LoadConsoles(); MessageService.Success("Consoles updated!"); } catch (Exception ex) { MessageService.Error("Could not update consoles!"); Logger.LogError(ex, "Could not update consoles!"); } } private void Add() { _consoles.Add(new ServerConsole { ServerId = ServerId, }); } private void Remove(ServerConsole console) { _consoles.Remove(console); } }