public IActionResult NewEntry([FromForm] EditDto entry) { if (!ModelState.IsValid) { return(BadRequest()); } if (!_isAdmin) { return(Unauthorized()); } _leaderboard.InsertEntry(entry.Name1, entry.Name2, entry.Score, entry.Mode); _hubContext.Clients.All.SendAsync("Update"); return(Redirect(Request.Headers["Referer"])); }
public IActionResult EndGame([FromBody] EndParameters endParams) { if (endParams.Success) { TimeSpan disarmTime = _gameContext.GetTimeSpend(endParams.EndTime); int score = Convert.ToInt32(disarmTime.TotalMilliseconds / 10); _leaderboard.InsertEntry(_gameContext.AgentName, _gameContext.DisarmerName, score, _gameContext.Mode); } var socket = IO.Socket(_configuration["ChatURL"]); socket.Emit("new"); _gameContext.EndGame(); return(this.Ok(_gameContext.GetBombRemainingTime(endParams.EndTime))); }