- Switch to custom edit model (MassDataEditModel) for popup editing, enabling granular field validation and UI control - Replace default editors with explicit DxTextBox/DxCheckBox bindings - Add AmountText field for string input and validation; validate and convert in OnEditModelSaving - Implement duplicate customer check via new GetByCustomerNameAsync API method - Show ValidationSummary in popup; manage validation state with ValidationMessageStore and EditContext - Make popup header and width dynamic; show procedure ComboBox only for existing records - Restore "New" button in grid command column - Refactor CatalogsGrid to handle validation clearing in OnEditFieldChanged instead of OnTitleChanged - General improvements to real-time validation feedback
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using System.Net.Http.Json;
|
|
using DbFirst.BlazorWebApp.Models;
|
|
|
|
namespace DbFirst.BlazorWebApp.Services;
|
|
|
|
public class MassDataApiClient
|
|
{
|
|
private readonly HttpClient _httpClient;
|
|
private const string Endpoint = "api/massdata";
|
|
|
|
public MassDataApiClient(HttpClient httpClient)
|
|
{
|
|
_httpClient = httpClient;
|
|
}
|
|
|
|
public async Task<int> GetCountAsync()
|
|
{
|
|
var result = await _httpClient.GetFromJsonAsync<int?>("api/massdata/count");
|
|
return result ?? 0;
|
|
}
|
|
|
|
public async Task<List<MassDataReadDto>> GetAllAsync(int skip, int take)
|
|
{
|
|
var result = await _httpClient.GetFromJsonAsync<List<MassDataReadDto>>($"{Endpoint}?skip={skip}&take={take}");
|
|
return result ?? new List<MassDataReadDto>();
|
|
}
|
|
|
|
public async Task<MassDataReadDto> UpsertAsync(MassDataWriteDto dto)
|
|
{
|
|
var response = await _httpClient.PostAsJsonAsync($"{Endpoint}/upsert", dto);
|
|
response.EnsureSuccessStatusCode();
|
|
var payload = await response.Content.ReadFromJsonAsync<MassDataReadDto>();
|
|
return payload ?? new MassDataReadDto();
|
|
}
|
|
|
|
public async Task<MassDataReadDto?> GetByCustomerNameAsync(string customerName)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(customerName))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var response = await _httpClient.GetAsync($"{Endpoint}/{Uri.EscapeDataString(customerName)}");
|
|
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
response.EnsureSuccessStatusCode();
|
|
return await response.Content.ReadFromJsonAsync<MassDataReadDto>();
|
|
}
|
|
}
|