public ActionResult ThongTinCaNhan(ResetPass resetPass) { if (resetPass != null && resetPass.MatKhauCu != null && resetPass.MatKhauCu.Length > 0 && resetPass.MatKhauMoi.Length > 0 && resetPass.ReMatKhauMoi.Length > 0) { tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); AccountCookie accountCookie = (AccountCookie)Session["AccountCookie"]; ResSubmit resSubmit = new ResSubmit(true, "Cập nhật thành công"); var _Account = tongcuclamnghiep.m_account.Where(a => a.id == accountCookie.Id && a.password == resetPass.MatKhauCu).FirstOrDefault(); if (_Account == null) { resSubmit = new ResSubmit(false, "Không có tài khoản này"); } if (resSubmit.success && !(resetPass.MatKhauMoi == resetPass.ReMatKhauMoi && (resetPass.MatKhauMoi.Length >= 12 && resetPass.MatKhauMoi.Length <= 50))) { resSubmit = new ResSubmit(false, "Mật khẩu mới không hợp lệ"); } if (resSubmit.success) { _Account.password = resetPass.MatKhauMoi; if (tongcuclamnghiep.SaveChanges() != 1) { resSubmit = new ResSubmit(false, "Cập nhật thất bại"); } else { string body = string.Format(@"<table width='100%' cellspacing='0' cellpadding='0' border='0' style='width:100%;min-width:100%'> <tbody> <tr> <td align='left' style='padding:0;font-size:20px;line-height:26px;letter-spacing:-0.32px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#0078d6'> Tóm tắt tài khoản </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Tên Tài khoản:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{0}</a> </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Mật khẩu:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{1}</a> </td> </tr> <tr> <td align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#6e6e6e'> <a href='http://baocaolamnghiep.quantriwebhanoi.com' style='color:#6e6e6e;text-decoration:underline' target='_blank' ><strong style='font-weight:normal'>Tài khoản của Tôi</strong></a> </td> </tr> </tbody></table>" , _Account.username, _Account.password); FuncExtend.SendMail(_Account.email, body, "Thông tin tài khoản"); } } ModelState.AddModelError("", resSubmit.message); return(View()); } else { return(View()); } }
public ActionResult ResetMatKhau(AccountLogin account) { if (!string.IsNullOrEmpty(account.UserName)) { tongcuclamnghiepEntities dataBase = new tongcuclamnghiepEntities(); var acc = dataBase.m_account.Where(a => (a.email == account.UserName) && a.status == true).FirstOrDefault(); if (acc != null) { string body = string.Format(@"<table width='100%' cellspacing='0' cellpadding='0' border='0' style='width:100%;min-width:100%'> <tbody> <tr> <td align='left' style='padding:0;font-size:20px;line-height:26px;letter-spacing:-0.32px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#0078d6'> Tóm tắt tài khoản </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Tên Tài khoản:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{0}</a> </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Mật khẩu:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{1}</a> </td> </tr> <tr> <td align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#6e6e6e'> <a href='http://baocaolamnghiep.quantriwebhanoi.com' style='color:#6e6e6e;text-decoration:underline' target='_blank' ><strong style='font-weight:normal'>Tài khoản của Tôi</strong></a> </td> </tr> </tbody></table>" , acc.username, acc.password); if (FuncExtend.SendMail(acc.email, body, "Thông tin tài khoản")) { ModelState.AddModelError("", "Gửi email thành công"); } else { ModelState.AddModelError("", "Gửi email thất bại"); } return(View("~/Views/Login/ResetMatKhau.cshtml")); } else { ModelState.AddModelError("", "Email tài khoản không tồn tại"); return(View("~/Views/Login/ResetMatKhau.cshtml")); } } else { return(View()); } }
public ResSubmit GuiMatKhau(int IdAccount, AccountCookie accountCookie) { ResSubmit resSubmit = new ResSubmit(true, "Gửi email thành công"); tongcuclamnghiepEntities tongcuclamnghiep = new tongcuclamnghiepEntities(); var _Account = tongcuclamnghiep.m_account.Where(a => a.id == IdAccount).FirstOrDefault(); if (accountCookie.Role_Id != 1) { resSubmit = new ResSubmit(false, "Bạn không có quyền này"); } if (resSubmit.success && _Account == null) { resSubmit = new ResSubmit(false, "Không có tài khoản này"); } if (resSubmit.success) { string body = string.Format(@"<table width='100%' cellspacing='0' cellpadding='0' border='0' style='width:100%;min-width:100%'> <tbody> <tr> <td align='left' style='padding:0;font-size:20px;line-height:26px;letter-spacing:-0.32px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#0078d6'> Tóm tắt tài khoản </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Tên Tài khoản:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{0}</a> </td> </tr> <tr> <td class='m_-8498465890789338487useremail' align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI','Segoe UI Regular',SUWR,Arial,sans-serif;color:#6e6e6e'> <b style='font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;font-weight:normal'>Mật khẩu:</b> <a href='#m_-8498465890789338487_' style='text-decoration:none;color:#737373'>{1}</a> </td> </tr> <tr> <td align='left' style='padding:3px 0 0;font-size:14px;line-height:19px;letter-spacing:-0.16px;font-weight:normal;font-family:'Segoe UI Semibold','Segoe UI',SUWSB,Arial,sans-serif;color:#6e6e6e'> <a href='http://baocaolamnghiep.quantriwebhanoi.com' style='color:#6e6e6e;text-decoration:underline' target='_blank' ><strong style='font-weight:normal'>Tài khoản của Tôi</strong></a> </td> </tr> </tbody></table>" , _Account.username, _Account.password); if (!FuncExtend.SendMail(_Account.email, body, "Thông tin tài khoản")) { resSubmit = new ResSubmit(false, "Gửi email thất bại"); } } return(resSubmit); }