private string SendVerificationCode(string phoneNumber, int userId, byte verificationCodeLength, CustomerRegistrationVerificationSMSTypes type) { Random rnd = new Random(); string verificationCode; string chars = type switch { CustomerRegistrationVerificationSMSTypes.OnlyNumbers => "0123456789", CustomerRegistrationVerificationSMSTypes.OnlyLetters => "abcdefghijklmnopqrstuvwxyz", CustomerRegistrationVerificationSMSTypes.NumbersAndLetters => "abcdefghijklmnopqrstuvwxyz01234567890123456789", _ => throw new Exception("Message type is not selected"), }; if (!Convert.ToBoolean(_config["TestVersion"])) { verificationCode = new string(Enumerable.Repeat(chars, verificationCodeLength).Select(s => s[rnd.Next(s.Length)]).ToArray()); _smsMessagingService.SendMessage(phoneNumber, 0, $"Mekangamya stugich code ` {verificationCode}", userId, 19); } else { verificationCode = "12345"; } return(verificationCode); }
private string SendVerificationCode(string phoneNumber, byte verificationCodeLength, CustomerRegistrationVerificationSMSTypes type) { var rnd = new Random(); string verificationCode; string chars; switch (type) { case CustomerRegistrationVerificationSMSTypes.OnlyNumbers: chars = "0123456789"; break; case CustomerRegistrationVerificationSMSTypes.OnlyLetters: chars = "abcdefghijklmnopqrstuvwxyz"; break; case CustomerRegistrationVerificationSMSTypes.NumbersAndLetters: chars = "abcdefghijklmnopqrstuvwxyz01234567890123456789"; break; default: throw new Exception("Message type is not selected"); } if (!Convert.ToBoolean(_config["TestVersion"])) { verificationCode = new string(Enumerable.Repeat(chars, verificationCodeLength) .Select(s => s[rnd.Next(s.Length)]).ToArray()); _smsMessagingService.SendMessage(phoneNumber, 0, $"Mekangamya stugich code ` {verificationCode}", (_cacheHelper.GetUser()).userID, 19); } else { verificationCode = "12345"; } return(verificationCode); }