Exemplo n.º 1
0
        public ActionResult DoiMatKhau(string TenTaiKhoan, string MatKhau, string MatKhauMoi, string NhapLaiMatKhau)
        {
            var model = new CommonNguoiDung.NguoiDungInput.DoiMatKhau();

            ViewBag.ThongBao = "Vui lòng nhập đầy đủ thông tin!";
            try
            {
                if (string.IsNullOrEmpty(MatKhau.Trim()))
                {
                    ViewBag.ThongBao = "Vui lòng nhập mật khẩu!";
                    return(View(model));
                }
                if (!string.IsNullOrEmpty(MatKhauMoi.Trim()) && MatKhauMoi == NhapLaiMatKhau)
                {
                    model.TenTaiKhoan    = TenTaiKhoan;
                    model.MatKhau        = Utility.MD5(MatKhau);
                    model.MatKhauMoi     = MatKhauMoi;
                    model.NhapLaiMatKhau = NhapLaiMatKhau;

                    var input = new CommonNguoiDung.NguoiDungInput.DoiMatKhau();
                    input.TenTaiKhoan    = TenTaiKhoan;
                    input.MatKhau        = Utility.MD5(MatKhau);
                    input.MatKhauMoi     = Utility.MD5(MatKhauMoi);
                    input.NhapLaiMatKhau = NhapLaiMatKhau;

                    var output = XuLyAPI.ApiJsonPost(APIUrl.NguoiDung.DoiMatKhau, input) as CommonOutput;
                    if (output == null)
                    {
                        throw new Exception(ConstantValues.Message.LoiServer);
                    }
                    if (output.KetQua == 1)
                    {
                        // Thành công
                        TempData["returnUrl"] = null;
                        Session.Clear();
                        return(Redirect("~/TrangChu/Index"));
                    }
                    else
                    {
                        ViewBag.ThongBao = "Đổi mật khẩu không thành công. Vui lòng kiểm tra lại!";
                    }
                }
                else
                {
                    ViewBag.ThongBao = "Nhập lại mật khẩu không đúng!";
                }
            }
            catch (Exception ex)
            {}
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult DoiMatKhau()
        {
            var model = new CommonNguoiDung.NguoiDungInput.DoiMatKhau();

            try
            {
                if (Session["UserInfo"] != null)
                {
                    var userInfo = Session["UserInfo"] as CommonNguoiDung.NguoiDungOutput.DangNhapTaiKhoan;
                    model.TenTaiKhoan = userInfo.TenTaiKhoan;
                }
            }
            catch (Exception ex)
            { }
            return(View(model));
        }