public ActionResult Admin(Bank_Admin admin) { BankEntities usersEntities = new BankEntities(); if (admin.b_admin_name == null) { ModelState.AddModelError(admin.b_admin_name, "The Username field cannot be empty"); } if (admin.b_admin_pin.ToString() == null) { ModelState.AddModelError(admin.b_admin_pin.ToString(), "The PIN field cannot be empty"); } int?userId = usersEntities.VALIDATE_ADMIN(admin.b_admin_name.ToString(), admin.b_admin_pin.ToString()).FirstOrDefault(); string message = string.Empty; switch (userId.Value) { case -1: message = "Username or password incorrect"; break; case 0: FormsAuthentication.SetAuthCookie(admin.b_admin_name, admin.RememberMe); return(RedirectToAction("Index", "Admin", admin)); } ViewBag.Message = message; return(View(admin)); }