-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathEndpoint.cs
More file actions
30 lines (24 loc) · 989 Bytes
/
Endpoint.cs
File metadata and controls
30 lines (24 loc) · 989 Bytes
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
using System.Text;
namespace Feature.PollingStations.GetImportTemplate;
public class Endpoint : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/polling-stations:import-template");
DontAutoTag();
Options(x => x.WithTags("polling-stations"));
Policies(PolicyNames.PlatformAdminsOnly);
}
public override async Task HandleAsync(CancellationToken ct)
{
const string template = """
"Level1", "Level2", "Level3", "Level4", "Level5", "Number", "Address", "DisplayOrder","Latitude", "Longitude", "Tag1", "Tag2", "Tag3"
""";
var stream = GenerateStreamFromString(template);
await SendStreamAsync(stream, "import-template.csv", stream.Length, "text/csv", cancellation: ct);
}
private static MemoryStream GenerateStreamFromString(string value)
{
return new MemoryStream(Encoding.UTF8.GetBytes(value));
}
}