feat(application): repository abstraction + DTOs + validators + handlers CRUD PuntosDeVenta con auditoría + retry deadlock

This commit is contained in:
2026-04-17 12:28:11 -03:00
parent 43877bd4a1
commit 50f6f2b67a
36 changed files with 1296 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
namespace SIGCM2.Application.PuntosDeVenta.List;
public sealed record ListPuntosDeVentaQuery(
int Page,
int PageSize,
int? MedioId,
bool? Activo);

View File

@@ -0,0 +1,30 @@
using SIGCM2.Application.Abstractions;
using SIGCM2.Application.Abstractions.Persistence;
using SIGCM2.Application.Common;
namespace SIGCM2.Application.PuntosDeVenta.List;
public sealed class ListPuntosDeVentaQueryHandler : ICommandHandler<ListPuntosDeVentaQuery, PagedResult<PuntoDeVentaListItemDto>>
{
private readonly IPuntoDeVentaRepository _repo;
public ListPuntosDeVentaQueryHandler(IPuntoDeVentaRepository repo)
{
_repo = repo;
}
public async Task<PagedResult<PuntoDeVentaListItemDto>> Handle(ListPuntosDeVentaQuery query)
{
var page = Math.Max(1, query.Page);
var pageSize = Math.Clamp(query.PageSize, 1, 100);
var repoQuery = new PuntosDeVentaQuery(page, pageSize, query.MedioId, query.Activo);
var paged = await _repo.GetPagedAsync(repoQuery);
var items = paged.Items
.Select(p => new PuntoDeVentaListItemDto(p.Id, p.MedioId, p.NumeroAFIP, p.Nombre, p.Activo))
.ToList();
return new PagedResult<PuntoDeVentaListItemDto>(items, paged.Page, paged.PageSize, paged.Total);
}
}

View File

@@ -0,0 +1,8 @@
namespace SIGCM2.Application.PuntosDeVenta.List;
public sealed record PuntoDeVentaListItemDto(
int Id,
int MedioId,
short NumeroAFIP,
string Nombre,
bool Activo);