public IHttpActionResult GetLoginUsers(LoginModel loginModel) { string sqlQuery = ""; string resultString = ""; try { if (loginModel.Email != null || loginModel.Password != "") { sqlQuery = "select CusID from Custrecords where Email='" + loginModel.Email + "' and Cust_Password='******' "; sdr = Concls.GetdataReader(sqlQuery); if (sdr.HasRows) { if (sdr.Read()) { resultString = sdr["CusID"].ToString(); } else { resultString = ""; } } else { resultString = ""; } sdr.Close(); if (string.IsNullOrEmpty(resultString)) { resultString = "false"; } else { resultString = "true"; } return(Ok(resultString)); } else { return(Ok("Something went Wrong...")); } } catch (Exception ex) { throw (ex); } }
public bool CheckSecurityPin(string SecurityPin) { string Type = "Registration"; bool flag = false; string OTP_Code = ""; if (SecurityPin == "") { SecurityPin = "0"; } SqlDataReader sdr = conCls.GetdataReader("Select OTP_Code from OTP_data_Code Where Status=0 AND Type='" + Type + "' AND OTP_Code=" + SecurityPin); if (sdr.HasRows) { if (sdr.Read()) { OTP_Code = sdr["OTP_Code"].ToString(); } } sdr.Close(); sdr.Dispose(); if (OTP_Code == "") { flag = false; } else { string sessvalue = OTP_Code; if (sessvalue == SecurityPin) { flag = true; } else { flag = false; } } return(flag); }
public IHttpActionResult RegisterMailConfirmation(string otpcode) { try { decryption Decryption = new decryption(); if (!string.IsNullOrEmpty(otpcode)) { checksecuritypin checksecuritypin = new checksecuritypin(); if (!checksecuritypin.CheckSecurityPin(otpcode)) { user.ErrorCode = 0; user.ErrorMessage = "false"; //return Ok("error: invalid_otp_code"); } else if (checksecuritypin.CheckSecurityPin(otpcode) == false) { user.ErrorCode = 0; user.ErrorMessage = "false"; //return Ok("error: invalid_otp_code"); } else { string custid = ""; SqlDataReader sdr = conCls.GetdataReader("Select CustID from OTP_data_Code Where Status=0 AND Type='Registration' AND OTP_Code=" + otpcode); if (sdr.HasRows) { if (sdr.Read()) { custid = sdr["CustID"].ToString(); } } sdr.Close(); sdr.Dispose(); int flag = 0; string errMsg = "0"; conCls.verification_byregistration(custid, out flag, out errMsg); string NewID = ""; NewID = flag.ToString(); if (NewID.Length > 4) { string regsucc = ""; regsucc = errMsg.ToString().Trim(); if (regsucc.ToString() == "SUCCESS") { string _Cust_Name = ""; string _email = ""; string _username = ""; string sqlStr1 = ""; sqlStr1 = "SELECT Cust_UserName, Email, cusid, cust_name from CustRecords_preReg where cusid = " + custid; SqlDataReader sdr1 = conCls.GetdataReader(sqlStr1); if (sdr1.HasRows) { if (sdr1.Read()) { _username = sdr1["Cust_UserName"].ToString(); _email = sdr1["Email"].ToString(); _Cust_Name = sdr1["cust_name"].ToString(); } else { user.ErrorCode = 0; user.ErrorMessage = "false"; //return Ok("error: record_not_available"); } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; //return Ok("error: record_not_available"); } sdr1.Close(); sdr1.Dispose(); SendSMS(NewID, _Cust_Name, _email, _username); user.ErrorCode = 1; user.ErrorMessage = "true"; return(Ok(registrationmodel)); //return Ok("true"); } else { user.ErrorCode = 0; user.ErrorMessage = "false"; //return Ok("error: please_contact_admin_or_create_support_ticket_for_activate_account"); } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; //return Ok("error:email_already_exist_or_sponserid_invalid"); } } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; //return Ok("error: otp_code_not_found"); } } catch (Exception ex) { return(Ok(ex.Message.ToString())); } }
public IHttpActionResult NewRegistrationUsers(RegistrationModel registrationmodel) { try { if (string.IsNullOrEmpty(registrationmodel.Name) || string.IsNullOrEmpty(registrationmodel.Email) || string.IsNullOrEmpty(registrationmodel.Password) || string.IsNullOrEmpty(registrationmodel.MobileNo)) { user.ErrorCode = 0; user.ErrorMessage = "false"; //return Ok("error: please_fill_mandatory_filled"); } else { string sqlQuery = ""; string valuexx, email_valuexx; if (string.IsNullOrEmpty(registrationmodel.SponserID = "")) { registrationmodel.SponserID = "admin"; } sqlQuery = "SELECT cusid FROM Custrecords WHERE loginusername='******'"; sdr = conCls.GetdataReader(sqlQuery); if (sdr.HasRows) { if (sdr.Read()) { valuexx = sdr["cusid"].ToString(); } else { valuexx = "HELLO"; } sdr = conCls.GetdataReader("SELECT count (*) as countemail FROM Custrecords_prereg WHERE email= '" + registrationmodel.Email.Replace(" ", "") + "'"); if (sdr.HasRows) { if (sdr.Read()) { email_valuexx = sdr["countemail"].ToString(); // sdr["coun"].ToString(); } else { email_valuexx = "1"; } } else { email_valuexx = "1"; } sdr.Close(); if (registrationmodel.Name.Trim().Length > 4) { if (!string.IsNullOrEmpty(registrationmodel.Name)) { decimal val; var isNumericName = decimal.TryParse(registrationmodel.Name.ToString(), out val); if (!isNumericName) { if (email_valuexx == "0") { string Newid = "0", Errocode = ""; string _cust_sponserID, _name, _email, _cust_Password, _cust_address, _cust_answer, _cust_question, _cust_city, _cust_state, _cust_country, _Cust_Title, _Cust_Name, _Cust_Gender, _Cust_FatherName, _Cust_Pincode, _Cust_mobileNo, _Cust_nominee, _Cust_Relation, _Cust_Package, _Cust_Location, _Cust_TempPinID, _Cust_BankName, _Cust_BankAcc, _Cust_BankIFSC, _Cust_BankBranch, _Cust_PanID, _custusername; int _PayMode = 0; DateTime _Cust_DOB; string msgSuccess = ""; _cust_sponserID = valuexx; _name = registrationmodel.Name; _email = registrationmodel.Email; _Cust_mobileNo = registrationmodel.MobileNo; _cust_Password = registrationmodel.Password; _cust_address = ""; _cust_answer = ""; _cust_question = ""; _cust_city = ""; _cust_state = ""; _cust_country = ""; _Cust_Title = ""; _Cust_Name = registrationmodel.Name; _Cust_Gender = ""; _Cust_FatherName = ""; _Cust_DOB = registrationmodel.Cust_DOB; _Cust_Pincode = ""; _Cust_nominee = ""; _Cust_Relation = ""; _Cust_Package = registrationmodel.Cust_Package; _Cust_Location = registrationmodel.Cust_Location; _Cust_TempPinID = registrationmodel.Cust_tempPinID; _PayMode = registrationmodel.PayMode; _Cust_BankName = ""; _Cust_BankAcc = ""; _Cust_BankIFSC = ""; _Cust_BankBranch = ""; _Cust_PanID = ""; _custusername = registrationmodel.custusername; var resultString = conCls.inserrtnewcustrecords(_cust_sponserID, _email, _cust_address, _cust_answer, _cust_question, _cust_city, _cust_state, _cust_country, _cust_Password, _Cust_Title, _Cust_Name, _Cust_Gender, _Cust_FatherName, _Cust_DOB, _Cust_Pincode, _Cust_mobileNo, _Cust_nominee, _Cust_Relation, _Cust_Package, _Cust_Location, _Cust_TempPinID, _PayMode, _Cust_BankName, _Cust_BankAcc, _Cust_BankIFSC, _Cust_BankBranch, _Cust_PanID, _custusername, out Newid, out Errocode); if (Newid.Length > 4) { ////****************OTP Gnereation Code********************* ////var Sendsms = new sendsms(); //string numbers = "1234567890"; //string characters = numbers; //// OTP LENGTH //int length = 6; ////INITIAL OTP //string otp = string.Empty; ////GENERATING OTP //for (int i = 0; i < length; i++) //{ // string character = string.Empty; // do // { // int index = new Random().Next(0, characters.Length); // character = characters.ToCharArray()[index].ToString(); // } while (otp.IndexOf(character) != -1); // otp += character; //} SendSMS(Newid, _Cust_Name, _cust_sponserID, _Cust_mobileNo, _cust_Password, _email, _custusername, _cust_Password, _Cust_Package); string otpstatus = conCls.ExecuteSqlnonQuery("Update [OTP_data_Code] Set Status = 1 Where CustID = '" + Newid + "' AND Type = 'Registration' AND Status = 0").ToString(); string result = Convert.ToString(resultString); if (!string.IsNullOrEmpty(result)) { if (result == "1") { //return new RegistrationModel(_Cust_Name, Request); //return Ok("true"); user.ErrorCode = 1; user.ErrorMessage = "true"; return(Ok(registrationmodel)); } else { user.ErrorCode = 0; user.ErrorMessage = "false"; user.registeruser = null; } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; user.registeruser = null; //result = "false"; } } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; user.registeruser = null; //return Ok("error: email_already_exist"); } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; user.registeruser = null; //return Ok("error: numeric_name_not_allowed"); } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; user.registeruser = null; //return Ok("error: name_cant_be_null_or_numeric"); } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; //user.registeruser = null; //return Ok("error: name_cant_be_less_than_five_characters"); } } else { user.ErrorCode = 0; user.ErrorMessage = "false"; user.registeruser = null; //return Ok("error: sponser_id_invalid "); } } return(Ok(user)); } catch (Exception ex) { return(Ok(ex.Message.ToString())); } }