public async Task <DomainValidationResult <Participant> > SnapshotChallengeParticipantAsync( IChallenge challenge, PlayerId gamePlayerId, IDateTimeProvider synchronizedAt, Func <IScoring, IImmutableSet <Match> > snapshotMatches, CancellationToken cancellationToken = default ) { var result = new DomainValidationResult <Participant>(); if (!challenge.ParticipantExists(gamePlayerId)) { result.AddFailedPreconditionError("Participant doesn't exists."); } if (result.IsValid) { var participant = challenge.FindParticipant(gamePlayerId); var matches = snapshotMatches(challenge.Scoring); participant.Snapshot(matches, synchronizedAt); await _challengeRepository.CommitAsync(true, cancellationToken); return(participant); } return(result); }