feat: add ?dividend query param to all report endpoints
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,7 +43,8 @@ public class ReportController : ControllerBase
|
|||||||
public async Task<IActionResult> GenerateReport(
|
public async Task<IActionResult> GenerateReport(
|
||||||
[FromQuery(Name = "p")] string? encryptedIsin = null,
|
[FromQuery(Name = "p")] string? encryptedIsin = null,
|
||||||
[FromQuery(Name = "alias")] string? aliasId = 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;
|
string? isin = null;
|
||||||
|
|
||||||
@@ -70,7 +71,7 @@ public class ReportController : ControllerBase
|
|||||||
return BadRequest("Specificare il parametro 'p' (ISIN cifrato) o 'alias' (alias ID).");
|
return BadRequest("Specificare il parametro 'p' (ISIN cifrato) o 'alias' (alias ID).");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await GenerateAndReturnPdf(isin, showBranding);
|
return await GenerateAndReturnPdf(isin, showBranding, showDividend);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -80,14 +81,15 @@ public class ReportController : ControllerBase
|
|||||||
[HttpGet("by-isin/{isin}")]
|
[HttpGet("by-isin/{isin}")]
|
||||||
public async Task<IActionResult> GenerateReportByIsin(
|
public async Task<IActionResult> GenerateReportByIsin(
|
||||||
string isin,
|
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)
|
if (string.IsNullOrWhiteSpace(isin) || isin.Length < 12)
|
||||||
{
|
{
|
||||||
return BadRequest("ISIN non valido.");
|
return BadRequest("ISIN non valido.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await GenerateAndReturnPdf(isin, showBranding);
|
return await GenerateAndReturnPdf(isin, showBranding, showDividend);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -97,7 +99,8 @@ public class ReportController : ControllerBase
|
|||||||
public async Task<IActionResult> DownloadReport(
|
public async Task<IActionResult> DownloadReport(
|
||||||
[FromQuery(Name = "p")] string? encryptedIsin = null,
|
[FromQuery(Name = "p")] string? encryptedIsin = null,
|
||||||
[FromQuery(Name = "alias")] string? aliasId = 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;
|
string? isin = null;
|
||||||
|
|
||||||
@@ -111,7 +114,7 @@ public class ReportController : ControllerBase
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pdfBytes = await _orchestrator.GenerateReportAsync(isin, showBranding);
|
var pdfBytes = await _orchestrator.GenerateReportAsync(isin, showBranding, showDividend);
|
||||||
return File(pdfBytes, "application/pdf", $"{isin}.pdf");
|
return File(pdfBytes, "application/pdf", $"{isin}.pdf");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -123,12 +126,12 @@ public class ReportController : ControllerBase
|
|||||||
|
|
||||||
// ─── Helper ────────────────────────────────────────────────────────
|
// ─── Helper ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
private async Task<IActionResult> GenerateAndReturnPdf(string isin, bool showBranding)
|
private async Task<IActionResult> GenerateAndReturnPdf(string isin, bool showBranding = false, bool showDividend = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Richiesta report per ISIN {Isin}", isin);
|
_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
|
// Inline: il PDF si apre direttamente nel browser
|
||||||
Response.Headers.Append("Content-Disposition", $"inline; filename={isin}.pdf");
|
Response.Headers.Append("Content-Disposition", $"inline; filename={isin}.pdf");
|
||||||
|
|||||||
Reference in New Issue
Block a user