Beispiel #1
0
        private async Task SaveResult(int competitionID, int fixtureID, int matchID, List <GameResult> gameResults)
        {
            var playerResultEngineManager = this._serviceProvider.GetService <IPlayerResultEngineManager>();
            var request = SaveStandardResultRequest.New()
                          .WithCompetitionID(competitionID)
                          .WithCompetitionStageSequence(1)
                          .WithFixtureID((short)fixtureID)
                          .WithMatchID(matchID)
                          .WithGameResults(gameResults)
                          .Build();
            IPlayerResultEngine engine = playerResultEngineManager.GetEngine(request).GetAwaiter().GetResult();
            var response = engine.SaveStandardResult(request);

            if (response.Status == ResultsEngineStatuses.Success)
            {
                await engine.Save();

                await this._sessionProvider.Session.FlushAsync();
            }
            else
            {
                foreach (var error in response.ValidationResult.Errors)
                {
                    Console.WriteLine(error.ErrorMessage);
                }

                throw new InvalidOperationException();
            }
        }
Beispiel #2
0
        private async Task <ApiResponse> SavePlayerMatch(int competitionID, short fixtureID, short matchID, dynamic data, List <GameResult> gameResults)
        {
            this._unitOfWork.Begin();
            try
            {
                var request = SaveStandardResultRequest.New()
                              .WithCompetitionID(competitionID)
                              .WithCompetitionStageSequence(int.Parse(data.competitionStageSequence.ToString()))
                              .WithFixtureID(fixtureID)
                              .WithMatchID(matchID)
                              .WithGameResults(gameResults)
                              .Build();
                IPlayerResultEngine engine = await this._playerResultEngineManager.GetEngine(request);

                var response = engine.SaveStandardResult(request);
                if (response.Status == ResultsEngineStatuses.Success)
                {
                    await engine.Save();

                    await this._sessionProvider.Session.FlushAsync();

                    this._unitOfWork.SoftCommit();
                }
                else
                {
                    this._unitOfWork.Rollback();
                    foreach (var error in response.ValidationResult.Errors)
                    {
                        Console.WriteLine(error.ErrorMessage);
                    }
                }

                return(ApiResponse.CreateError(response.ValidationResult));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                this._unitOfWork.Rollback();
                throw;
            }
        }