public async Task SendMailVerificationCode(string mailAddress) { var code = VerificationCodeGenerater.GenerateCode(); Expression <Func <Task> > expression = () => _emailSender.SendMessage(mailAddress, L("VerificationSubject"), string.Format(L("VerificationBody"), code)); Hangfire.BackgroundJob.Schedule(expression, TimeSpan.Zero); await _messageHistoryRepository.InsertAsync(new MessageHistory { Code = code, Type = MessageType.Mail, Message = string.Format(L("VerificationBody"), code), To = mailAddress }); }
public async Task SendSmsVerificationCode(string phoneNumber) { var code = VerificationCodeGenerater.GenerateCode(); var smsParams = new Dictionary <string, string>() { { "code", code } }; Expression <Func <Task> > expression = () => _smsMessage.SendMessage(phoneNumber, "", smsParams); Hangfire.BackgroundJob.Schedule(expression, TimeSpan.Zero); await _messageHistoryRepository.InsertAsync(new MessageHistory { Code = code, Type = MessageType.Sms, Message = code, To = phoneNumber }); }
public Task <bool> Verify(string code) { return(new ValueTask <bool>(VerificationCodeGenerater.Verify(code)).AsTask()); }