/// <summary> /// Method for updating user password /// </summary> /// <param name="objUserLogin"></param> /// <returns></returns> public bool UpdateUserPassword(UserLogin objUserLogin) { return objUserDAL.UpdateUserPassword(objUserLogin); }
/// <summary> /// Method for updating password /// </summary> /// <param name="objUserLogin"></param> /// <param name="GudId"></param> /// <returns></returns> public bool UpdatePassword(UserLogin objUserLogin, string gudId) { return objUserDAL.UpdatePassword(objUserLogin, gudId); }
/// <summary> /// Method for updating password wrong attempts /// </summary> /// <param name="objUserLogin"></param> /// <returns></returns> public bool UpdatePasswordWorngAttemptDetails(UserLogin objUserLogin) { return objUserDAL.UpdatePasswordWorngAttemptDetails(objUserLogin); }
/// <summary> /// Method for lock user details /// </summary> /// <param name="objUserLogin"></param> /// <returns></returns> public bool LockUserDetails(UserLogin objUserLogin) { return objUserDAL.LockUserDetails(objUserLogin); }
/// <summary> /// Method for updating user password details /// </summary> /// <param name="objUserLogin"></param> /// <returns></returns> public bool UpdateUserPassword(UserLogin objUserLogin) { bool result = false; try { SqlCommand objSqlCommand = new SqlCommand(); SqlParameter[] objLstParams = new SqlParameter[4]; SqlParameter objPassword = new SqlParameter("@Password", SqlDbType.VarChar); objPassword.Value = objUserLogin.Password; objLstParams[0] = objPassword; SqlParameter objUserId = new SqlParameter("@UserId", SqlDbType.Int); objUserId.Value = Convert.ToInt32(objUserLogin.UserId); objLstParams[1] = objUserId; SqlParameter objUpdatedBy = new SqlParameter("@UpdatedBy", SqlDbType.Int); objUpdatedBy.Value = Convert.ToInt32(objUserLogin.UpdatedBy); objLstParams[2] = objUpdatedBy; SqlParameter objUpdatedOn = new SqlParameter("@UpdatedOn", SqlDbType.DateTime); objUpdatedOn.Value = objUserLogin.UpdatedOn; objLstParams[3] = objUpdatedOn; result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.StoredProcedure, SP_UpdateUserPassword, objLstParams)); objSqlCommand.Parameters.Clear(); } catch (Exception ex) { log.Error("UpdateUserPassword \n Message: " + ex.Message + "\n Source: " + ex.Source + "\n StackTrace: " + ex.StackTrace); ExceptionLog.WriteLog(COMMONDATA + " @ UpdateUserPassword ", ex.Message + " \n " + ex.StackTrace); } return result; }
/// <summary> /// Method for updating wrong password attempts /// </summary> /// <param name="objUserLogin"></param> /// <returns></returns> public bool UpdatePasswordWorngAttemptDetails(UserLogin objUserLogin) { bool result = false; try { SqlCommand objSqlCommand = new SqlCommand(); SqlParameter[] objLstParams = new SqlParameter[6]; SqlParameter objAccountLocked = new SqlParameter("@AccountLocked", SqlDbType.Bit); objAccountLocked.Value = objUserLogin.AccountLocked; objLstParams[0] = objAccountLocked; SqlParameter objPasswordWrongAttempts = new SqlParameter("@PasswordWrongAttempts", SqlDbType.Int); objPasswordWrongAttempts.Value = Convert.ToInt32(objUserLogin.PasswordWrongAttempts); objLstParams[1] = objPasswordWrongAttempts; SqlParameter objUpdatedBy = new SqlParameter("@UpdatedBy", SqlDbType.Int); objUpdatedBy.Value = Convert.ToInt32(objUserLogin.UpdatedBy); objLstParams[2] = objUpdatedBy; SqlParameter objUpdatedOn = new SqlParameter("@UpdatedOn", SqlDbType.DateTime); objUpdatedOn.Value = objUserLogin.UpdatedOn; objLstParams[3] = objUpdatedOn; SqlParameter objLastPasswordWrong = new SqlParameter("@LastPasswordWrong", SqlDbType.DateTime); if (objUserLogin.LastPasswordWrong == null) { objLastPasswordWrong.Value = DBNull.Value; } else { objLastPasswordWrong.Value = objUserLogin.LastPasswordWrong; } objLstParams[4] = objLastPasswordWrong; SqlParameter objUserId = new SqlParameter("@UserId", SqlDbType.Int); objUserId.Value = objUserLogin.UserId; objLstParams[5] = objUserId; result = Convert.ToBoolean(SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.StoredProcedure, SP_UpdatePasswordWorngAttemptDetails, objLstParams)); objSqlCommand.Parameters.Clear(); } catch (Exception ex) { log.Error("UpdatePasswordWorngAttemptDetails \n Message: " + ex.Message + "\n Source: " + ex.Source + "\n StackTrace: " + ex.StackTrace); ExceptionLog.WriteLog(COMMONDATA + " @ UpdatePasswordWorngAttemptDetails ", ex.Message + " \n " + ex.StackTrace); } return result; }
/// <summary> /// Method for getting user details by username /// </summary> /// <param name="userName"></param> /// <returns></returns> public User GetUserDetailsByUserName(string userName) { User objUser = new User(); UserLogin objUserLogin = new UserLogin(); try { SqlCommand sqlCommand = new SqlCommand(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.StoredProcedure, SP_GetUserDetailsByUserName, new SqlParameter("@UserName", userName))) { if (reader.Read()) { objUser.Id = Convert.ToInt32(reader["UserId"]); objUser.FirstName = Convert.ToString(reader["FirstName"]); objUser.LastName = Convert.ToString(reader["LastName"]); objUser.Mobile = Convert.ToString(reader["Mobile"]); objUser.Gender = Convert.ToInt32(reader["Gender"]); objUser.Address = Convert.ToString(reader["Address"]); objUser.CountryId = Convert.ToInt32(reader["CountryId"]); objUser.City = Convert.ToString(reader["City"]); objUser.ZipCode = Convert.ToString(reader["ZipCode"]); objUser.CreatedBy = Convert.ToInt32(reader["CreatedBy"]); objUser.CreatedOn = Convert.ToDateTime(reader["CreatedOn"]); objUser.UpdatedBy = Convert.ToInt32(reader["UpdatedBy"]); objUser.UpdatedOn = Convert.ToDateTime(reader["UpdatedOn"]); objUser.IsEmailVerified = Convert.ToBoolean(reader["IsEmailVerified"]); objUserLogin.UserName = Convert.ToString(reader["UserName"]); objUserLogin.Password = Convert.ToString(reader["Password"]); objUserLogin.SecurityQuestion = Convert.ToInt32(reader["SecurityQuestion"]); objUserLogin.Answer = Convert.ToString(reader["Answer"]); objUserLogin.PasswordWrongAttempts = Convert.ToInt32(reader["PasswordWrongAttempts"]); if (!string.IsNullOrWhiteSpace(Convert.ToString(reader["LastPasswordWrong"]))) { objUserLogin.LastPasswordWrong = Convert.ToDateTime(reader["LastPasswordWrong"]); } else { objUserLogin.LastPasswordWrong = null; } objUserLogin.RoleId = Convert.ToInt32(reader["RoleId"]); objUserLogin.IsActive = Convert.ToBoolean(reader["IsActive"]); objUserLogin.UserId = Convert.ToInt32(reader["UserId"]); if (!string.IsNullOrWhiteSpace(Convert.ToString(reader["AccountLocked"]))) { objUserLogin.AccountLocked = Convert.ToBoolean(reader["AccountLocked"]); } else { objUserLogin.AccountLocked = false; } objUser.UserLogin = objUserLogin; } } } catch (Exception ex) { log.Error("GetUserDetailsByUserName \n Message: " + ex.Message + "\n Source: " + ex.Source + "\n StackTrace: " + ex.StackTrace); ExceptionLog.WriteLog(COMMONDATA + " @ GetUserDetailsByUserName ", ex.Message + " \n " + ex.StackTrace); } return objUser; }
/// <summary> /// Method for getting user details /// </summary> /// <returns></returns> public List<User> GetUserDetails() { List<User> objLstUser = new List<User>(); try { SqlCommand sqlCommand = new SqlCommand(); using (DataSet objUserDataSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionString, CommandType.StoredProcedure, SP_GetUserDetails)) { if (objUserDataSet.Tables[0].Rows.Count > 0) { for (int i = 0; i < objUserDataSet.Tables[0].Rows.Count; i++) { User objUser = new User(); UserLogin objUserLogin = new UserLogin(); objUser.Id = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["UserId"]); objUser.FirstName = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["FirstName"]); objUser.LastName = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["LastName"]); objUser.Mobile = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["Mobile"]); objUser.Gender = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["Gender"]); objUser.Address = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["Address"]); objUser.CountryId = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["CountryId"]); objUser.Email = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["Email"]); objUser.City = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["City"]); objUser.ZipCode = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["ZipCode"]); objUser.CreatedBy = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["CreatedBy"]); objUser.CreatedOn = Convert.ToDateTime(objUserDataSet.Tables[0].Rows[i]["CreatedOn"]); objUser.UpdatedBy = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["UpdatedBy"]); objUser.UpdatedOn = Convert.ToDateTime(objUserDataSet.Tables[0].Rows[i]["UpdatedOn"]); objUser.IsEmailVerified = Convert.ToBoolean(objUserDataSet.Tables[0].Rows[i]["IsEmailVerified"]); objUserLogin.UserName = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["UserName"]); objUserLogin.Password = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["Password"]); objUserLogin.SecurityQuestion = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["SecurityQuestion"]); objUserLogin.Answer = Convert.ToString(objUserDataSet.Tables[0].Rows[i]["Answer"]); objUserLogin.PasswordWrongAttempts = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["PasswordWrongAttempts"]); if (!string.IsNullOrWhiteSpace(Convert.ToString(objUserDataSet.Tables[0].Rows[i]["LastPasswordWrong"]))) { objUserLogin.LastPasswordWrong = Convert.ToDateTime(objUserDataSet.Tables[0].Rows[i]["LastPasswordWrong"]); } else { objUserLogin.LastPasswordWrong = null; } objUserLogin.CreatedBy = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["CreatedBy"]); objUserLogin.CreatedOn = Convert.ToDateTime(objUserDataSet.Tables[0].Rows[i]["CreatedOn"]); objUserLogin.UpdatedBy = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["UpdatedBy"]); objUserLogin.UpdatedOn = Convert.ToDateTime(objUserDataSet.Tables[0].Rows[i]["UpdatedOn"]); objUserLogin.RoleId = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["RoleId"]); objUserLogin.IsActive = Convert.ToBoolean(objUserDataSet.Tables[0].Rows[i]["IsActive"]); objUserLogin.UserId = Convert.ToInt32(objUserDataSet.Tables[0].Rows[i]["UserId"]); if (!string.IsNullOrWhiteSpace(Convert.ToString(objUserDataSet.Tables[0].Rows[i]["AccountLocked"]))) { objUserLogin.AccountLocked = Convert.ToBoolean(objUserDataSet.Tables[0].Rows[i]["AccountLocked"]); } else { objUserLogin.AccountLocked = false; } objUser.UserLogin = objUserLogin; objLstUser.Add(objUser); } } } } catch (Exception ex) { log.Error("GetUserDetails \n Message: " + ex.Message + "\n Source: " + ex.Source + "\n StackTrace: " + ex.StackTrace); ExceptionLog.WriteLog(COMMONDATA + " @ GetUserDetails ", ex.Message + " \n " + ex.StackTrace); } return objLstUser; }