using SIGCM2.Application.Abstractions; using SIGCM2.Application.Abstractions.Persistence; using SIGCM2.Application.Pricing.ChargeableChars; using SIGCM2.Domain.Pricing.ChargeableChars; namespace SIGCM2.Application.Pricing.ChargeableChars.GetById; /// /// PRC-001 — Handler for GetChargeableCharConfigByIdQuery. /// Returns null DTO when not found (API layer maps to 404). /// public sealed class GetChargeableCharConfigByIdQueryHandler : ICommandHandler { private readonly IChargeableCharConfigRepository _repo; public GetChargeableCharConfigByIdQueryHandler(IChargeableCharConfigRepository repo) { _repo = repo; } public async Task Handle(GetChargeableCharConfigByIdQuery query) { var entity = await _repo.GetByIdAsync(query.Id); return entity is null ? null : ToDto(entity); } private static ChargeableCharConfigDto ToDto(ChargeableCharConfig c) => new( c.Id, c.MedioId, c.Symbol, c.Category, c.PricePerUnit, c.ValidFrom, c.ValidTo, c.IsActive); }