public async Task <ActionResult> Login(LoginViewModel model, string ReturnUrl, string PlanType, string TMS) { if (!ModelState.IsValid) { return(View(model)); } LoginViewModel login = null; if (!String.IsNullOrEmpty(model.UserName)) { login = admin.GetLoginDetails(model.UserName); } if (login == null) { ModelState.AddModelError("", "User Not Found."); return(View(model)); } ViewBag.PlanType = PlanType; ViewBag.TMS = TMS; model.UserName = login.UserName; model.Email = login.Email; //model.PhoneNumber = login.PhoneNumber; var user = UserManager.Find(model.UserName, model.Password); if (user != null) { var roles = UserManager.GetRoles(user.Id); var roleId = roles.FirstOrDefault(); if (admin.IsUserDeactivated(user.Id, roleId)) { ModelState.AddModelError("", "User Not Found."); return(View(model)); } //for calling every day employeeconfirmationdate in procedure if (roleId == "Employee" || roleId == "Admin") { UserViewModel userDetails = generic.GetUserDetail(user.Id); var logcheck = db.SubscriberLogInHistory.Where(c => c.SubscriberId == userDetails.SubscriberId).FirstOrDefault(); if (logcheck == null) { generic.AddSubscriberHitory(userDetails.SubscriberId, DateTime.UtcNow); admin.AddConfirmationNotification(); } else { if (logcheck != null) { var Logindate = logcheck.LastLogIn.Value.Date; if (Logindate != DateTime.Now.Date) { admin.AddConfirmationNotification(); } } } generic.AddSubscriberHitory(userDetails.SubscriberId, DateTime.UtcNow); } generic.UpdateUserHistoryLastLoggedOn(user.Id); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout : false); //if (PlanType != null) //{ // return RedirectToAction("CheckOut", "Plan_Pricing", new { area = "Admin", PlanType = PlanType, TMS = TMS }); //} switch (result) { case SignInStatus.Success: return(RedirectToLocal(ReturnUrl, user.Id)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = ReturnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }