public ActionResult ProfileUser(string returnUrl) { try { AddPageHeader("Profile", ""); AddBreadcrumb("Hệ thống", ""); AddBreadcrumb("Profile", "/Account/ProfileUser"); ViewBag.ReturnUrl = returnUrl; if (Session["UserInfo"] == null) { Logout(); return(RedirectToAction("Login", "Account")); } var UserInfo = ((cms_Account)Session["UserInfo"]); cms_Account _Account = new cms_Account(); _Account = impCms_Account.Get(UserInfo.uid); return(View(_Account)); } catch (Exception ex) { ViewBag.TitleSuccsess = "Có lỗi xẩy ra trong quá trình thực hiện, Mời bạn thực hiện lại!"; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; return(View()); } }
public ActionResult ChangePassword(ChangePasswordViewModel model) { AddPageHeader("Đổi mật khẩu", ""); AddBreadcrumb("Hệ thống", ""); AddBreadcrumb("Đổi mật khẩu", "/Account/ChangePassword"); cms_Account _Account = new cms_Account(); _Account = ((cms_Account)Session["UserInfo"]); try { if (ModelState.IsValid) { if (model.OldPassword.Equals(model.Password)) { ViewBag.TitleSuccsess = "Password new trùng với Password cũ, Mời bạn nhập lại"; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; } else if (!model.Password.Equals(model.ConfirmPassword)) { ViewBag.TitleSuccsess = "Nhập password new không trùng với confirm password, Mời bạn nhập lại"; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; } else { string salt = SaltedHash.GetSHA512(_Account.Username + model.OldPassword); salt = salt.Substring(0, 10); model.OldPassword = SaltedHash.GetSHA512(salt + model.OldPassword); List <cms_Account> accountInfo = impCms_Account.Getcms_Account(_Account.Username, model.OldPassword); if (accountInfo != null) { if (accountInfo.Count > 0) { salt = SaltedHash.GetSHA512(_Account.Username + model.Password); salt = salt.Substring(0, 10); model.Password = SaltedHash.GetSHA512(salt + model.Password); List <cms_Account> cms_Accounts = impCms_Account.ChangePasswordCms_Account(_Account.uid, model.Password); if (!string.IsNullOrEmpty(cms_Accounts[0].Username)) { ViewBag.TitleSuccsess = Constant.ChangePasswordSuccess; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; AddLogAction(_Account.uid.ToString(), Constant.ActionChangePasswordOK.ToString()); } else { ViewBag.TitleSuccsess = Constant.ChangePasswordError; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; AddLogAction(_Account.uid.ToString(), Constant.ActionChangePasswordOK.ToString()); } } else { ViewBag.TitleSuccsess = Constant.NoFindAccount; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; AddLogAction(_Account.uid.ToString(), Constant.ActionChangePasswordOK.ToString()); } } else { ViewBag.TitleSuccsess = Constant.Error; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; AddLogAction(_Account.uid.ToString(), Constant.ActionChangePasswordOK.ToString()); } } } } catch (Exception ex) { AddLogAction(_Account.uid.ToString(), Constant.ActionChangePasswordOK.ToString()); ViewBag.TitleSuccsess = Constant.Error; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; logIn.Info("ChangePassword: " + ex.ToString()); } return(View()); }
public ActionResult ProfileUser(cms_Account _Account) { AddPageHeader("Profile", ""); AddBreadcrumb("Hệ thống", ""); AddBreadcrumb("Profile", "/Account/ProfileUser"); if (ModelState.IsValid) { var UserInfo = ((cms_Account)Session["UserInfo"]); ImpCms_Account impCms_Account = new ImpCms_Account(); _Account.LastLogin = DateTime.Now; _Account.Password = string.Empty; bool validate = true; try { if (!string.IsNullOrEmpty(_Account.NgaysinhText.Trim())) { _Account.Ngaysinh = DateTime.ParseExact(_Account.NgaysinhText.Trim(), "dd/MM/yyyy", new CultureInfo("en-US")); } if (_Account.Ngaysinh > DateTime.Now) { validate = false; ViewBag.TitleSuccsess = "Ngày sinh lớn hơn ngày ngày hiện tại."; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; } if (_Account.Ngaysinh.Year < 1920) { validate = false; ViewBag.TitleSuccsess = "Năm sinh nhỏ hơn năm 1920"; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; } } catch { validate = false; } #region Check input data try { if (validate) { _Account.Hoten = _Account.Hoten.Trim(); _Account.UpdateBy = UserInfo.uid; _Account.Update_date = DateTime.Now; _Account.IsFirstLogin = false; _Account.LastLogin = DateTime.Now; string result = impCms_Account.UpdateProfile(_Account); if (!string.IsNullOrEmpty(result)) { ViewBag.TitleSuccsess = "Cập nhật thông tin thành công"; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeSuccsess; AddLogAction(result, Constant.ActionUpdateOK.ToString()); } else { ViewBag.TitleSuccsess = "Cập nhật thông tin không thành công"; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; AddLogAction(result, Constant.ActionUpdateNOK.ToString()); } } } catch (Exception ex) { ViewBag.TitleSuccsess = "Có lỗi xẩy ra trong quá trình thực hiện, Mời bạn thực hiện lại!"; ViewBag.TypeAlert = CMSLIS.Common.Constant.typeError; logIn.Info("ProfileUser: "******"ProfileUser: " + ex.ToString()); } #endregion } return(View(_Account)); }