public bool RemoveGroup(Group Group) { if (DatabaseManager.RemoveGroup(Group)) { return true; } else { return false; } }
public bool CreateGroup(Group group) { Random random = new Random(); group.ID = GenerateKey(8, random); try { DatabaseManager.CreateGroup(group); this.Groups = this.RequestGroups(); return true; } catch { return false; } }
public static bool AddGroupUser(Group group, Account account) { using (OracleConnection connection = Connection) { try { OracleCommand command = CreateOracleCommand(connection, "INSERT INTO GROEP_GEBRUIKERS(GEBRUIKER_ID, GROEP_ID) VALUES (:userID, :groupID);"); command.Parameters.Add(":userID", account.ID); command.Parameters.Add(":groupID", group.ID); return ExecuteNonQuery(command); } finally { connection.Close(); } } }
public static bool RemoveGroupUser(Group group, Account account) { using (OracleConnection connection = Connection) { try { OracleCommand command = CreateOracleCommand(connection, "DELETE FROM GROEP_GEBRUIKERS WHERE GEBRUIKER_ID = :userID AND GROEP_ID = :groupID;"); command.Parameters.Add(":userID", account.ID); command.Parameters.Add(":groupID", group.ID); return ExecuteNonQuery(command); } finally { connection.Close(); } } }
public static bool RemoveGroup(Group group) { using (OracleConnection connection = Connection) { try { OracleCommand command = CreateOracleCommand(connection, "UPDATE GROEP SET status = '0' WHERE ID = :groupID"); command.Parameters.Add(":groupID", group.ID); return ExecuteNonQuery(command); } finally { connection.Close(); } } }
public static List<Account> GetGroupAccounts(Group group) { using (OracleConnection connection = Connection) { try { OracleCommand command = CreateOracleCommand(connection, "SELECT ID, EMAIL, NAAM, ROL FROM GEBRUIKER, GROEP_GEBRUIKERS WHERE ID = GROEP_GEBRUIKERS.GEBRUIKER_ID AND GROEP_GEBRUIKERS.GROEP_ID = :GroupID"); command.Parameters.Add(":GroupID", group.ID); OracleDataReader reader = ExecuteQuery(command); List<Account> Accounts = new List<Account>(); while (reader.Read()) { try { string email = reader["Email"].ToString(); string name = reader["Naam"].ToString(); AccountType role = (AccountType)Enum.Parse(typeof(AccountType), reader["rol"].ToString()); Accounts.Add(new Account(email, name, role)); } catch (Exception exc) { Debug.WriteLine(exc.Message); continue; } } return Accounts; } finally { connection.Close(); } } }
public static bool CreateGroup(Group group) { using (OracleConnection connection = Connection) { try { OracleCommand command = CreateOracleCommand(connection, "INSERT INTO GROEP(ID, NAAM) VALUES(:id, :name)"); command.Parameters.Add(":id", group.ID); command.Parameters.Add(":name", group.Name); bool isAdded = ExecuteNonQuery(command); if (!isAdded) { throw new Exception("The group could not be added to the database."); } OracleCommand ownerCommand = CreateOracleCommand(connection, "INSERT INTO GROEP_EIGENAAR(GROEP_ID, GEBRUIKER_ID) VALUES (:groupID, :ownerID"); ownerCommand.Parameters.Add(":groupID", group.ID); ownerCommand.Parameters.Add(":ownerID", group.Owner.ID); return ExecuteNonQuery(ownerCommand); } catch (OracleException exc) { Debug.WriteLine(exc.Message); return false; } finally { connection.Close(); } } }
public List<double> CalculateGroupStatistics(Group group, string type) { return null; }