57 lines
1.5 KiB
Plaintext
57 lines
1.5 KiB
Plaintext
@page "/servers/add"
|
|
@using System.ComponentModel.DataAnnotations
|
|
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<h3>Add server</h3>
|
|
<br/>
|
|
<br/>
|
|
<EditForm Model="server" FormName="formServer" OnValidSubmit="SubmitServer">
|
|
<DataAnnotationsValidator></DataAnnotationsValidator>
|
|
<ValidationSummary></ValidationSummary>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-2">
|
|
<label class="col-form-label">Name</label>
|
|
</div>
|
|
<div class="col-6">
|
|
<InputText @bind-Value="server.Name" class="form-control"></InputText>
|
|
</div>
|
|
<div class="col">
|
|
<ValidationMessage For="() => server.Name"></ValidationMessage>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-2">
|
|
<label class="col-form-label">City</label>
|
|
</div>
|
|
<div class="col-6">
|
|
<InputText @bind-Value="server.City" class="form-control"></InputText>
|
|
</div>
|
|
<div class="col">
|
|
<ValidationMessage For="() => server.City"></ValidationMessage>
|
|
</div>
|
|
</div>
|
|
<br/>
|
|
<button class="btn btn-primary" type="submit">Add</button>
|
|
|
|
<a href="/servers" class="btn btn-primary">Close</a>
|
|
</EditForm>
|
|
|
|
|
|
@code {
|
|
[SupplyParameterFromForm(FormName = "formServer")]
|
|
private Server server { get; set; } = new Server() { IsOnline = false };
|
|
|
|
private void SubmitServer()
|
|
{
|
|
if (server != null)
|
|
{
|
|
ServersRepository.AddServer(server);
|
|
}
|
|
|
|
// An exception is raised when debugging from VS Code, but not when using dotnet watch.
|
|
NavigationManager.NavigateTo("/servers");
|
|
}
|
|
} |