public ActionResult ChangePass(string newPassword, string oldPassword, string confirmPassword) { string newUrl = string.Empty; try { if (oldPassword == null) { oldPassword = ""; } UserPMModel user = new UserPMBLL().GetUserByID(GlobalData.User.IDUser.ToString()); if (user != null) { if (oldPassword.Trim().Equals(string.Empty) && !user.Password.Equals(string.Empty)) { return(ToResponse(false, null, Resources.Global.NhanVien_UserProfile_Password_Error_PassOld_Empty)); } else if (newPassword.Trim().Equals(string.Empty)) { return(ToResponse(false, null, Resources.Global.NhanVien_UserProfile_Password_Error_PassNew_Empty)); } else if (confirmPassword.Trim().Equals(string.Empty)) { return(ToResponse(false, null, Resources.Global.NhanVien_UserProfile_Password_Error_PassComfirm_Empty)); } else if (!newPassword.Trim().Equals(confirmPassword.Trim())) { return(ToResponse(false, null, Resources.Global.NhanVien_UserProfile_Password_Error_PassNewConform)); } else if (MD5.getMD5(oldPassword.Trim()) != user.Password.Trim() && user.Password != string.Empty) { return(ToResponse(false, null, Resources.Global.NhanVien_UserProfile_Password_Error_Old)); } else { bool result = new UserPMBLL().ChangePass(user.IDUser.ToString(), MD5.getMD5(newPassword.Trim())); if (result) { newUrl = Url.Action("UserProfile", "Employee"); return(ToResponse(true, null, newUrl)); } return(ToResponse(false, string.Empty)); } } return(ToResponse(false, string.Empty)); } catch (Exception ex) { return(ToResponse(false, ex.Message)); } }
public static void SendMailToAdmin(int id, string url) { try { var hoSo = new HoSoBLL().LayChiTiet(id); if (hoSo != null) { var lstUserApprove = new NhanVienNhomBLL().LayDSNhanVien(hoSo.HoSoCuaAi, (int)QuyenIndex.DuyetHoSo); if (lstUserApprove != null) { foreach (var item in lstUserApprove) { string mailTo = ""; string subject = "[FINTECHCOM]{0}"; string mailBody = ""; string genderSend = ""; UserPMModel userSend = new UserPMBLL().GetUserByID(hoSo.HoSoCuaAi.ToString()); UserPMModel userReceive = item; mailTo = userReceive.Email; string genderReceive = ""; string template = ""; mailBody += "<p style=\"margin-left:20px;margin-top:20px\"><font size=\"2.5\" face=\"Arial\">Dear{0} {1}\r\n\r\n"; mailBody += "Bạn được chọn để duyệt hồ sơ bởi {2} {3}.\r\n"; mailBody += "Hồ sơ: {4}\r\n"; mailBody += "Mã hồ sơ: <a href='" + url + "/DuyetHoSo/XemHSByID/" + id + "'>{5}</a>\r\n\r\n"; mailBody += "Vui lòng click vào link bên dưới {6} thực hiện việc kiểm duyệt.\r\n\r\n"; mailBody += "http://" + url + "/DuyetHoSo/XemHSByID/" + id + ".\r\n\r\n"; mailBody += "Đây là một email được tạo ra hệ thống. Xin vui lòng không trả lời tin nhắn này.\r\n"; //mailBody += "Nếu bạn có bất kỳ thắc mắc, xin vui lòng liên hệ {7}\r\n"; mailBody += "Trân trọng,\r\n\r\n"; mailBody += "VIETBANK – HỆ THỐNG KIỂM DUYỆT HỒ SƠ\r\n\r\n</font></p>"; template += "<html><table style=\"width: 700px\" cellpadding=\"0\" cellspacing=\"0\"><tr style =\"background-color:#0D622F\"><td style =\"width:15%;float:left\"><img style=\"width:120px;margin-left: 20px;margin-top: 20px;\" src ='" + CMLink.PathLogo + "'></td><td style=\"width:85%\"><p style=\"float:left; margin: 10px 0px 10px 15px\"><font size=\"6\" face=\"VIETBANK – HỆ THỐNG KIỂM DUYỆT HỒ SƠ\" style=\"color:white\">HỆ THỐNG KIỂM DUYỆT HỒ SƠ</font></p ></td></tr>"; template += "<tr style=\"background-color:#61ec66\" align=\"left\" ><td colspan='2'>###</td></tr>"; template += "</table></html>"; mailBody = mailBody.Replace("\r\n", "<br>"); mailBody = string.Format(mailBody, genderReceive, userReceive.FullName, genderSend, userSend.FullName, hoSo.TenKhachHang, hoSo.MaHoSo, "đây"); template = template.Replace("###", mailBody); SendMail(mailTo, string.Format(subject, hoSo.TenKhachHang), hoSo.TenKhachHang, template); } } } } catch { } }
public JsonResult GetUser(string userName) { var message = new RMessage { ErrorMessage = Resources.Global.Message_Error, Result = false }; UserPMModel user = null; try { user = new UserPMBLL().Get(userName); } catch (BusinessException ex) { message.Result = false; message.MessageId = ex.getExceptionId(); message.ErrorMessage = ex.Message; message.SystemMessage = ex.ToString(); } return(Json(new { Message = message, User = user }, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> DangNhap(string userName, string password, string rememberMe) { string newUrl = string.Empty; try { UserPMModel user = new UserPMBLL().DangNhap(userName, MD5.getMD5(password)); //user = new UserPMModel { // IDUser = 1, // UserName = "******" //}; if (user != null) { GlobalData.User = user; GlobalData.User.UserType = (int)UserTypeEnum.Sale; var isTeamLead = new GroupRepository().checkIsTeamLeadByUserId(user.IDUser); var isAdmin = await _rpEmployee.CheckIsAdmin(user.IDUser); if (isAdmin) { GlobalData.User.UserType = (int)UserTypeEnum.Admin; } else if (isTeamLead) { GlobalData.User.UserType = (int)UserTypeEnum.Teamlead; } GlobalData.User.OrgId = user.OrgId; var cookieUserName = new HttpCookie("userName"); var cookiePassword = new HttpCookie("password"); if (rememberMe != null && rememberMe.ToLower().Equals("on")) { cookieUserName.Expires = DateTime.Now.AddDays(30); cookiePassword.Expires = DateTime.Now.AddDays(30); FormsAuthentication.SetAuthCookie(userName, true); } else { cookieUserName.Expires = DateTime.Now.AddDays(-1); cookiePassword.Expires = DateTime.Now.AddDays(-1); FormsAuthentication.SetAuthCookie(userName, false); } cookieUserName.Value = userName; cookiePassword.Value = password; Response.SetCookie(cookieUserName); Response.SetCookie(cookiePassword); GlobalData.Rules = new GrantRightBLL().GetListRule(user.IDUser.ToString()); if (GlobalData.LinkBack != string.Empty) { newUrl = GlobalData.LinkBack; GlobalData.LinkBack = string.Empty; } else { newUrl = "/Home/Index"; } return(ToResponse(true, null, newUrl)); } else { return(ToResponse(false, null, Resources.Global.NhanVien_Login_Message_DangNhap_Error_TDNORMK)); } } catch (BusinessException ex) { return(ToResponse(false, ex.Message)); } }