public OperationResult Consume(VerificationCodeProvided message) { if (!SagaData.IsVerificationCodeSent) { throw new Exception("Verification code is not sent. How did you get here?"); } if (SagaData.VerificationCode != message.VerificationCode) { return(new OperationResult("Verification Code is not set")); } if (SagaData.VerificationCodeSentDate.Value.AddDays(1) < DateTime.UtcNow) { return(new OperationResult("Verification code has expired. Please request a new one")); } if (message.VerificationCode != SagaData.VerificationCode) { return(new OperationResult("Verification code does not match. Please try again")); } Console.WriteLine("Verificaton code provided matches!"); SagaData.IsVerificationCodeMatched = true; return(new OperationResult()); }
private static void ProvideVerificationCode(Guid correlationId) { var verificationCode = new VerificationCodeProvided(correlationId) { VerificationCode = "123456", }; _sagaMediator.Consume(verificationCode); }