@page "/admin/servers/all/create" @using MoonCore.Blazor.FlyonUi.Components @using MoonCore.Blazor.FlyonUi.Toasts @using MoonCore.Helpers @using Moonlight.Shared.Http.Responses.Admin.Users @using MoonlightServers.Shared.Http.Requests.Admin.Servers @using MoonlightServers.Frontend.UI.Components.Servers.CreatePartials @using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations @using MoonlightServers.Shared.Http.Responses.Admin.Nodes @using MoonlightServers.Shared.Http.Responses.Admin.Stars @inject HttpApiClient ApiClient @inject NavigationManager Navigation @inject ToastService ToastService @attribute [Authorize(Policy = "permissions:admin.servers.create")] Back Create
@code { private HandleForm Form; private CreateServerRequest Request; public List Allocations = new(); public UserResponse? Owner; public StarResponse? Star; public NodeResponse? Node; protected override void OnInitialized() { Request = new(); } private async Task OnSubmit() { Request.AllocationIds = Allocations .Select(x => x.Id) .ToArray(); Request.StarId = Star?.Id ?? -1; Request.NodeId = Node?.Id ?? -1; Request.OwnerId = Owner?.Id ?? -1; await ApiClient.Post("api/admin/servers", Request); await ToastService.SuccessAsync("Successfully created Server"); Navigation.NavigateTo("/admin/servers/all"); } }