Users can now choose how many records to display per page in the MassData grid (100, 1,000, 10,000, 100,000, or all). The backend and API client are updated to support nullable skip/take parameters, allowing "all" records to be fetched when desired. The pager and page count calculations are updated to reflect the selected page size, and the pager is hidden if only one page exists. Additional UI and CSS changes provide a combo box for page size selection. The API controller now treats take <= 0 as "no limit."
59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using DbFirst.Application.MassData;
|
|
using DbFirst.Application.MassData.Commands;
|
|
using DbFirst.Application.MassData.Queries;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace DbFirst.API.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class MassDataController : ControllerBase
|
|
{
|
|
private readonly IMediator _mediator;
|
|
|
|
public MassDataController(IMediator mediator)
|
|
{
|
|
_mediator = mediator;
|
|
}
|
|
|
|
[HttpGet("count")]
|
|
public async Task<ActionResult<int>> GetCount(CancellationToken cancellationToken)
|
|
{
|
|
var count = await _mediator.Send(new GetMassDataCountQuery(), cancellationToken);
|
|
return Ok(count);
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<ActionResult<IEnumerable<MassDataReadDto>>> GetAll([FromQuery] int? skip, [FromQuery] int? take, CancellationToken cancellationToken)
|
|
{
|
|
int? resolvedTake = take;
|
|
if (resolvedTake is <= 0)
|
|
{
|
|
resolvedTake = null;
|
|
}
|
|
|
|
var result = await _mediator.Send(new GetAllMassDataQuery(skip, resolvedTake), cancellationToken);
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpGet("{customerName}")]
|
|
public async Task<ActionResult<MassDataReadDto>> GetByCustomerName(string customerName, CancellationToken cancellationToken)
|
|
{
|
|
var result = await _mediator.Send(new GetMassDataByCustomerNameQuery(customerName), cancellationToken);
|
|
if (result == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
return Ok(result);
|
|
}
|
|
|
|
[HttpPost("upsert")]
|
|
public async Task<ActionResult<MassDataReadDto>> Upsert(MassDataWriteDto dto, CancellationToken cancellationToken)
|
|
{
|
|
var result = await _mediator.Send(new UpsertMassDataByCustomerNameCommand(dto), cancellationToken);
|
|
return Ok(result);
|
|
}
|
|
}
|