feat(medios,secciones): application layer + handlers TDD — ADM-001 B3+B4
- IMedioRepository, ISeccionRepository interfaces - MediosQuery, SeccionesQuery common records - TipoSeccion static AllowedTipos helper - Medios: 6 use cases (Create/Update/Deactivate/Reactivate/List/GetById) with validators, handlers and DTOs - Secciones: 6 use cases mirroring Medios; Create validates MedioId active via IMedioRepository - 52 unit tests (xUnit + NSubstitute) all green; audit LogAsync asserted per mutating handler - DI registrations for all 12 handlers and validators auto-scanned via AddValidatorsFromAssemblyContaining
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
namespace SIGCM2.Application.Medios.GetById;
|
||||
|
||||
public sealed record GetMedioByIdQuery(int Id);
|
||||
@@ -0,0 +1,31 @@
|
||||
using SIGCM2.Application.Abstractions;
|
||||
using SIGCM2.Application.Abstractions.Persistence;
|
||||
using SIGCM2.Domain.Exceptions;
|
||||
|
||||
namespace SIGCM2.Application.Medios.GetById;
|
||||
|
||||
public sealed class GetMedioByIdQueryHandler : ICommandHandler<GetMedioByIdQuery, MedioDetailDto>
|
||||
{
|
||||
private readonly IMedioRepository _repo;
|
||||
|
||||
public GetMedioByIdQueryHandler(IMedioRepository repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
public async Task<MedioDetailDto> Handle(GetMedioByIdQuery query)
|
||||
{
|
||||
var medio = await _repo.GetByIdAsync(query.Id)
|
||||
?? throw new MedioNotFoundException(query.Id);
|
||||
|
||||
return new MedioDetailDto(
|
||||
Id: medio.Id,
|
||||
Codigo: medio.Codigo,
|
||||
Nombre: medio.Nombre,
|
||||
Tipo: medio.Tipo,
|
||||
PlataformaEmpresaId: medio.PlataformaEmpresaId,
|
||||
Activo: medio.Activo,
|
||||
FechaCreacion: medio.FechaCreacion,
|
||||
FechaModificacion: medio.FechaModificacion);
|
||||
}
|
||||
}
|
||||
13
src/api/SIGCM2.Application/Medios/GetById/MedioDetailDto.cs
Normal file
13
src/api/SIGCM2.Application/Medios/GetById/MedioDetailDto.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using SIGCM2.Domain.Entities;
|
||||
|
||||
namespace SIGCM2.Application.Medios.GetById;
|
||||
|
||||
public sealed record MedioDetailDto(
|
||||
int Id,
|
||||
string Codigo,
|
||||
string Nombre,
|
||||
TipoMedio Tipo,
|
||||
int? PlataformaEmpresaId,
|
||||
bool Activo,
|
||||
DateTime FechaCreacion,
|
||||
DateTime? FechaModificacion);
|
||||
Reference in New Issue
Block a user