dimanche 20 décembre 2020

The bool value always is always taken as false but its true in database? MVC

I have defined user(admin) type as 'bit' data type in my database. So if value is true it should go to a specific page otherwise it should return the same view. But whenever I pass object (adminObj) with different values the if statement only returns 'false' from database. Can somebody help where is the problem ?

here is my logic

[HttpPost]
        public ActionResult Login(tbl_Admin adminObj)
        { 
            studentDBEntities db = new studentDBEntities();
            var adminvar = db.tbl_Admin.Where(x => x.Email == adminObj.Email && x.Password == adminObj.Password).FirstOrDefault();
            var type=adminObj.Type;
            if (adminvar != null)
            {
                /*var isGlobal=*/
                if (adminObj.Type == true)
                {
                    return RedirectToAction("ListAdmin");
                }
                else
                {
                    return View();
                }
            }
            else 
            {
                return View();
            }
        }

Values in Database-Table:

When Type=1

type is true at first place but false at if condition

Aucun commentaire:

Enregistrer un commentaire