public DataSet insert_update_agency(Agencymaster _obj) { try { _cn.Open(); SqlCommand _cmd = new SqlCommand("insert_update_agency", _cn); _cmd.Parameters.AddWithValue("@agencyid", _obj.agencyid); _cmd.Parameters.AddWithValue("@agency_uniq_id", _obj.agency_uniq_id); _cmd.Parameters.AddWithValue("@nameofagency", _obj.nameofagency); _cmd.Parameters.AddWithValue("@agencyaddress", _obj.agencyaddress); _cmd.Parameters.AddWithValue("@email", _obj.email); _cmd.Parameters.AddWithValue("@password", _obj.password); _cmd.Parameters.AddWithValue("@countrycode", _obj.countrycode); _cmd.Parameters.AddWithValue("@mobile", _obj.mobile); _cmd.Parameters.AddWithValue("@typeofagency", _obj.typeofagency); _cmd.Parameters.AddWithValue("@createdip", _obj.createdip); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandTimeout = 300; SqlDataAdapter _adp = new SqlDataAdapter(_cmd); DataSet _ds = new DataSet(); _adp.Fill(_ds); _adp.Dispose(); _cmd.Dispose(); return(_ds); } catch (Exception) { throw; } finally { _cn.Close(); } }
public DataSet agency_password_change(Agencymaster _obj) { try { _cn.Open(); SqlCommand _cmd = new SqlCommand("agency_password_change", _cn); _cmd.Parameters.AddWithValue("@agency_uniq_id", _obj.agency_uniq_id); _cmd.Parameters.AddWithValue("@change_password", _obj.change_password); _cmd.CommandType = CommandType.StoredProcedure; _cmd.CommandTimeout = 300; SqlDataAdapter _adp = new SqlDataAdapter(_cmd); DataSet _ds = new DataSet(); _adp.Fill(_ds); _adp.Dispose(); _cmd.Dispose(); return(_ds); } catch (Exception) { throw; } finally { _cn.Close(); } }
public JsonResult SelectAgencymaster(string ID = "") { AgencyRepository objRep = new AgencyRepository(); DataSet ds = objRep.select_Agency_master(TempData.Peek("agencyid").ToString()); TempData.Keep("agencyid"); List <Agencymaster> _list = new List <Agencymaster>(); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { Agencymaster objBasic = new Agencymaster(); objBasic.agencyid = row["agencyid"].ToString(); objBasic.agency_uniq_id = row["agency_uniq_id"].ToString(); objBasic.nameofagency = row["nameofagency"].ToString(); objBasic.agencyaddress = row["agencyaddress"].ToString(); objBasic.email = row["email"].ToString(); objBasic.password = row["password"].ToString(); objBasic.countrycode = row["countrycode"].ToString(); objBasic.mobile = row["mobile"].ToString(); objBasic.typeofagency = row["typeofagency"].ToString(); _list.Add(objBasic); } } } return(Json(new { List = _list }, JsonRequestBehavior.AllowGet )); }
public JsonResult SaveAgencymaster(Agencymaster _obj) { AgencyRepository objRepository = new AgencyRepository(); SendEmail _objseedemail = new SendEmail(); string localIP = "?"; localIP = Request.ServerVariables["REMOTE_ADDR"].ToString(); _obj.createdip = localIP; string password = Membership.GeneratePassword(8, 1); _obj.password = password; DataSet _ds = objRepository.insert_update_agency(_obj); bool flag = false; if (_ds != null) { if (_ds.Tables[0].Rows.Count > 0) { if (_ds.Tables[0].Rows[0]["counts"].ToString() == "1") { TempData["agencyid"] = _ds.Tables[0].Rows[0]["id"].ToString(); TempData.Keep("agencyid"); flag = true; if (_obj.email.ToString() != "") { string strform = System.Configuration.ConfigurationManager.AppSettings["Emailusername"]; string Subject = "Agency Registration"; StringBuilder MailBody = new StringBuilder(); MailBody.Append("<br/>Dear " + _obj.nameofagency + ",<br/>"); MailBody.Append("<br/>You have been registered with Study in India as a" + _obj.typeofagency); MailBody.Append("<br/>Your login credentials are:"); MailBody.Append("<br/>Agency ID: " + _ds.Tables[0].Rows[0]["agency_uniq_id"].ToString()); MailBody.Append("<br/>Password: "******"(System Generated)"); MailBody.Append("<br/><br/><a target='_blank' href='" + FullyQualifiedApplicationPath(ControllerContext.RequestContext.HttpContext.Request) + "GovernmentSchemeAdmission/Login/index' style='color:blue;'>click here</a> to login for the first time and reset your password." + "<br/>"); MailBody.Append("<br/>After resetting the password, kindly login to<a target='_blank' href='https://www.studyinindia.gov.in/channel'>https://www.studyinindia.gov.in/channel</a>"); MailBody.Append("<br/>Please note: This is an auto generated mail.<br/>"); MailBody.Append("<br/>Regards,<br/>"); MailBody.Append("Study in India Cell<br/>"); string bcc = ""; string cc = ""; _objseedemail.SendEmailInBackgroundThread(strform, _obj.email, bcc, cc, Subject, MailBody.ToString(), "", true); } } } } return(Json(new { flag = flag }, JsonRequestBehavior.AllowGet )); }
public JsonResult CheckLogin(Agencymaster _obj) { bool flagCaptcha = false; bool flagLogin = false; bool flagPasswordChanged = true; bool flagValidID = false; try { if (this.Session["CaptchaImageText"].ToString() == _obj.Captchastr) { flagCaptcha = true; AgencyRepository _objRepository = new AgencyRepository(); DataSet ds = _objRepository.select_tbl_Agency_master_login(_obj); if (ds != null) { Session["IsChangePwd"] = null; if (ds.Tables[0].Rows.Count > 0) { flagValidID = true; DataRow dr = ds.Tables[0].Rows[0]; string Password = dr["change_password"].ToString(); string random = ""; if (dr["password"] != null) { random = dr["password"].ToString(); } if (dr["is_change_pass"].ToString().ToLower() == "true") { //nvNHsQGCNC3Ph/TQRX3dbd4BnGKtXFV/Ow== string PASSWORD = _obj.password; string MD5 = Helper.VerifyHash(PASSWORD, "MD5", Password).ToString(); string SHA1 = Helper.VerifyHash(PASSWORD, "SHA1", Password).ToString(); string sha256 = Helper.VerifyHash(PASSWORD, "SHA256", Password).ToString(); string sha384 = Helper.VerifyHash(PASSWORD, "SHA384", Password).ToString(); string sha512 = Helper.VerifyHash(PASSWORD, "SHA512", Password).ToString(); if (MD5 == "True" || SHA1 == "True" || sha256 == "True" || sha384 == "True" || sha512 == "True") { TempData["old_password"] = PASSWORD; flagLogin = true; } } else { if (random != "") { if (random == _obj.password) { flagLogin = true; flagPasswordChanged = false; TempData["agent_old_password"] = random; } } } if (flagLogin) { Session["Gov_User_id"] = dr["agencyid"]; Session["Gov_User_Name"] = dr["email"]; Session["agency_uniq_id"] = dr["agency_uniq_id"]; Session["Gov_Name"] = dr["nameofagency"].ToString(); flagLogin = true; } } } } } catch (Exception) { throw; } return(Json(new { flagCaptcha = flagCaptcha, flagLogin = flagLogin, flagPasswordChanged = flagPasswordChanged, flagValidID = flagValidID }, JsonRequestBehavior.AllowGet )); //bool flagLogin = false; //bool flagCaptcha = false; //bool flagValidID = false; //UserRepository _objRepository = new UserRepository(); //DataSet ds = _objRepository.Login_Usermaster(_obj); //try //{ // if (this.Session["CaptchaImageText"].ToString() == _obj.Captchastr) // { // flagCaptcha = true; // if (ds != null) // { // if (ds.Tables[0].Rows.Count > 0) // { // flagValidID = true; // DataRow dr = ds.Tables[0].Rows[0]; // if (dr["Password"].ToString() == _obj.Password) // { // string localIPadmin = "?"; // localIPadmin = Request.ServerVariables["REMOTE_ADDR"].ToString(); // Session["localIPADmin"] = localIPadmin; // Session["Gov_User_id"] = dr["User_id"]; // Session["Gov_User_Name"] = dr["User_Name"]; // Session["Gov_Name"] = dr["Name"].ToString(); // Session["Gov_is_admin"] = dr["is_admin"].ToString(); // flagLogin = true; // } // } // } // } // else // { // flagCaptcha = false; // } //} //catch (Exception) //{ // throw; //} //return Json(new //{ // flagLogin = flagLogin, // flagValidID = flagValidID, // flagCaptcha = flagCaptcha, //}, // JsonRequestBehavior.AllowGet //); }
public JsonResult Agent_Check_And_ChangePassword(Agencymaster _obj) { bool flagCheckPassword = false; bool flagCaptcha = false; bool flagPwdChanged = false; if (this.Session["CaptchaImageText"].ToString() == _obj.Captchastr) //if (CaptchaValid) { flagCaptcha = true; _obj.agency_uniq_id = Session["agency_uniq_id"].ToString(); AgencyRepository _objRepository = new AgencyRepository(); DataSet ds = _objRepository.select_tbl_Agency_master_login(_obj); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; string actualPassword = dr["change_password"].ToString(); string random = ""; if (dr["password"] != null) { random = dr["password"].ToString(); } if (dr["is_change_pass"].ToString().ToLower() == "true") { string password = _obj.password; string MD5 = Helper.VerifyHash(password, "MD5", actualPassword).ToString(); string SHA1 = Helper.VerifyHash(password, "SHA1", actualPassword).ToString(); string sha256 = Helper.VerifyHash(password, "SHA256", actualPassword).ToString(); string sha384 = Helper.VerifyHash(password, "SHA384", actualPassword).ToString(); string sha512 = Helper.VerifyHash(password, "SHA512", actualPassword).ToString(); if (MD5 == "True" || SHA1 == "True" || sha256 == "True" || sha384 == "True" || sha512 == "True") { flagCheckPassword = true; } } else { if (random != "") { if (random == _obj.password) { flagCheckPassword = true; } } } if (flagCheckPassword) { Random rn = new Random(); #pragma warning disable SCS0005 // Weak random generator int month = rn.Next(1, 6); #pragma warning restore SCS0005 // Weak random generator StringBuilder hashPassword = new StringBuilder(); string new_password = _obj.change_password; switch (month) { case 1: hashPassword.Append(Helper.ComputeHash(new_password, "MD5", null)); break; case 2: hashPassword.Append(Helper.ComputeHash(new_password, "SHA1", null)); break; case 3: hashPassword.Append(Helper.ComputeHash(new_password, "SHA256", null)); break; case 4: hashPassword.Append(Helper.ComputeHash(new_password, "SHA384", null)); break; case 5: hashPassword.Append(Helper.ComputeHash(new_password, "SHA512", null)); break; } _obj.change_password = hashPassword.ToString(); DataSet _dsChngPwd = _objRepository.agency_password_change(_obj); if (_dsChngPwd != null) { if (_dsChngPwd.Tables[0].Rows.Count > 0) { flagPwdChanged = true; Session["IsPasswordChanged"] = "true"; } } } } } } return(Json(new { flagCaptcha = flagCaptcha, flagPwdChanged = flagPwdChanged }, JsonRequestBehavior.AllowGet )); }