public async Task <DomainValidationResult <IChallenge> > CloseChallengeAsync( IChallenge challenge, IDateTimeProvider provider, CancellationToken cancellationToken = default ) { var result = new DomainValidationResult <IChallenge>(); if (!challenge.CanClose()) { result.AddFailedPreconditionError("Challenge can't be closed."); } if (result.IsValid) { challenge.Close(provider); await _challengeRepository.CommitAsync(true, cancellationToken); return(challenge.Cast <Challenge>()); } return(result); }
public async Task CloseChallengeAsync(IChallenge challenge, Dictionary <UserId, decimal?> scoreboard, CancellationToken cancellationToken = default) { challenge.Close(new ChallengeScoreboard(challenge.Payout, scoreboard)); await _challengeRepository.CommitAsync(true, cancellationToken); }