Example #1
0
        public ActionResult Login(string TaiKhoan, string MatKhau)
        {
            NguoiDung nguoiDung = db.NguoiDungs.Where(i => i.TaiKhoan == TaiKhoan).FirstOrDefault();

            if (nguoiDung != null)
            {
                if (SecurePasswordHasher.Verify(MatKhau, nguoiDung.MatKhau))
                {
                    Session["nguoiDung"] = nguoiDung;
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                TaiKhoanKhachHang taiKhoanKhachHang = db.TaiKhoanKhachHangs.Where(i => i.TaiKhoan == TaiKhoan).FirstOrDefault();
                if (taiKhoanKhachHang != null)
                {
                    if (SecurePasswordHasher.Verify(MatKhau, taiKhoanKhachHang.MatKhau))
                    {
                        KhachHang khachHang = db.KhachHangs.Where(i => i.MaKH == taiKhoanKhachHang.MaKH && i.DaXoa == false).FirstOrDefault();
                        if (khachHang != null)
                        {
                            Session["khachHang"] = khachHang;
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }
            }
            return(View("Index"));
        }
Example #2
0
        public ActionResult Login(string TaiKhoan, string MatKhau)
        {
            NguoiDung nguoiDung = db.NguoiDungs.Where(i => i.TaiKhoan == TaiKhoan).First();

            System.Diagnostics.Debug.WriteLine(nguoiDung);
            if (nguoiDung != null)
            {
                System.Diagnostics.Debug.WriteLine("co nguoi dung");
                if (SecurePasswordHasher.Verify(MatKhau, nguoiDung.MatKhau))
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View("Index"));
        }