// Store the token and use this method from the service public String StoreToken(int UserId, String CredentialToken, String strKeyId) { Token token = new Token() .SetDateToken() .SetRevoked(0) .SetUserId(UserId) .SetToken(CredentialToken); IDbDao <IObjectBrowser> tokenDao = new MySqlDbManager(token); return(tokenDao.save(strKeyId, false)); }
// Only for inserting to the database public String SaveInObjects(IObjectBrowser[] mnrgObj) { if (mnrgObj.Length == 0) { return("Create objects..."); } // Connection Obj MySqlDbManager mngrSave = new MySqlDbManager(); mngrSave.GetConn().Open(); MySqlCommand comm = mngrSave.GetConn().CreateCommand(); // Transaction Obj from connection MySql.Data.MySqlClient.MySqlTransaction tr = mngrSave.GetConn().BeginTransaction(); // Pass the tr to the Command comm.Transaction = tr; try { for (int i = 0; i < mnrgObj.Length; i++) { comm.CommandType = CommandType.Text; mngrSave.SetObject(mnrgObj[i]); comm.CommandText = mngrSave.createInsertString(comm); comm.ExecuteNonQuery(); } tr.Commit(); } catch (MySql.Data.MySqlClient.MySqlException ee) { tr.Rollback(); return(ee.ToString()); } finally { mngrSave.GetConn().Close(); } return(OAuthDbCONST.DB_MESS_DONEMULTIOBJ); }
public bool IsValidUser(String email, String pwd) { this.usr = new User() .SetEmail(email) .SetPwd(pwd); this.dbmngr = new MySqlDbManager(usr); this.dbmngr.createConnComm(); this.dbmngr.GetComm().CommandText = this.createSelectUserString(usr); try { MySqlDataReader rdr = this.dbmngr.GetComm().ExecuteReader(); while (rdr.Read()) { if (rdr.HasRows && iBruteforce <= OAuthDbCONST.DB_BRUTEFORCE) { this.usr.SetUserId((int)rdr.GetValue(0)); // Get the user id from the sql query return(true); } else { iBruteforce++; } } } catch (MySql.Data.MySqlClient.MySqlException ee) { iBruteforce++; return(false); } finally { this.dbmngr.GetConn().Close(); } return(false); }
// "SELECT actioncode FROM actiondb where roleid = "; public String displayActionsOrRole(int keyId) { String strDisplayActionsRoles = ""; String strUserRole = new UserRoleDAO(new UserRole() .SetUserId(keyId) ).display(); if (OAuthDbCONST.JWT_SHOWROLES) { MySqlDbManager dbmngr = new MySqlDbManager(new RoleAction().SetRoleName(strUserRole)); dbmngr.SetSelectQueryString(OAuthDbCONST.DBCOLUMN_RAN_ACTION); strDisplayActionsRoles = dbmngr.display(); } else { strDisplayActionsRoles = strUserRole; } return(strDisplayActionsRoles); }
// DELETE UserRole public String DeleteUserRole(UserRole usrRole) { MySqlDbManager msmmngr = new MySqlDbManager(usrRole); return(msmmngr.delete(usrRole.GetObjectId())); }
// INSERT or UPDATE UserRole >> Force update is for updating existing user with new role public string CreateOrUpdateUserRole(UserRole usrRole, Boolean forceUpdate) { MySqlDbManager msmmngr = new MySqlDbManager(usrRole); return(msmmngr.save(usrRole.GetObjectId(), forceUpdate)); }
// DELETE User public String DeleteUser(User usr) { MySqlDbManager msmmngr = new MySqlDbManager(usr); return(msmmngr.delete(usr.GetObjectId())); }
// INSERT or UPDATE User // If no id is given the insert query will work, otherwise the // Update query works. public String CreateOrUpdateUser(User usr) { MySqlDbManager msmmngr = new MySqlDbManager(usr); return(msmmngr.save(usr.GetObjectId(), false)); }
public UserRoleDAO(UserRole userRole) { this.userRole = userRole; this.userRoleMngr = new MySqlDbManager(this.userRole); }