public IActionResult FinishRound(Guid id, [FromBody] FinishedRoundModel roundModel) { lock (gameLock) { var game = gameRepository.Get(id).Result; var player = User.Identity.Name; if (game.FinishCurrentRound(roundModel.Consensus, player) is Failure <string> f) { return(StatusCode((int)HttpStatusCode.Forbidden, f.Data)); } gameRepository.Update(game).Wait(); return(Ok()); } }
public async Task <HttpResponseMessage> FinishRound(Guid id, [FromBody] FinishedRoundModel roundModel) { var game = await gameRepository.Get(id).ConfigureAwait(false); var player = Thread.CurrentPrincipal.Identity.Name; if (game.FinishCurrentRound(roundModel.Consensus, player) is Failure <string> f) { return(new HttpResponseMessage(HttpStatusCode.Forbidden) { Content = new StringContent(f.Data) }); } await gameRepository.Update(game).ConfigureAwait(false); return(new HttpResponseMessage(HttpStatusCode.OK)); }