public ActionResult Edit(Managing_agent_Data md, int id) { string user = (string)Session["username"].ToString(); DateTime date = DateTime.Now; Managing_Agent.Update_Managing_Agent(md, user, date, id); return(RedirectToAction("AdminDashboard")); }
public static Managing_agent_Data get_managingById(int id) { DynamicParameters param = new DynamicParameters(); param.Add("@Mid", id); Managing_agent_Data md = new Managing_agent_Data(); string constr = ConfigurationManager.ConnectionStrings["myconnection"].ToString(); using (SqlConnection con = new SqlConnection(constr)) { md = con.Query <Managing_agent_Data>("Get_Managing_Agent_By_Id", param, commandType: CommandType.StoredProcedure).SingleOrDefault(); } return(md); }
public ActionResult Addagent(Managing_agent_Data md) { if (ModelState.IsValid) { bool IsUserExist = WebSecurity.UserExists(md.Email); if (IsUserExist) { ModelState.AddModelError("UserName", "UserName Already Exist"); } else { var user = (string)Session["username"].ToString(); WebSecurity.CreateUserAndAccount(md.Email, md.password, new { CompanyName = md.companyName, Phone_number = md.phone_number, Contact_name = md.contact_name, Email = md.Email, Status_ = "Active", Created_By = user, Created_On = DateTime.Now }); Roles.AddUserToRole(md.Email, "managing agent"); #region MailMessage mail = new MailMessage(); mail.To.Add(md.Email); mail.From = new System.Net.Mail.MailAddress("*****@*****.**"); mail.Subject = "Account created"; mail.Body = "Dear User your account has been created successfully for the role of Managing Agent And your UserName is " + md.Email + " and Password is " + md.password; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", ""); smtp.EnableSsl = true; smtp.Send(mail); #endregion return(RedirectToAction("AdminDashboard", "SuperAdmin")); } } return(View()); }
public static void Update_Managing_Agent(Managing_agent_Data dt, string username, DateTime date, int id) { DynamicParameters param = new DynamicParameters(); param.Add("@Muserid", id); param.Add("@MCompany", dt.companyName); param.Add("@MEmail", dt.Email); param.Add("@MPhone_Number", dt.phone_number); param.Add("@MContact_Name", dt.contact_name); param.Add("@MUpdated_By", username); param.Add("@MUpdated_On", date); param.Add("@MIs_Active", dt.status_); string constr = ConfigurationManager.ConnectionStrings["myconnection"].ToString(); using (SqlConnection con = new SqlConnection(constr)) { con.Open(); con.Execute("update_managing_agent", param, commandType: CommandType.StoredProcedure); con.Close(); } }