public async Task <DomainValidationResult <IChallenge> > SynchronizeChallengeAsync( IChallenge challenge, IDateTimeProvider synchronizedAt, CancellationToken cancellationToken = default ) { var result = new DomainValidationResult <IChallenge>(); if (!challenge.CanSynchronize()) { result.AddFailedPreconditionError("Challenge wasn't synchronized due to is current state."); } if (result.IsValid) { challenge.Synchronize(synchronizedAt); await _challengeRepository.CommitAsync(true, cancellationToken); return(challenge.Cast <Challenge>()); } return(result); }