|
|
@@ -2,6 +2,7 @@ using System.Security.Claims;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using RunnersMeet.Server.Domain;
|
|
|
+using RunnersMeet.Server.GpxFormat;
|
|
|
using RunnersMeet.Server.Persistence;
|
|
|
|
|
|
namespace RunnersMeet.Server.Controllers;
|
|
|
@@ -12,11 +13,13 @@ namespace RunnersMeet.Server.Controllers;
|
|
|
public class TracksController : ControllerBase
|
|
|
{
|
|
|
private readonly IFileStorage _fileStorage;
|
|
|
+ private readonly GpxParser _gpxParser;
|
|
|
private readonly QueryFactory _queryFactory;
|
|
|
|
|
|
- public TracksController(IFileStorage fileStorage, QueryFactory queryFactory)
|
|
|
+ public TracksController(IFileStorage fileStorage, GpxParser gpxParser, QueryFactory queryFactory)
|
|
|
{
|
|
|
_fileStorage = fileStorage;
|
|
|
+ _gpxParser = gpxParser;
|
|
|
_queryFactory = queryFactory;
|
|
|
}
|
|
|
|
|
|
@@ -31,8 +34,9 @@ public class TracksController : ControllerBase
|
|
|
{
|
|
|
var fileName = await _fileStorage.UploadFileAsync(file, name, cancellationToken);
|
|
|
|
|
|
+ var gpxSummary = _gpxParser.ExtractSummary(_fileStorage.OpenFileRead(fileName));
|
|
|
var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? "<unknown>";
|
|
|
- var track = _queryFactory.CreateTrackCommand().Create(userId, fileName);
|
|
|
+ var track = _queryFactory.CreateTrackCommand().Create(userId, fileName, gpxSummary);
|
|
|
|
|
|
return Ok(track);
|
|
|
}
|