示例#1
0
        public async Task <StartGameRoundResult> Handle(StartGameRound request, CancellationToken cancellationToken)
        {
            using (var transaction = repositoryTransactionsFactory.CreateTransaction())
            {
                var validatorResult = await validator.Validate(request);

                if (!validatorResult.IsSuccessful)
                {
                    return(new StartGameRoundResult(validatorResult.Error));
                }

                var started = await gameRoundsRepository
                              .UpdateGameRoundStatus(request.GameRoundId, Common.Enums.GameRoundStatusEnum.InProgress);

                if (!started)
                {
                    return(new StartGameRoundResult(GameErrors.GameRoundCouldNotBeStarted));
                }

                var checkpoint = await gameCheckpointUpdater.Update(request.GameId, nameof(StartGameRound));

                transaction.CommitTransaction();

                return(new StartGameRoundResult());
            }
        }
示例#2
0
        public async Task <EndSubmissionsResult> Handle(EndSubmissions request, CancellationToken cancellationToken)
        {
            using (var transaction = repositoryTransactionsFactory.CreateTransaction())
            {
                var validationResult = await requestValidator.Validate(request);

                if (!validationResult.IsSuccessful)
                {
                    return(new EndSubmissionsResult(validationResult.Error));
                }

                var updated = await gameRoundsRepository
                              .UpdateGameRoundStatus(request.GameRoundId, Common.Enums.GameRoundStatusEnum.Selection);

                if (!updated)
                {
                    return(new EndSubmissionsResult(GameErrors.CouldNotEndAnswersSubmissions));
                }

                var checkpoint = await gameCheckpointUpdater.Update(request.GameId, nameof(EndSubmissions));

                transaction.CommitTransaction();

                return(new EndSubmissionsResult());
            }
        }