public IActionResult NewRound(Guid id, [FromBody] NewRoundModel roundModel)
        {
            lock (gameLock)
            {
                var game   = gameRepository.Get(id).Result;
                var player = User.Identity.Name;

                if (game.NewRound(roundModel.Subject, player) is Failure <string> f)
                {
                    return(StatusCode((int)HttpStatusCode.Forbidden, f.Data));
                }

                gameRepository.Update(game).Wait();
                return(Ok());
            }
        }
Example #2
0
        public async Task <HttpResponseMessage> NewRound(Guid id, [FromBody] NewRoundModel roundModel)
        {
            var game = await gameRepository.Get(id).ConfigureAwait(false);

            var player = Thread.CurrentPrincipal.Identity.Name;

            if (game.NewRound(roundModel.Subject, 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));
        }