Ejemplo n.º 1
0
        public ActionResult DangNhap(LoginCus login)
        {
            if (ModelState.IsValid)
            {
                var acc = new AccountDao();
                var kq  = acc.Login(login.Username, login.Password);
                if (kq == 1)
                {
                    var user       = acc.GetCus(login.Username);
                    var accSession = new AccLogin();
                    accSession.UserName = user.Username;
                    accSession.AccID    = user.ID;

                    Session.Add(CommonConstants.Account_Session, accSession);

                    return(Redirect("/Khachhang/Khachhang"));
                }
                else if (kq == 2)
                {
                    var user       = acc.Getnv(login.Username);
                    var accSession = new AccLogin();
                    accSession.UserName = user.Username;
                    accSession.AccID    = user.MaNV;

                    Session.Add(CommonConstants.Account_Session, accSession);

                    return(Redirect("/NhanVien/NhanVien"));
                }
                else
                {
                    ModelState.AddModelError("", "Sai tài khoản hoặc mật khẩu");
                }
            }
            return(View("DangNhap"));
        }