public ActionResult StaffLogin(IFormCollection formData) { string loginID = formData["txtLoginID"].ToString().ToLower(); string password = formData["txtPassword"].ToString(); Staff staff = staffContext.GetStaff(loginID); if (homeContext.IsEmailExist(loginID, password)) { if (loginID == staff.Email.ToLower() && password == staff.Password) { string name = homeContext.GetName(loginID); string department = homeContext.GetDepartment(loginID); string role = homeContext.GetRole(loginID); HttpContext.Session.SetString("LoginID", loginID); HttpContext.Session.SetString("Name", name); HttpContext.Session.SetString("Department", department); HttpContext.Session.SetString("Role", role); if (department == "Operations") { if (role == "Manager") { return(RedirectToAction("Index", "OperationsManager")); } else if (role == "Staff") { return(RedirectToAction("Index", "OperationsStaff")); } else if (role == "Part-timer") { return(RedirectToAction("Index", "PartTimeStaff")); } } } else { TempData["Message"] = "Your credentials are incorrect!"; return(RedirectToAction("Index", "Home")); } return(View()); } else { TempData["Message"] = "Invalid Login Credentials!"; return(RedirectToAction("Index", "Home")); } }