diff --git a/API/Controllers/TimeTrackController.cs b/API/Controllers/TimeTrackController.cs index 3d04f7a..10162cb 100644 --- a/API/Controllers/TimeTrackController.cs +++ b/API/Controllers/TimeTrackController.cs @@ -54,6 +54,21 @@ public class TimeTrackController(Context databaseContext) : ApiController(typeof return Ok(sum); } + [HttpGet("{steamId}/Total/{appId}")] + [ProducesResponseType(Status200OK)] + [ProducesResponseType(Status404NotFound)] + public IActionResult GetTrackedTimeAll(ulong steamId, ulong appId) + { + if (databaseContext.Players.Find(steamId) is not { } player) + return NotFound(); + if (databaseContext.Games.Find(appId) is not { } game) + return NotFound(); + databaseContext.Entry(player).Collection(p => p.TrackedTimes).Load(); + ulong? maxTime = player.TrackedTimes.Where(t => t.Game == game).MaxBy(t => t.TimePlayed)?.TimePlayed; + + return maxTime is not null ? Ok(maxTime) : NoContent(); + } + [HttpGet("{steamId}/Total/PerGame")] [ProducesResponseType[]>(Status200OK)] [ProducesResponseType(Status404NotFound)]