-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUploadController.cs
More file actions
35 lines (29 loc) · 945 Bytes
/
Copy pathUploadController.cs
File metadata and controls
35 lines (29 loc) · 945 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
31
32
33
34
35
using System.Globalization;
using Lib.AspNetCore.ServerSentEvents;
using Microsoft.AspNetCore.Mvc;
namespace FaFLobbySimServer.Controllers;
[ApiController]
[Route("upload")]
public class UploadController : ControllerBase
{
private readonly IServerSentEventsService _sseService;
public UploadController(IServerSentEventsService sseService)
{
_sseService = sseService;
}
[HttpPost]
public async Task<IActionResult> Upload([FromBody] OccupancyUpload upload)
{
SystemStore.StoreLatest(upload.Identifier, upload.Occupied, upload.Total);
await _sseService.SendEventAsync(new ServerSentEvent
{
Id = upload.Identifier,
Data = new List<string>
{
upload.Occupied.ToString("F0", CultureInfo.InvariantCulture),
upload.Total.ToString("F0", CultureInfo.InvariantCulture)
}
});
return Ok();
}
}