public bool RequestOTPForSessionComp(RequestOTP ROTP) { try { int OTP = GenerateRandomNo(); string StudetnName, ContactNo, studentEmail; using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd1 = new SqlCommand("Sp_CDFsessionCompletionOTP", con); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@Cid", ROTP.StudentID); cmd1.Parameters.AddWithValue("@token", OTP); cmd1.Parameters.AddWithValue("@SP_Type", "INSERT"); con.Open(); int i = cmd1.ExecuteNonQuery(); con.Close(); if (i > 0) { string query = " select c_first_name as fname,c_last_name as lname,c_phone_no as contactNo,c_email_id as email from [cyberind_dheya].[dbo].[tbl_candidate_master] where c_id='" + ROTP.StudentID + "'"; SqlCommand cmd = new SqlCommand(query, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable ds = new DataTable(); da.Fill(ds); if (ds != null) { if (ds.Rows.Count > 0) { StudetnName = ds.Rows[0]["fname"].ToString(); ContactNo = ds.Rows[0]["contactNo"].ToString(); studentEmail = ds.Rows[0]["email"].ToString(); string uname = ROTP.CDFName; //string uname = Session["userName"].ToString(); //send OTP on User SMS //string SMSText = WebConfigurationManager.AppSettings["sessionCompleteOTP"].ToString(); string SMSText = ConfigurationManager.AppSettings["sessionCompleteOTP"].ToString(); SMSText = SMSText.Replace("{Name}", "" + StudetnName); SMSText = SMSText.Replace("{OTP}", "" + OTP); SMSText = SMSText.Replace("{MentorName}", "" + uname); sendMail(StudetnName, studentEmail, SMSText); DC.sendSms(ContactNo, SMSText); } } return(true); } else { return(false); } } } catch (Exception ex) { Log.Error(ex); return(false); } }
public bool RequestOTP([FromBody] RequestOTP ROTP) { return(SR.RequestOTPForSessionComp(ROTP)); }