public async Task <ResultsEngineStatuses> Process(ITeamResultEngineContext context, IResultsEngineRequest request, ResultsEngineResponse response) { var status = ResultsEngineStatuses.Success; var pendingFixtures = await context.GetPendingFixtures(); foreach (TeamFixture pendingFixture in pendingFixtures) { var updateRequest = UpdatePendingTeamFixtureRequest.New() .WithCompetitionID(pendingFixture.CompetitionID) .WithFixtureID(pendingFixture.ID) .WithCompetitionStageID(pendingFixture.CompetitionRound.CompetitionEvent.CompetitionStage.ID) .WithCompletedFixture(context.Fixture.Data) .Build(); ITeamResultEngine engine = await this._teamResultEngineManager.GetEngine(updateRequest); var updateResponse = engine.UpdatePendingFixture(updateRequest); status = updateResponse.Status; if (status != ResultsEngineStatuses.Success) { break; } } return(status); }
public async Task <ApiResponse> SetAwayWalkover([FromRoute] int competitionID, [FromRoute] short fixtureID, [FromRoute] short matchID, [FromBody] dynamic data) { this._unitOfWork.Begin(); try { int competitionStageSequence = int.Parse(data.competitionStageSequence.ToString()); var request = SetMatchWalkoverRequest.New() .WithCompetitionID(competitionID) .WithCompetitionStageSequence(competitionStageSequence) .WithFixtureID(fixtureID) .WithMatchID(matchID) .WithWalkover(Walkover.Away) .Build(); ITeamResultEngine engine = await this._teamResultEngineManager.GetEngine(request); var response = await engine.SetWalkover(request); if (response.Status == ResultsEngineStatuses.Success) { await engine.Save(); await this._sessionProvider.Session.FlushAsync(); this._unitOfWork.SoftCommit(); return(ApiResponse.CreateSuccess(null)); } else { this._unitOfWork.Rollback(); return(ApiResponse.CreateError(response.ValidationResult)); } } catch (Exception e) { Console.WriteLine(e); this._unitOfWork.Rollback(); throw; } }
private async Task <ApiResponse> SaveTeamMatch(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(); ITeamResultEngine engine = await this._teamResultEngineManager.GetEngine(request); var response = engine.SaveStandardResult(request); if (response.Status == ResultsEngineStatuses.Success) { await engine.Save(); await this._sessionProvider.Session.FlushAsync(); this._unitOfWork.SoftCommit(); return(ApiResponse.CreateSuccess(null)); } else { this._unitOfWork.Rollback(); return(ApiResponse.CreateError(response.ValidationResult)); } } catch (Exception e) { Console.WriteLine(e); this._unitOfWork.Rollback(); throw; } }