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())); } }