Skip to content

Commit ab6c475

Browse files
authored
Merge pull request #65 from PandaTechAM/development
name fix
2 parents e911ca7 + b2cf7ed commit ab6c475

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

src/FileExporter/Extensions/EnumerableExtensions.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,7 @@ private static ExportFile CreateZip(string baseName, MimeTypes innerType, IReadO
162162
}
163163
}
164164

165-
// Ensure exactly one ".zip" on the outer file
166-
var outerName = baseName.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)
167-
? baseName
168-
: $"{baseName}.zip";
169-
170-
return new ExportFile(outerName, MimeTypes.Zip, ms.ToArray());
165+
return new ExportFile(baseName, MimeTypes.Zip, ms.ToArray());
171166
}
172167

173168
private static ExportFile ReturnFileOrZippedVersion<T>(DataTable<T> dataTable, List<byte[]> files, MimeTypes type)

src/FileExporter/FileExporter.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Copyright>MIT</Copyright>
99
<PackageIcon>Logo.jpg</PackageIcon>
1010
<PackageReadmeFile>Readme.md</PackageReadmeFile>
11-
<Version>4.1.1</Version>
11+
<Version>4.1.2</Version>
1212
<Company>PandaTech</Company>
1313
<Title>Model to File</Title>
1414
<PackageTags>Pandatech, lib, export, xlsx, csv, pdf</PackageTags>

test/FileExporter.Demo/Program.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
using FileExporter.Demo.ExportRules;
2+
using FileExporter.Demo.Models;
3+
using FileExporter.Enums;
4+
using FileExporter.Rules;
5+
using Microsoft.AspNetCore.Mvc;
6+
17
var builder = WebApplication.CreateBuilder(args);
28

39

@@ -20,7 +26,33 @@
2026

2127
app.MapControllers();
2228

23-
using var scope = app.Services.CreateScope();
24-
29+
app.MapGet("/export-dummy-csv",
30+
([FromQuery] ExportType exportType) =>
31+
{
32+
// some demo data
33+
var data = new List<DummyTable>
34+
{
35+
new()
36+
{
37+
Id = 1,
38+
RelatedId = 10,
39+
Name = "First",
40+
Comment = "Hello"
41+
},
42+
new()
43+
{
44+
Id = 2,
45+
RelatedId = 20,
46+
Name = "Second",
47+
Comment = "World"
48+
}
49+
};
50+
51+
var rule = new DummyExportRule();
52+
var exportFile = rule.ToFileFormat(data, exportType);
53+
54+
// Minimal API: return FileResult with correct headers
55+
return TypedResults.File(exportFile.Data, exportFile.Type, exportFile.Name);
56+
});
2557

2658
app.Run();

0 commit comments

Comments
 (0)