public ActionResult CheckLogin(UserDetailDTO userdetailDTO) { ModelState.Where(m => m.Key == "UserName").FirstOrDefault().Value.Errors.Clear(); ModelState.Where(m => m.Key == "CompanyName").FirstOrDefault().Value.Errors.Clear(); // ModelState.Where(m => m.Key == "OTP").FirstOrDefault().Value.Errors.Clear(); ModelState.Where(m => m.Key == "MobileNo").FirstOrDefault().Value.Errors.Clear(); if (ModelState.IsValid) { UserDetail userDetail = new UserDetail(); userDetail = Mapper.Map<ViewModel.UserDetailDTO, UserDetail>(userdetailDTO); List<UserDetail> userDTL = _LoginService.checkLogin(userDetail); if (userDTL.Count > 0) { Session["UserName"] = userDTL[0].UserName; Session["UserId"] = userDTL[0].Id; Session["UserRole"] = userDTL[0].RoleId; Session["UserEmailId"] = userDTL[0].EmailId; return RedirectToAction("Index", "DashBoard"); // return RedirectToAction("NewLoanEntry", "Dashboard"); } return View("Login", userdetailDTO); } else { return View("Login", userdetailDTO); } }
public List<UserDetail> checkLogin(UserDetail objUserDetail) { try { return _dbContext.UserDetails.Where(c => c.EmailId == objUserDetail.EmailId && c.Password == objUserDetail.Password).ToList(); } catch (Exception) { return null; } }
public Int16 CheckMobileOTP(UserDetail objUserDetail, string MobileNo, string OTP) { try { var mobiledata = _dbContext.MobileOTPDetails.Where(c => c.MobileNo == MobileNo && c.OTP == OTP).Select(d => d.MobileNo).FirstOrDefault(); if (mobiledata == null) { return 3; } else { return UpdateMobileVerification(objUserDetail); } } catch (Exception) { return 4; } }
public Int16 UpdatePassword(UserDetail objUserDetail) { Int16 rtnValue = 0; using (var dbContextTransaction = _dbContext.Database.BeginTransaction()) { try { _dbContext.Configuration.ProxyCreationEnabled = false; _dbContext.Configuration.ValidateOnSaveEnabled = false; // _dbContext.UserDetails.Find() _UserDetail.Attach(objUserDetail); var entry = _dbContext.Entry(objUserDetail); entry.Property(e => e.Password).IsModified = true; entry.Property(e => e.EmailVerificationStatus).IsModified = true; entry.Property(e => e.Status).IsModified = true; entry.Property(e => e.ModifiedBy).IsModified = true; entry.Property(e => e.ModifiedDate).IsModified = true; _dbContext.SaveChanges(); dbContextTransaction.Commit(); if(objUserDetail.Status) { rtnValue = 2; } } catch (Exception ex) { rtnValue = 1; dbContextTransaction.Rollback(); } } return rtnValue; }
public string SaveUserRegistration(UserDetail userDetail) { using (var dbContextTransaction = _dbContext.Database.BeginTransaction()) { try { _UserDetail.Add(userDetail); _dbContext.SaveChanges(); UserCompanyDetail objUserCompanyDetail = new UserCompanyDetail(); objUserCompanyDetail.UserId = userDetail.Id; objUserCompanyDetail.CompanyName = userDetail.CompanyName; objUserCompanyDetail.CreatedBy = userDetail.CreatedBy; objUserCompanyDetail.CreatedDate = userDetail.CreatedDate; _UserCompanyDetail.Add(objUserCompanyDetail); _dbContext.SaveChanges(); dbContextTransaction.Commit(); } catch (Exception) { dbContextTransaction.Rollback(); } } return ""; }