public static string verifyOTP([FromBody] otpVerify otp) { List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@OTPValue", otp.OTPValue)); parameters.Add(new SqlParameter("@email", otp.email)); parameters.Add(new SqlParameter("@type", otp.type)); try { string ConnectionString = Common.GetConnectionString(); string rowsAffected = SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "spVerifyOTP", parameters.ToArray()).ToString(); return(rowsAffected); } catch (Exception e) { //loggerErr.Error(e.Message + " - " + e.StackTrace); throw e; } }
public IActionResult verifyOTP([FromBody] otpVerify otp) { try { Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(otp.email); if (otp.OTPValue <= 0) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter OTP Value" } })); } else if (otp.type == "" || otp.type == "string") { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter a type" } })); } else if (match.Success) { string row = Data.User.verifyOTP(otp); if (row == "OTP Verified") { return(StatusCode((int)HttpStatusCode.OK, "OTP Verified Successfully")); } else { //return "Invalid user"; return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = row } })); } } else { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter a valid Email" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("verifyOTP", e.Message); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message } })); } }