Add MassData feature with API, paging, and Blazor grid
Introduces MassData management to backend and Blazor frontend: - Adds API endpoint for MassData count and paging - Updates repository and controller for count support - Implements MediatR query/handler for count - Adds Blazor page and grid for viewing/editing MassData - Registers MassDataApiClient and integrates with DI - Supports paging, upsert, and UI feedback in grid
This commit is contained in:
35
DbFirst.BlazorWebApp/Services/MassDataApiClient.cs
Normal file
35
DbFirst.BlazorWebApp/Services/MassDataApiClient.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user