feat: add ?dividend query param to all report endpoints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-23 15:53:53 +01:00
parent f79423219f
commit 02ca8bc9fb

View File

@@ -43,7 +43,8 @@ public class ReportController : ControllerBase
public async Task<IActionResult> GenerateReport(
[FromQuery(Name = "p")] string? encryptedIsin = null,
[FromQuery(Name = "alias")] string? aliasId = null,
[FromQuery(Name = "branding")] bool showBranding = false)
[FromQuery(Name = "branding")] bool showBranding = false,
[FromQuery(Name = "dividend")] bool showDividend = false)
{
string? isin = null;
@@ -70,7 +71,7 @@ public class ReportController : ControllerBase
return BadRequest("Specificare il parametro 'p' (ISIN cifrato) o 'alias' (alias ID).");
}
return await GenerateAndReturnPdf(isin, showBranding);
return await GenerateAndReturnPdf(isin, showBranding, showDividend);
}
/// <summary>
@@ -80,14 +81,15 @@ public class ReportController : ControllerBase
[HttpGet("by-isin/{isin}")]
public async Task<IActionResult> GenerateReportByIsin(
string isin,
[FromQuery(Name = "branding")] bool showBranding = false)
[FromQuery(Name = "branding")] bool showBranding = false,
[FromQuery(Name = "dividend")] bool showDividend = false)
{
if (string.IsNullOrWhiteSpace(isin) || isin.Length < 12)
{
return BadRequest("ISIN non valido.");
}
return await GenerateAndReturnPdf(isin, showBranding);
return await GenerateAndReturnPdf(isin, showBranding, showDividend);
}
/// <summary>
@@ -97,7 +99,8 @@ public class ReportController : ControllerBase
public async Task<IActionResult> DownloadReport(
[FromQuery(Name = "p")] string? encryptedIsin = null,
[FromQuery(Name = "alias")] string? aliasId = null,
[FromQuery(Name = "branding")] bool showBranding = false)
[FromQuery(Name = "branding")] bool showBranding = false,
[FromQuery(Name = "dividend")] bool showDividend = false)
{
string? isin = null;
@@ -111,7 +114,7 @@ public class ReportController : ControllerBase
try
{
var pdfBytes = await _orchestrator.GenerateReportAsync(isin, showBranding);
var pdfBytes = await _orchestrator.GenerateReportAsync(isin, showBranding, showDividend);
return File(pdfBytes, "application/pdf", $"{isin}.pdf");
}
catch (Exception ex)
@@ -123,12 +126,12 @@ public class ReportController : ControllerBase
// ─── Helper ────────────────────────────────────────────────────────
private async Task<IActionResult> GenerateAndReturnPdf(string isin, bool showBranding)
private async Task<IActionResult> GenerateAndReturnPdf(string isin, bool showBranding = false, bool showDividend = false)
{
try
{
_logger.LogInformation("Richiesta report per ISIN {Isin}", isin);
var pdfBytes = await _orchestrator.GenerateReportAsync(isin, showBranding);
var pdfBytes = await _orchestrator.GenerateReportAsync(isin, showBranding, showDividend);
// Inline: il PDF si apre direttamente nel browser
Response.Headers.Append("Content-Disposition", $"inline; filename={isin}.pdf");