Сделал привязку местоположений и принтеров к местоположениям

This commit is contained in:
Hukuta committed 2026-04-28 13:52:50 +09:00
1 parent d69a5689e8
commit 13b3513d2d
49 files changed
+705 -1323

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
@page "/LocationsAdd"
@using System.Net.Http.Json
@using System.ComponentModel.DataAnnotations
@inject HttpClient Http
@inject NavigationManager Nav
<EditForm Model="model" OnValidSubmit="Create">
<DataAnnotationsValidator />
<div style="max-width:400px;">
<RadzenLabel Text="Название местоположения" />
<RadzenTextBox @bind-Value="model.Name" Style="width:100%;" />
<ValidationMessage For="@(() => model.Name)" />
<div style="margin-top:12px;">
<RadzenButton ButtonType="ButtonType.Submit" Text="Создать" />
<RadzenButton ButtonType="ButtonType.Button" Text="Отмена" />
</div>
</div>
</EditForm>
@code {
private CreateLocationModel model = new();
private async Task Create()
{
var resp = await Http.PostAsJsonAsync("api/locations", new { Name = model.Name });
if (resp.IsSuccessStatusCode) Nav.NavigateTo("/locations");
else
{
var err = await resp.Content.ReadAsStringAsync();
// простая обработка ошибки
await JS.InvokeVoidAsync("alert", $"Ошибка: {err}");
}
}
public class CreateLocationModel
{
[Required(ErrorMessage = "Имя обязательно")]
[StringLength(200)]
public string Name { get; set; } = string.Empty;
}
[Inject] IJSRuntime JS { get; set; } = default!;
}