From 53e924055a4e2b479c791068bc75db667199526e Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 27 Apr 2018 17:55:04 +0100 Subject: [PATCH] Update DB to version 13: Add fields to sound_synths and drop music_synths. --- Cicm.Database/Operations/MusicSynth.cs | 276 ------------------------- Cicm.Database/Operations/Operations.cs | 2 +- Cicm.Database/Operations/Update.cs | 206 +++++++++++++++++- Cicm.Database/Schemas/Sql/V13.cs | 94 +++++++++ cicm_web/Models/Computer.cs | 4 +- cicm_web/Models/Console.cs | 4 +- cicm_web/Models/MusicSynth.cs | 60 ------ cicm_web/cicm_web.csproj | 2 +- 8 files changed, 305 insertions(+), 343 deletions(-) delete mode 100644 Cicm.Database/Operations/MusicSynth.cs create mode 100644 Cicm.Database/Schemas/Sql/V13.cs delete mode 100644 cicm_web/Models/MusicSynth.cs diff --git a/Cicm.Database/Operations/MusicSynth.cs b/Cicm.Database/Operations/MusicSynth.cs deleted file mode 100644 index c5df7453..00000000 --- a/Cicm.Database/Operations/MusicSynth.cs +++ /dev/null @@ -1,276 +0,0 @@ -/****************************************************************************** -// Canary Islands Computer Museum Website -// ---------------------------------------------------------------------------- -// -// Filename : MusicSynth.cs -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Contains operations to manage music synthetizer. -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2018 Natalia Portillo -*******************************************************************************/ - -using System; -using System.Collections.Generic; -using System.Data; -using Cicm.Database.Schemas; -using Console = System.Console; - -namespace Cicm.Database -{ - public partial class Operations - { - /// - /// Gets all music synthetizers - /// - /// All music synthetizers - /// true if is correct, false otherwise - public bool GetMusicSynths(out List entries) - { - #if DEBUG - Console.WriteLine("Getting all music synthetizers..."); - #endif - - try - { - const string SQL = "SELECT * from music_synths"; - - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = SQL; - DataSet dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - entries = MusicSynthFromDataTable(dataSet.Tables[0]); - - return true; - } - catch(Exception ex) - { - Console.WriteLine("Error getting music synthetizers."); - Console.WriteLine(ex); - entries = null; - return false; - } - } - - /// - /// Gets the specified number of music synthetizers since the specified start - /// - /// List of music synthetizers - /// Start of query - /// How many entries to retrieve - /// true if is correct, false otherwise - public bool GetMusicSynths(out List entries, ulong start, ulong count) - { - #if DEBUG - Console.WriteLine("Getting {0} music synthetizers from {1}...", count, start); - #endif - - try - { - string sql = $"SELECT * FROM music_synths LIMIT {start}, {count}"; - - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = sql; - DataSet dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - entries = MusicSynthFromDataTable(dataSet.Tables[0]); - - return true; - } - catch(Exception ex) - { - Console.WriteLine("Error getting music synthetizers."); - Console.WriteLine(ex); - entries = null; - return false; - } - } - - /// - /// Gets music synthetizer by specified id - /// - /// Id - /// music synthetizer with specified id, null if not found or error - public MusicSynth GetMusicSynth(int id) - { - #if DEBUG - Console.WriteLine("Getting music synthetizer with id {0}...", id); - #endif - - try - { - string sql = $"SELECT * from music_synths WHERE id = '{id}'"; - - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = sql; - DataSet dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - List entries = MusicSynthFromDataTable(dataSet.Tables[0]); - - return entries == null || entries.Count == 0 ? null : entries[0]; - } - catch(Exception ex) - { - Console.WriteLine("Error getting music synthetizer."); - Console.WriteLine(ex); - return null; - } - } - - /// - /// Counts the number of music synthetizers in the database - /// - /// Entries in database - public long CountMusicSynths() - { - #if DEBUG - Console.WriteLine("Counting mpus..."); - #endif - - IDbCommand dbcmd = dbCon.CreateCommand(); - dbcmd.CommandText = "SELECT COUNT(*) FROM music_synths"; - object count = dbcmd.ExecuteScalar(); - dbcmd.Dispose(); - try { return Convert.ToInt64(count); } - catch { return 0; } - } - - /// - /// Adds a new music synthetizer to the database - /// - /// Entry to add - /// ID of added entry - /// true if added correctly, false otherwise - public bool AddMusicSynth(MusicSynth entry, out long id) - { - #if DEBUG - Console.Write("Adding music synthetizer `{0}`...", entry.Name); - #endif - - IDbCommand dbcmd = GetCommandMusicSynth(entry); - IDbTransaction trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - const string SQL = "INSERT INTO music_synths (name)" + " VALUES (@name)"; - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - dbcmd.Dispose(); - - id = dbCore.LastInsertRowId; - - #if DEBUG - Console.WriteLine(" id {0}", id); - #endif - - return true; - } - - /// - /// Updated an music synthetizer in the database - /// - /// Updated entry - /// true if updated correctly, false otherwise - public bool UpdateMusicSynth(MusicSynth entry) - { - #if DEBUG - Console.WriteLine("Updating music synthetizer `{0}`...", entry.Name); - #endif - - IDbCommand dbcmd = GetCommandMusicSynth(entry); - IDbTransaction trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - string sql = "UPDATE music_synths SET name = @name " + $"WHERE id = {entry.Id}"; - - dbcmd.CommandText = sql; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - dbcmd.Dispose(); - - return true; - } - - public bool RemoveMusicSynth(long id) - { - #if DEBUG - Console.WriteLine("Removing music synthetizer widh id `{0}`...", id); - #endif - - IDbCommand dbcmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - string sql = $"DELETE FROM music_synths WHERE id = '{id}';"; - - dbcmd.CommandText = sql; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - dbcmd.Dispose(); - - return true; - } - - IDbCommand GetCommandMusicSynth(MusicSynth entry) - { - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - - param1.ParameterName = "@name"; - - param1.DbType = DbType.String; - - param1.Value = entry.Name; - - dbcmd.Parameters.Add(param1); - - return dbcmd; - } - - static List MusicSynthFromDataTable(DataTable dataTable) - { - List entries = new List(); - - foreach(DataRow dataRow in dataTable.Rows) - { - MusicSynth entry = new MusicSynth {Id = (int)dataRow["id"], Name = (string)dataRow["name"]}; - - entries.Add(entry); - } - - return entries; - } - } -} \ No newline at end of file diff --git a/Cicm.Database/Operations/Operations.cs b/Cicm.Database/Operations/Operations.cs index 363138da..8f0ba67c 100644 --- a/Cicm.Database/Operations/Operations.cs +++ b/Cicm.Database/Operations/Operations.cs @@ -35,7 +35,7 @@ namespace Cicm.Database public partial class Operations { /// Last known database version - const int DB_VERSION = 12; + const int DB_VERSION = 13; /// The column with this value indicates there is no item of this type. public const int DB_NONE = -1; /// This value indicates there's no GPU, but a direct memory->display connection (a framebuffer). diff --git a/Cicm.Database/Operations/Update.cs b/Cicm.Database/Operations/Update.cs index e723b734..29fc7a35 100644 --- a/Cicm.Database/Operations/Update.cs +++ b/Cicm.Database/Operations/Update.cs @@ -128,6 +128,11 @@ namespace Cicm.Database UpdateDatabaseToV12(); break; } + case 12: + { + UpdateDatabaseToV13(); + break; + } } OptimizeDatabase(); @@ -999,7 +1004,7 @@ namespace Cicm.Database trans = dbCon.BeginTransaction(); dbCmd.Transaction = trans; dbCmd.CommandText = - "ALTER TABLE `gpus` ADD FOREIGN KEY `fk_gpus_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;;"; + "ALTER TABLE `gpus` ADD FOREIGN KEY `fk_gpus_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; dbCmd.ExecuteNonQuery(); trans.Commit(); dbCmd.Dispose(); @@ -1086,6 +1091,205 @@ namespace Cicm.Database dbCmd.Dispose(); } + void UpdateDatabaseToV13() + { + Console.WriteLine("Updating database to version 13"); + + Console.WriteLine("Adding new columns to table `sound_synths`"); + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbTransaction trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `sound_synths` ADD COLUMN `company` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `model_code` VARCHAR(45) NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `introduced` DATETIME NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `voices` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `frequency` DOUBLE NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `depth` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `square_wave` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `white_noise` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `type` INT NULL;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating new indexes in table `sound_synths`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX `idx_sound_synths_company` ON `sound_synths` (`company`);\n" + + "CREATE INDEX `idx_sound_synths_model_code` ON `sound_synths` (`model_code`);\n" + + "CREATE INDEX `idx_sound_synths_introduced` ON `sound_synths` (`introduced`);\n" + + "CREATE INDEX `idx_sound_synths_voices` ON `sound_synths` (`voices`);\n" + + "CREATE INDEX `idx_sound_synths_frequency` ON `sound_synths` (`frequency`);\n" + + "CREATE INDEX `idx_sound_synths_depth` ON `sound_synths` (`depth`);\n" + + "CREATE INDEX `idx_sound_synths_square_wave` ON `sound_synths` (`square_wave`);\n" + + "CREATE INDEX `idx_sound_synths_white_noise` ON `sound_synths` (`white_noise`);\n" + + "CREATE INDEX `idx_sound_synths_type` ON `sound_synths` (`type`);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating foreign keys in table `sound_synths`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = + "ALTER TABLE `sound_synths` ADD FOREIGN KEY `fk_sound_synths_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Dropping foreign keys from tables `computers` and `consoles`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `computers` DROP FOREIGN KEY `fk_computers_music_synth`;\n" + + "ALTER TABLE `consoles` DROP FOREIGN KEY `fk_consoles_music_synth`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `music_synths`"); + + Dictionary musicSynths = new Dictionary(); + dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from music_synths"; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + musicSynths.Add(int.Parse(dataRow["id"].ToString()), dataRow["name"].ToString()); + + Dictionary conversionEquivalents = new Dictionary(); + + Console.WriteLine("Converting all items from `music_synths` to `sound_synths`"); + foreach(KeyValuePair musicSynth in musicSynths) + { + dbCmd = dbCon.CreateCommand(); + dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = $"SELECT * from sound_synths WHERE name LIKE '{musicSynth.Value}'"; + dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + if(dataSet.Tables[0].Rows.Count == 1) + { + Console.WriteLine("Converting music synth `{0}` to sound synth `{1}`", musicSynth.Value, + dataSet.Tables[0].Rows[0]["name"]); + conversionEquivalents.Add(musicSynth.Key, int.Parse(dataSet.Tables[0].Rows[0]["id"].ToString())); + } + else + { + Console.Write("Adding new sound synth `{0}`... ", musicSynth.Value); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"INSERT INTO sound_synths (name) VALUES ('{musicSynth.Value}')"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + long id = dbCore.LastInsertRowId; + Console.WriteLine("got id {0}", id); + conversionEquivalents.Add(musicSynth.Key, (int)id); + } + } + + Console.WriteLine("Getting all items from `consoles`"); + Dictionary consoleIdAndMusicSynthId = new Dictionary(); + dbCmd = dbCon.CreateCommand(); + dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT id,music_synth from consoles"; + dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + consoleIdAndMusicSynthId.Add(int.Parse(dataRow["id"].ToString()), + int.Parse(dataRow["music_synth"].ToString())); + + trans = dbCon.BeginTransaction(); + foreach(KeyValuePair keyValuePair in consoleIdAndMusicSynthId) + { + conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId); + Console.WriteLine("Converting music synth {0} to sound synth {1} for console {2}... ", + keyValuePair.Value, newId, keyValuePair.Key); + dbCmd = dbCon.CreateCommand(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"UPDATE consoles SET music_synth = {newId} WHERE id = {keyValuePair.Key}"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + Console.WriteLine("Comitting changes..."); + trans.Commit(); + + Console.WriteLine("Getting all items from `computers`"); + Dictionary computerIdAndMusicSynthId = new Dictionary(); + dbCmd = dbCon.CreateCommand(); + dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT id,music_synth from computers"; + dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + computerIdAndMusicSynthId.Add(int.Parse(dataRow["id"].ToString()), + int.Parse(dataRow["music_synth"].ToString())); + + trans = dbCon.BeginTransaction(); + foreach(KeyValuePair keyValuePair in computerIdAndMusicSynthId) + { + conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId); + Console.WriteLine("Converting music synth {0} to sound synth {1} for computer {2}... ", + keyValuePair.Value, newId, keyValuePair.Key); + dbCmd = dbCon.CreateCommand(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"UPDATE computers SET music_synth = {newId} WHERE id = {keyValuePair.Key}"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + Console.WriteLine("Comitting changes..."); + trans.Commit(); + + Console.WriteLine("Adding new foreign keys to table `computers`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = + "ALTER TABLE `computers` ADD FOREIGN KEY `fk_computers_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new foreign keys to table `consoles`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = + "ALTER TABLE `consoles` ADD FOREIGN KEY `fk_consoles_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Dropping table `music_synths`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "DROP TABLE `music_synths`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 13..."); + dbCmd = dbCon.CreateCommand(); + dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('13')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + void OptimizeDatabase() { IDbCommand dbCmd = dbCon.CreateCommand(); diff --git a/Cicm.Database/Schemas/Sql/V13.cs b/Cicm.Database/Schemas/Sql/V13.cs new file mode 100644 index 00000000..35c62b80 --- /dev/null +++ b/Cicm.Database/Schemas/Sql/V13.cs @@ -0,0 +1,94 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : V12.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains SQL queries to create the database version 7. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +namespace Cicm.Database.Schemas.Sql +{ + public static class V13 + { + public static readonly string Admins = V12.Admins; + + public static readonly string BrowserTests = V12.BrowserTests; + + public static readonly string CicmDb = "CREATE TABLE `cicm_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + ");\n" + + "INSERT INTO cicm_db (version) VALUES ('13');"; + + public static readonly string Companies = V12.Companies; + + public static readonly string Computers = V12.Computers; + + public static readonly string Consoles = V12.Consoles; + + public static readonly string DiskFormats = V12.DiskFormats; + + public static readonly string Forbidden = V12.Forbidden; + + public static readonly string Gpus = V12.Gpus; + + public static readonly string Logs = V12.Logs; + + public static readonly string MoneyDonations = V12.MoneyDonations; + + public static readonly string MusicSynths = V12.MusicSynths; + + public static readonly string News = V12.News; + + public static readonly string OwnedComputers = V12.OwnedComputers; + + public static readonly string OwnedConsoles = V12.OwnedConsoles; + + public static readonly string Processors = V12.Processors; + + public static readonly string SoundSynths = V12.SoundSynths; + + public static readonly string ComputersForeignKeys = V12.ComputersForeignKeys; + + public static readonly string ConsolesForeignKeys = V12.ConsolesForeignKeys; + + public static readonly string Iso3166Numeric = V12.Iso3166Numeric; + + public static readonly string Iso3166NumericValues = V12.Iso3166NumericValues; + + public static readonly string CompaniesForeignKeys = V12.CompaniesForeignKeys; + + public static readonly string CompanyLogos = V12.CompanyLogos; + + public static readonly string CompanyDescriptions = V12.CompanyDescriptions; + + public static readonly string InstructionSets = V12.InstructionSets; + + public static readonly string InstructionSetExtensions = V12.InstructionSetExtensions; + + public static readonly string InstructionSetExtensionsByProcessor = V12.InstructionSetExtensionsByProcessor; + } +} \ No newline at end of file diff --git a/cicm_web/Models/Computer.cs b/cicm_web/Models/Computer.cs index 5a0c01b0..c5a59c8e 100644 --- a/cicm_web/Models/Computer.cs +++ b/cicm_web/Models/Computer.cs @@ -54,7 +54,7 @@ namespace cicm_web.Models public float Mhz2; public string Model; public int MusicChannels; - public MusicSynth MusicSynth; + public SoundSynth MusicSynth; public int Ram; public string Resolution; public int Rom; @@ -136,7 +136,7 @@ namespace cicm_web.Models if(dbItem.MusicSynth > 0) { - item.MusicSynth = MusicSynth.GetItem(dbItem.MusicSynth); + item.MusicSynth = SoundSynth.GetItem(dbItem.MusicSynth); item.MusicChannels = dbItem.MusicChannels; } diff --git a/cicm_web/Models/Console.cs b/cicm_web/Models/Console.cs index d3f76694..0eaebd6f 100644 --- a/cicm_web/Models/Console.cs +++ b/cicm_web/Models/Console.cs @@ -49,7 +49,7 @@ namespace cicm_web.Models public float Mhz2; public string Model; public int MusicChannels; - public MusicSynth MusicSynth; + public SoundSynth MusicSynth; public int Palette; public int Ram; public string Resolution; @@ -122,7 +122,7 @@ namespace cicm_web.Models if(dbItem.MusicSynth > 0) { - item.MusicSynth = MusicSynth.GetItem(dbItem.MusicSynth); + item.MusicSynth = SoundSynth.GetItem(dbItem.MusicSynth); item.MusicChannels = dbItem.MusicChannels; } diff --git a/cicm_web/Models/MusicSynth.cs b/cicm_web/Models/MusicSynth.cs deleted file mode 100644 index a3229487..00000000 --- a/cicm_web/Models/MusicSynth.cs +++ /dev/null @@ -1,60 +0,0 @@ -/****************************************************************************** -// Canary Islands Computer Museum Website -// ---------------------------------------------------------------------------- -// -// Filename : MusicSynth.cs -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Music Synthetizer model -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2003-2018 Natalia Portillo -*******************************************************************************/ - -using System.Collections.Generic; - -namespace cicm_web.Models -{ - public class MusicSynth - { - public int Id; - public string Name; - - public static MusicSynth GetItem(int id) - { - Cicm.Database.Schemas.MusicSynth dbItem = Program.Database?.Operations.GetMusicSynth(id); - return dbItem == null ? null : new MusicSynth {Name = dbItem.Name, Id = dbItem.Id}; - } - - public static MusicSynth[] GetAllItems() - { - List dbItems = null; - bool? result = Program.Database?.Operations.GetMusicSynths(out dbItems); - if(result == null || result.Value == false || dbItems == null) return null; - - List items = new List(); - - foreach(Cicm.Database.Schemas.MusicSynth dbItem in dbItems) - items.Add(new MusicSynth {Id = dbItem.Id, Name = dbItem.Name}); - - return items.ToArray(); - } - } -} \ No newline at end of file diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index f59e313c..ce74fe39 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - 3.0.99.189 + 3.0.99.192 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website