-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExportController.cs
More file actions
42 lines (38 loc) · 1.43 KB
/
ExportController.cs
File metadata and controls
42 lines (38 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using BlazorAppSpreadsheet;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace BlazorAppSpreadsheet
{
[Route("api/[controller]")]
[ApiController]
public class ExportController : ControllerBase
{
readonly DocumentService documentService;
public ExportController(DocumentService documentService)
{
this.documentService = documentService;
}
[HttpGet]
[Route("[action]")]
public async Task<IActionResult> Xlsx([FromQuery] double loanAmount,
[FromQuery] int periodInYears, [FromQuery] double interestRate,
[FromQuery] DateTime loanStartDate)
{
var document = await documentService.GetXlsxDocumentAsync(loanAmount, periodInYears,
interestRate, loanStartDate);
return File(document, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"output.xlsx");
}
[HttpGet]
[Route("[action]")]
public async Task<IActionResult> Pdf([FromQuery] double loanAmount,
[FromQuery] int periodInYears, [FromQuery] double interestRate,
[FromQuery] DateTime loanStartDate)
{
var document = await documentService.GetPdfDocumentAsync(loanAmount, periodInYears,
interestRate, loanStartDate);
return File(document, "application/pdf", "output.pdf");
}
}
}