public ActionResult SignIn(SignInModel signIn) //Action method for sign in { if (ModelState.IsValid) //verify validation { var user = AutoMapper.Mapper.Map <SignInModel, UserAccount>(signIn); //Auto mapper UserAccount userEntity = userBl.ValidateLogin(user); if (userEntity != null) { Session["UserId"] = userEntity.UserId; FormsAuthentication.SetAuthCookie(userEntity.MailId, false); var authTicket = new FormsAuthenticationTicket(1, userEntity.MailId, DateTime.Now, DateTime.Now.AddMinutes(20), false, userEntity.Role); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); HttpContext.Response.Cookies.Add(authCookie); return(RedirectToAction("Index", "Home")); } //if (userEntity.Role == "User") //{ // ViewBag.message = "User Login Successful"; //} //else if(userEntity.Role == "Admin") //{ // ViewBag.message = "Admin Login Successful"; // return RedirectToAction("index", "Admin"); //} //else if(userEntity.Role == "Theatre Manager") //{ // if (TheatreRepository.GetStatus(userEntity.UserId) == "Accept") // { // TempData["id"] = userEntity.UserId; // return RedirectToAction("AddData","TheatreManager"); // } // else // { // ViewBag.message = "The request is not accepted"; // } //} else { ViewBag.message = "Incorrect user name or password "; } } return(View()); }