示例#1
0
        public async Task <Response> Handle(AddGameRound request, CancellationToken cancellationToken)
        {
            var game = await _gameRepo.GetById(request.GameId);

            if (game == null)
            {
                throw new DomainException(ErrorCode.GameNotFound, $"A game with id '{request.GameId}' was not found");
            }

            var current = await _roundRepo.GetCurrentRound(request.GameId);

            await _roundRepo.UpdateRoundTimestamp(request.GameId, current.Id, DateTimeOffset.Now);

            await _roundRepo.AddRound(request.GameId, new Round
            {
                Id = request.Id,
                StartedTimestamp = DateTimeOffset.Now,
                Subject          = request.Subject,
                RoundVersion     = request.RoundVersion
            });

            return(Response.Success);
        }