public string ChangeStatus(string id) { UserLoginDetail user = _dbRepository.SelectById(id); user.IsActive = !user.IsActive; return(_dbRepository.Update(user)); }
public Task <long> AddUserLoginDetailAsync(UserLoginDetail userLoginDetail) { return(Task.Run(() => { return userLoginDetailRepository.Insert(userLoginDetail); })); }
public ActionResult SaveModelData(UserLoginDetail model, string create = null) { if (!ModelState.IsValid) { return(View("Create", model)); } string message = string.Empty; try { if (!string.IsNullOrEmpty(model.ID)) { model.ModifiedBy = "1"; model.ModifiedDate = DateTime.Now; message = _dbRepository.Update(model); } else { model.ID = Guid.NewGuid().ToString(); model.CreatedBy = "1"; model.CreatedDate = DateTime.Now; message = _dbRepository.Insert(model); } } catch (Exception ex) { message = ex.Message; } if (!string.IsNullOrEmpty(model.ID)) { if (create == "Save & Continue") { return(RedirectToAction("Edit", new { id = model.ID })); } else if (create == "Save & New") { return(RedirectToAction("Create")); } } //if (model.CustomerId > 0) //{ // TempData[Enums.NotifyType.Success.GetDescription()] = "Customer Updated Successfully."; //} //else //{ // TempData[Enums.NotifyType.Success.GetDescription()] = "Customer Created Successfully."; //} return(RedirectToAction("Index")); }
public virtual ActionResult UpdateLastActivityDate(string userName) { ApplicationUser user = UserManager.FindByName(userName); UserLoginDetail userLogin = db.UserLoginDetail.Where(p => p.UserID.Equals(user.Id)).FirstOrDefault(); userLogin.LastActivity = DateTime.Now; db.Entry(userLogin).State = EntityState.Modified; db.SaveChanges(); return(new EmptyResult()); }
public ActionResult Authorize(UserLoginDetail user) { using (TaxiServiceEntities dbEntities = new TaxiServiceEntities()) { var userDetails = dbEntities.UserLoginDetails.Where(x => x.UserLoginEmail == user.UserLoginEmail && x.UserLoginPassword == user.UserLoginPassword).FirstOrDefault(); if (userDetails == null) { ViewBag.ErrorMessage = "Username or password is incorrect"; Session["LoginUserID"] = null; //user.ErrorMessage = "Username or password is incorrect"; return(View("Index", user)); } else { Session["LoginUserID"] = userDetails.UserLoginID; Session["LoginUserName"] = userDetails.UserLoginMobile; return(RedirectToAction("Index", "Home")); } } }
public ActionResult Index(LoginModel model) { if (!ModelState.IsValid) { return(View("Index", model)); } UserLoginDetail logedInUser = _dbRepository.GetEntities().FirstOrDefault(m => m.LoginID == model.UserName && m.Password == model.Password); if (logedInUser == null) { ModelState.AddModelError("UserName", "Invalid Login Credentials."); return(View(model)); } SessionHelper.UserId = logedInUser.ID; SessionHelper.WelcomeUser = logedInUser.Name; FormsService.SignIn(logedInUser.LoginID, true); return(RedirectToAction("Index", "Home")); }
public ActionResult ValidateTripLogin(ViewTripModel model) { using (context) { UserLoginDetail obj = context.UserLoginDetails.Where(x => x.UserLoginEmail == model.UserName || x.UserLoginMobile.ToString() == model.UserName).FirstOrDefault(); if (obj == null) { TempData["ValidateMessage"] = "The username is doesnt exist in the context"; return(RedirectToAction("SubmitTrip", "Trips", model)); } else { if (obj.UserLoginPassword.Contains("$")) { if (BCrypt.Net.BCrypt.Verify(model.Password, obj.UserLoginPassword)) { if (obj.UserType == 2) { TempData["ValidateMessage"] = "You Cannot Request With Driver Account"; return(RedirectToAction("SubmitTrip", "Trips", model)); } else if (obj.UserType == 3) { Session["LoggedUserID"] = obj.UserTableID; RiderDetailsTable rd = context.RiderDetailsTables.Where(x => x.RiderID == obj.UserTableID).FirstOrDefault(); Session["LoggedUserName"] = rd.FirstName; return(RedirectToAction("SubmitTrip", "Trips", model)); } else if (obj.UserType == 1) { TempData["ValidateMessage"] = "You Cannot Request With Admin Account"; return(RedirectToAction("SubmitTrip", "Trips", model)); } } } else if (obj.UserLoginPassword == model.Password) { if (obj.UserType == 2) { TempData["ValidateMessage"] = "You Cannot Request With Driver Account"; return(RedirectToAction("SubmitTrip", "Trips", model)); } else if (obj.UserType == 3) { Session["LoggedUserID"] = obj.UserTableID; RiderDetailsTable rd = context.RiderDetailsTables.Where(x => x.RiderID == obj.UserTableID).FirstOrDefault(); Session["LoggedUserName"] = rd.FirstName; return(RedirectToAction("SubmitTrip", "Trips", model)); } else if (obj.UserType == 1) { TempData["ValidateMessage"] = "You Cannot Request With Admin Account"; return(RedirectToAction("SubmitTrip", "Trips", model)); } } else { TempData["ValidateMessage"] = "The password is incorrect"; ViewBag.Message = "The password is incorrect"; return(RedirectToAction("SubmitTrip", "Trips", model)); } } } return(RedirectToAction("SubmitTrip", "Trips", model)); }
public long AddUserLoginDetail(UserLoginDetail userLoginDetail) { return(userLoginDetailRepository.Insert(userLoginDetail)); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await UserManager.FindAsync(model.UserName, model.Password); if (user != null) { if (user.EmailConfirmed == true) { string userId = User.Identity.GetUserId(); var currentUserLogin = db.UserLoginDetail.Where(p => p.UserID.Equals(userId)); if (currentUserLogin.Count() > 0) { db.UserLoginDetail.Remove(currentUserLogin.FirstOrDefault()); db.SaveChanges(); } var userLogin = db.UserLoginDetail.Where(p => p.UserID.Equals(user.Id)).ToList(); if (userLogin.Count() > 0) { UserLoginDetail loginUser = userLogin.FirstOrDefault(); var diffLastActUser = DateTime.Now.Subtract((DateTime)loginUser.LastActivity); int loginTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["Login_Timeout"]); if (diffLastActUser.TotalMinutes > loginTimeout) { await SignInManager.SignInAsync(user, isPersistent : true, rememberBrowser : true); loginUser.LastActivity = DateTime.Now; db.Entry(loginUser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", "Could not login, You still Logged In on another device."); } } else { await SignInManager.SignInAsync(user, isPersistent : true, rememberBrowser : true); UserLoginDetail userDetail = new UserLoginDetail(); userDetail.UserID = user.Id; userDetail.LastActivity = DateTime.Now; userDetail.status = "Logged In"; db.UserLoginDetail.Add(userDetail); db.SaveChanges(); return(RedirectToLocal(returnUrl)); } } else { ModelState.AddModelError("", "Confirm Email Address."); } } else { ModelState.AddModelError("", "Invalid username or password."); } } // If we got this far, something failed, redisplay form return(View(model)); }
public JsonResult Authorize(ViewTripModel model) { using (context) { UserLoginDetail obj = context.UserLoginDetails.Where(x => x.UserLoginEmail == model.UserName || x.UserLoginMobile.ToString() == model.UserName).FirstOrDefault(); if (obj == null) { TempData["ValidateMessage"] = "The username is doesnt exist in the context"; return(Json(Response, JsonRequestBehavior.AllowGet)); } else { if (model.Password.Contains("$")) { if (BCrypt.Net.BCrypt.Verify(model.Password, obj.UserLoginPassword)) { if (obj.UserType == 2) { Session["LoggedUserID"] = obj.UserTableID; DriverDetailsTable dr = context.DriverDetailsTables.Where(x => x.DriverID == obj.UserTableID).FirstOrDefault(); Session["LoggedUserName"] = dr.FirstName; Session["ImageUrl"] = dr.UserImageUrl; // return RedirectToAction("Home", "DriverDash", new { area = "DriverHome" }); } else if (obj.UserType == 3) { Session["LoggedUserID"] = obj.UserTableID; RiderDetailsTable rd = context.RiderDetailsTables.Where(x => x.RiderID == obj.UserTableID).FirstOrDefault(); Session["LoggedUserName"] = rd.FirstName; // return RedirectToAction("Index", "UserHome", new { area = "" }); } else if (obj.UserType == 1) { Session["LoggedUserID"] = obj.UserTableID; AdminDetailsTable ad = context.AdminDetailsTables.Where(x => x.AdminID == obj.UserTableID).FirstOrDefault(); Session["LoggedUserName"] = ad.FirstName; Session["ImageUrl"] = ad.UserImageUrl; // return RedirectToAction("Index", "Home", new { area = "Admin" }); } } } else if (obj.UserLoginPassword == model.Password) { if (obj.UserType == 2) { Session["LoggedUserID"] = obj.UserTableID; DriverDetailsTable dr = context.DriverDetailsTables.Where(x => x.DriverID == obj.UserTableID).FirstOrDefault(); Session["LoggedUserName"] = dr.FirstName; Session["ImageUrl"] = dr.UserImageUrl; //return RedirectToAction("Home", "DriverDash", new { area = "DriverHome" }); } else if (obj.UserType == 3) { Session["LoggedUserID"] = obj.UserTableID; RiderDetailsTable rd = context.RiderDetailsTables.Where(x => x.RiderID == obj.UserTableID).FirstOrDefault(); Session["LoggedUserName"] = rd.FirstName; // return RedirectToAction("Index", "UserHome", new { area = "" }); } else if (obj.UserType == 1) { Session["LoggedUserID"] = obj.UserTableID; AdminDetailsTable ad = context.AdminDetailsTables.Where(x => x.AdminID == obj.UserTableID).FirstOrDefault(); Session["LoggedUserName"] = ad.FirstName; Session["ImageUrl"] = ad.UserImageUrl; //return RedirectToAction("Index", "Home", new { area = "Admin" }); } } else { TempData["ValidateMessage"] = "The password is incorrect"; ViewBag.Message = "The password is incorrect"; //return RedirectToAction("Login", "UserHome", model); } } } return(Json(Response)); }