Add Endpoint GET {steamId}/Total/{appId}"
This commit is contained in:
parent
227346e096
commit
92397eea18
@ -54,6 +54,21 @@ public class TimeTrackController(Context databaseContext) : ApiController(typeof
|
||||
return Ok(sum);
|
||||
}
|
||||
|
||||
[HttpGet("{steamId}/Total/{appId}")]
|
||||
[ProducesResponseType<ulong>(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<KeyValuePair<ulong, ulong>[]>(Status200OK)]
|
||||
[ProducesResponseType(Status404NotFound)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user