public static void update(Guid userAccountID, Guid id, string name, string notes, List <int> userAccountAccessEnum) { UserAccountRole objOld = new UserAccountRole(id); string log = ""; log = Util.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'"); log = Util.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'"); using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString)) { if (!string.IsNullOrEmpty(log)) { SqlQueryResult result = DBConnection.query( sqlConnection, QueryTypes.ExecuteNonQuery, "UserAccountRoles_update", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_Name, SqlDbType.NVarChar, Util.wrapNullable(name)) ); if (result.IsSuccessful) { LOGGING.ActivityLog.add(sqlConnection, userAccountID, id, String.Format("Updated: {0}", log)); } } UserAccountAccessRoleAssignment.update(sqlConnection, userAccountID, id, userAccountAccessEnum); } }
/*******************************************************************************************************/ #region DATABASE METHODS public static Guid add(Guid userAccountID, string name, string notes, List <int> userAccountAccessEnum) { Guid id = Guid.NewGuid(); using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString)) { SqlQueryResult result = DBConnection.query( sqlConnection, QueryTypes.ExecuteNonQuery, "UserAccountRoles_add", new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id), new SqlQueryParameter(COL_DB_Name, SqlDbType.NVarChar, name), new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes)) ); if (result.IsSuccessful) { LOGGING.ActivityLog.add(sqlConnection, userAccountID, id, "Added"); UserAccountAccessRoleAssignment.update(sqlConnection, userAccountID, id, userAccountAccessEnum); } } return(id); }