40 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
		
		
			
		
	
	
			40 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
|  | using GestionIntegral.Api.Dtos.Comunicaciones; | ||
|  | using GestionIntegral.Api.Services.Comunicaciones; | ||
|  | using Microsoft.AspNetCore.Authorization; | ||
|  | using Microsoft.AspNetCore.Mvc; | ||
|  | 
 | ||
|  | namespace GestionIntegral.Api.Controllers.Comunicaciones | ||
|  | { | ||
|  |     [Route("api/lotes-envio")] | ||
|  |     [ApiController] | ||
|  |     [Authorize] | ||
|  |     public class LotesEnvioController : ControllerBase | ||
|  |     { | ||
|  |         private readonly IEmailLogService _emailLogService; | ||
|  | 
 | ||
|  |         public LotesEnvioController(IEmailLogService emailLogService) | ||
|  |         { | ||
|  |             _emailLogService = emailLogService; | ||
|  |         } | ||
|  | 
 | ||
|  |         // GET: api/lotes-envio/123/detalles | ||
|  |         [HttpGet("{idLote:int}/detalles")] | ||
|  |         [ProducesResponseType(typeof(IEnumerable<EmailLogDto>), StatusCodes.Status200OK)] | ||
|  |         [ProducesResponseType(StatusCodes.Status403Forbidden)] | ||
|  |         [ProducesResponseType(StatusCodes.Status404NotFound)] | ||
|  |         public async Task<IActionResult> GetDetallesLote(int idLote) | ||
|  |         { | ||
|  |             // Reutilizamos un permiso existente, ya que esta es una función de auditoría relacionada. | ||
|  |             var tienePermiso = User.IsInRole("SuperAdmin") || User.HasClaim(c => c.Type == "permission" && c.Value == "SU006"); | ||
|  |             if (!tienePermiso) | ||
|  |             { | ||
|  |                 return Forbid(); | ||
|  |             } | ||
|  | 
 | ||
|  |             var detalles = await _emailLogService.ObtenerDetallesPorLoteId(idLote); | ||
|  |              | ||
|  |             // Devolvemos OK con un array vacío si no hay resultados, el frontend lo manejará. | ||
|  |             return Ok(detalles); | ||
|  |         } | ||
|  |     } | ||
|  | } |