diff --git a/Cicm.Database/Operations/Init.cs b/Cicm.Database/Operations/Init.cs index 7f2dadc8..8c57cfb2 100644 --- a/Cicm.Database/Operations/Init.cs +++ b/Cicm.Database/Operations/Init.cs @@ -49,123 +49,127 @@ namespace Cicm.Database IDbCommand dbCmd = dbCon.CreateCommand(); Console.WriteLine("Creating table `admins`"); - dbCmd.CommandText = V21.Admins; + dbCmd.CommandText = V22.Admins; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `browser_tests`"); - dbCmd.CommandText = V21.BrowserTests; + dbCmd.CommandText = V22.BrowserTests; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `cicm_db`"); - dbCmd.CommandText = V21.CicmDb; + dbCmd.CommandText = V22.CicmDb; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `companies`"); - dbCmd.CommandText = V21.Companies; + dbCmd.CommandText = V22.Companies; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Creating table `machine_families`"); + dbCmd.CommandText = V22.MachineFamilies; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `machines`"); - dbCmd.CommandText = V21.Machines; + dbCmd.CommandText = V22.Machines; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `forbidden`"); - dbCmd.CommandText = V21.Forbidden; + dbCmd.CommandText = V22.Forbidden; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `gpus`"); - dbCmd.CommandText = V21.Gpus; + dbCmd.CommandText = V22.Gpus; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `log`"); - dbCmd.CommandText = V21.Logs; + dbCmd.CommandText = V22.Logs; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `money_donations`"); - dbCmd.CommandText = V21.MoneyDonations; + dbCmd.CommandText = V22.MoneyDonations; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `news`"); - dbCmd.CommandText = V21.News; + dbCmd.CommandText = V22.News; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `owned_computers`"); - dbCmd.CommandText = V21.OwnedComputers; + dbCmd.CommandText = V22.OwnedComputers; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `owned_consoles`"); - dbCmd.CommandText = V21.OwnedConsoles; + dbCmd.CommandText = V22.OwnedConsoles; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `instruction_sets`"); - dbCmd.CommandText = V21.InstructionSets; + dbCmd.CommandText = V22.InstructionSets; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `instruction_set_extensions`"); - dbCmd.CommandText = V21.InstructionSetExtensions; + dbCmd.CommandText = V22.InstructionSetExtensions; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `processors`"); - dbCmd.CommandText = V21.Processors; + dbCmd.CommandText = V22.Processors; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `instruction_set_extensions_by_processor`"); - dbCmd.CommandText = V21.InstructionSetExtensionsByProcessor; + dbCmd.CommandText = V22.InstructionSetExtensionsByProcessor; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `sound_synths`"); - dbCmd.CommandText = V21.SoundSynths; + dbCmd.CommandText = V22.SoundSynths; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `iso3166_1_numeric`"); - dbCmd.CommandText = V21.Iso3166Numeric; + dbCmd.CommandText = V22.Iso3166Numeric; dbCmd.ExecuteNonQuery(); Console.WriteLine("Filling table `iso3166_1_numeric`"); - dbCmd.CommandText = V21.Iso3166NumericValues; + dbCmd.CommandText = V22.Iso3166NumericValues; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating foreign keys for table `companies`"); - dbCmd.CommandText = V21.CompaniesForeignKeys; + dbCmd.CommandText = V22.CompaniesForeignKeys; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating foreign keys for table `machines`"); - dbCmd.CommandText = V21.MachinesForeignKeys; + dbCmd.CommandText = V22.MachinesForeignKeys; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `company_logos`"); - dbCmd.CommandText = V21.CompanyLogos; + dbCmd.CommandText = V22.CompanyLogos; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `company_descriptions`"); - dbCmd.CommandText = V21.CompanyDescriptions; + dbCmd.CommandText = V22.CompanyDescriptions; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `processors_by_machine`"); - dbCmd.CommandText = V21.ProcessorsByMachine; + dbCmd.CommandText = V22.ProcessorsByMachine; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `gpus_by_machine`"); - dbCmd.CommandText = V21.GpusByMachine; + dbCmd.CommandText = V22.GpusByMachine; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `sound_by_machine`"); - dbCmd.CommandText = V21.SoundByMachine; + dbCmd.CommandText = V22.SoundByMachine; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `memory_by_machine`"); - dbCmd.CommandText = V21.MemoryByMachine; + dbCmd.CommandText = V22.MemoryByMachine; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `resolutions`"); - dbCmd.CommandText = V21.Resolutions; + dbCmd.CommandText = V22.Resolutions; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `resolutions_by_gpu`"); - dbCmd.CommandText = V21.ResolutionsByGpu; + dbCmd.CommandText = V22.ResolutionsByGpu; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `storage_by_machine`"); - dbCmd.CommandText = V21.StorageByMachine; + dbCmd.CommandText = V22.StorageByMachine; dbCmd.ExecuteNonQuery(); return true; diff --git a/Cicm.Database/Operations/Machine.cs b/Cicm.Database/Operations/Machine.cs index 595a8620..7c19640a 100644 --- a/Cicm.Database/Operations/Machine.cs +++ b/Cicm.Database/Operations/Machine.cs @@ -206,7 +206,7 @@ namespace Cicm.Database public bool AddMachine(Machine entry, out long id) { #if DEBUG - Console.Write("Adding machine `{0}`...", entry.Model); + Console.Write("Adding machine `{0}`...", entry.Name); #endif IDbCommand dbcmd = GetCommandMachine(entry); @@ -214,7 +214,7 @@ namespace Cicm.Database dbcmd.Transaction = trans; const string SQL = - "INSERT INTO machines (company, introduced, model, type) VALUES (@company, @introduced, @model, @type)"; + "INSERT INTO machines (company, introduced, name, type, model, family) VALUES (@company, @introduced, @name, @type, @model, @family)"; dbcmd.CommandText = SQL; @@ -239,7 +239,7 @@ namespace Cicm.Database public bool UpdateMachine(Machine entry) { #if DEBUG - Console.WriteLine("Updating machine `{0}`...", entry.Model); + Console.WriteLine("Updating machine `{0}`...", entry.Name); #endif IDbCommand dbcmd = GetCommandMachine(entry); @@ -247,7 +247,7 @@ namespace Cicm.Database dbcmd.Transaction = trans; string sql = - "UPDATE machines SET company = @company, introduced = @introduced, model = @model, type = @type " + + "UPDATE machines SET company = @company, introduced = @introduced, name = @name, type = @type, model = @model, family = @family " + $"WHERE id = {entry.Id}"; dbcmd.CommandText = sql; @@ -293,26 +293,36 @@ namespace Cicm.Database IDbDataParameter param2 = dbcmd.CreateParameter(); IDbDataParameter param3 = dbcmd.CreateParameter(); IDbDataParameter param4 = dbcmd.CreateParameter(); + IDbDataParameter param5 = dbcmd.CreateParameter(); + IDbDataParameter param6 = dbcmd.CreateParameter(); param1.ParameterName = "@company"; param2.ParameterName = "@introduced"; - param3.ParameterName = "@model"; + param3.ParameterName = "@name"; param4.ParameterName = "@type"; + param5.ParameterName = "@model"; + param6.ParameterName = "@family"; param1.DbType = DbType.Int32; param2.DbType = DbType.DateTime; param3.DbType = DbType.String; param4.DbType = DbType.Int32; + param5.DbType = DbType.String; + param6.DbType = DbType.Int32; param1.Value = entry.Company; param2.Value = entry.Introduced; - param3.Value = entry.Model; + param3.Value = entry.Name; param4.Value = entry.Type; + param5.Value = entry.Model; + param6.Value = entry.Family == 0 ? (object)null : entry.Family; dbcmd.Parameters.Add(param1); dbcmd.Parameters.Add(param2); dbcmd.Parameters.Add(param3); dbcmd.Parameters.Add(param4); + dbcmd.Parameters.Add(param5); + dbcmd.Parameters.Add(param6); return dbcmd; } @@ -329,8 +339,10 @@ namespace Cicm.Database Company = (int)dataRow["company"], Introduced = dataRow["introduced"] == DBNull.Value ? DateTime.MinValue : (DateTime)dataRow["introduced"], - Model = (string)dataRow["model"], - Type = (MachineType)dataRow["type"] + Name = (string)dataRow["name"], + Type = (MachineType)dataRow["type"], + Model = dataRow["model"] == DBNull.Value ? null : (string)dataRow["model"], + Family = dataRow["family"] == DBNull.Value ? 0 : (int)dataRow["family"] }; entries.Add(entry); diff --git a/Cicm.Database/Operations/MachineFamily.cs b/Cicm.Database/Operations/MachineFamily.cs new file mode 100644 index 00000000..a8398c0c --- /dev/null +++ b/Cicm.Database/Operations/MachineFamily.cs @@ -0,0 +1,326 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : MachineFamily.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains operations to manage machine_families. +// +// --[ 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; + +namespace Cicm.Database +{ + public partial class Operations + { + /// + /// Gets all machine_families + /// + /// All machine_families + /// true if is correct, false otherwise + public bool GetMachineFamilies(out List entries) + { + #if DEBUG + Console.WriteLine("Getting all machine_families..."); + #endif + + try + { + const string SQL = "SELECT * from machine_families"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = SQL; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + entries = MachineFamiliesFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting machine_families."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + /// + /// Gets all machine_families from specified company + /// + /// All machine_families + /// Company id + /// true if is correct, false otherwise + public bool GetMachineFamilies(out List entries, int company) + { + #if DEBUG + Console.WriteLine("Getting all machine_families from company id {0}...", company); + #endif + + try + { + string sql = $"SELECT * from machine_families WHERE company = '{company}'"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = sql; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + entries = MachineFamiliesFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting machine_families."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + /// + /// Gets the specified number of machine_families since the specified start + /// + /// List of machine_families + /// Start of query + /// How many entries to retrieve + /// true if is correct, false otherwise + public bool GetMachineFamilies(out List entries, ulong start, ulong count) + { + #if DEBUG + Console.WriteLine("Getting {0} machine_families from {1}...", count, start); + #endif + + try + { + string sql = $"SELECT * FROM machine_families 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 = MachineFamiliesFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting machine_families."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + /// + /// Gets machine_families by specified id + /// + /// Id + /// MachineFamily with specified id, null if not found or error + public MachineFamily GetMachineFamily(int id) + { + #if DEBUG + Console.WriteLine("Getting machine_families with id {0}...", id); + #endif + + try + { + string sql = $"SELECT * from machine_families 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 = MachineFamiliesFromDataTable(dataSet.Tables[0]); + + return entries == null || entries.Count == 0 ? null : entries[0]; + } + catch(Exception ex) + { + Console.WriteLine("Error getting machine_families."); + Console.WriteLine(ex); + return null; + } + } + + /// + /// Counts the number of machine_families in the database + /// + /// Entries in database + public long CountMachineFamilies() + { + #if DEBUG + Console.WriteLine("Counting machine_families..."); + #endif + + IDbCommand dbcmd = dbCon.CreateCommand(); + dbcmd.CommandText = "SELECT COUNT(*) FROM machine_families"; + object count = dbcmd.ExecuteScalar(); + dbcmd.Dispose(); + try { return Convert.ToInt64(count); } + catch { return 0; } + } + + /// + /// Adds a new administrator to the database + /// + /// Entry to add + /// ID of added entry + /// true if added correctly, false otherwise + public bool AddMachineFamily(MachineFamily entry, out long id) + { + #if DEBUG + Console.Write("Adding machine_families `{0}`...", entry.Name); + #endif + + IDbCommand dbcmd = GetCommandMachineFamily(entry); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + const string SQL = "INSERT INTO machine_families (company, name) VALUES (@company, @name)"; + + dbcmd.CommandText = SQL; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + id = dbCore.LastInsertRowId; + + #if DEBUG + Console.WriteLine(" id {0}", id); + #endif + + return true; + } + + /// + /// Updated a machine_families in the database + /// + /// Updated entry + /// true if updated correctly, false otherwise + public bool UpdateMachineFamily(MachineFamily entry) + { + #if DEBUG + Console.WriteLine("Updating machine_families `{0}`...", entry.Name); + #endif + + IDbCommand dbcmd = GetCommandMachineFamily(entry); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + string sql = "UPDATE machine_families SET company = @company, name = @name " + $"WHERE id = {entry.Id}"; + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + return true; + } + + /// + /// Removes a machine_families from the database + /// + /// ID of entry to remove + /// true if removed correctly, false otherwise + public bool RemoveMachineFamily(long id) + { + #if DEBUG + Console.WriteLine("Removing machine_families widh id `{0}`...", id); + #endif + + IDbCommand dbcmd = dbCon.CreateCommand(); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + string sql = $"DELETE FROM machine_families WHERE id = '{id}';"; + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + return true; + } + + IDbCommand GetCommandMachineFamily(MachineFamily entry) + { + IDbCommand dbcmd = dbCon.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + + param1.ParameterName = "@company"; + param2.ParameterName = "@name"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.String; + + param1.Value = entry.Company; + param2.Value = entry.Name; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + + return dbcmd; + } + + static List MachineFamiliesFromDataTable(DataTable dataTable) + { + List entries = new List(); + + foreach(DataRow dataRow in dataTable.Rows) + { + MachineFamily entry = new MachineFamily + { + Id = (int)dataRow["id"], + Company = (int)dataRow["company"], + 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 fbe065da..136bee7d 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 = 21; + const int DB_VERSION = 22; /// The column with this value indicates there is no item of this type. public const int DB_NONE = -1; /// diff --git a/Cicm.Database/Operations/Update.cs b/Cicm.Database/Operations/Update.cs index 7536fda4..eccdbbd0 100644 --- a/Cicm.Database/Operations/Update.cs +++ b/Cicm.Database/Operations/Update.cs @@ -174,6 +174,11 @@ namespace Cicm.Database UpdateDatabaseToV21(); break; } + case 21: + { + UpdateDatabaseToV22(); + break; + } } OptimizeDatabase(); @@ -2486,6 +2491,59 @@ namespace Cicm.Database dbCmd.Dispose(); } + void UpdateDatabaseToV22() + { + Console.WriteLine("Updating database to version 22"); + + Console.WriteLine("Creating new table table `machine_families`"); + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbTransaction trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V22.MachineFamilies; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new columns to table `machines`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `machines` ADD COLUMN `family` INT DEFAULT NULL;\n" + + "ALTER TABLE `machines` CHANGE COLUMN `model` `name` VARCHAR(255) NOT NULL;\n" + + "ALTER TABLE `machines` DROP INDEX `idx_machines_model`;\n" + + "ALTER TABLE `machines` ADD COLUMN `model` VARCHAR(50) DEFAULT NULL;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new indexes to table `machines`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX `idx_machines_family` ON `machines` (`family`);\n" + + "CREATE INDEX `idx_machines_name` ON `machines` (`name`);\n" + + "CREATE INDEX `idx_machines_model` ON `machines` (`model`);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new foreign keys to table `machines`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_family` (family) REFERENCES machine_families (`id`) ON UPDATE CASCADE"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 22..."); + dbCmd = dbCon.CreateCommand(); + dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('22')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + void OptimizeDatabase() { IDbCommand dbCmd = dbCon.CreateCommand(); diff --git a/Cicm.Database/Schemas/Machine.cs b/Cicm.Database/Schemas/Machine.cs index 0eca8ef5..ef91f977 100644 --- a/Cicm.Database/Schemas/Machine.cs +++ b/Cicm.Database/Schemas/Machine.cs @@ -37,12 +37,16 @@ namespace Cicm.Database.Schemas { /// Manufacturer's company ID public int Company; + /// Machine family + public int Family; /// ID public int Id; /// Introduction date, null if unknown, 1000 if prototype public DateTime Introduced; - /// Model name + /// Machine model/SKU public string Model; + /// Model name + public string Name; /// Machine type public MachineType Type; } diff --git a/Cicm.Database/Schemas/MachineFamily.cs b/Cicm.Database/Schemas/MachineFamily.cs new file mode 100644 index 00000000..955ac89a --- /dev/null +++ b/Cicm.Database/Schemas/MachineFamily.cs @@ -0,0 +1,43 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Computer.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// High level representation of a computer. +// +// --[ 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 +{ + /// Computer + public class MachineFamily + { + /// Manufacturer's company ID + public int Company; + /// ID + public int Id; + /// Model name + public string Name; + } +} \ No newline at end of file diff --git a/Cicm.Database/Schemas/Sql/V21.cs b/Cicm.Database/Schemas/Sql/V21.cs index a2392aa8..8bab6bd1 100644 --- a/Cicm.Database/Schemas/Sql/V21.cs +++ b/Cicm.Database/Schemas/Sql/V21.cs @@ -41,7 +41,7 @@ namespace Cicm.Database.Schemas.Sql "`version` int(11) NOT NULL,\n" + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + "PRIMARY KEY (`id`));\n" + - "INSERT INTO cicm_db (version) VALUES ('20');"; + "INSERT INTO cicm_db (version) VALUES ('21');"; public static readonly string Companies = V20.Companies; diff --git a/Cicm.Database/Schemas/Sql/V22.cs b/Cicm.Database/Schemas/Sql/V22.cs new file mode 100644 index 00000000..5bae1eba --- /dev/null +++ b/Cicm.Database/Schemas/Sql/V22.cs @@ -0,0 +1,125 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : V22.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 V22 + { + public static readonly string Admins = V21.Admins; + + public static readonly string BrowserTests = V21.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" + + "INSERT INTO cicm_db (version) VALUES ('22');"; + + public static readonly string Companies = V21.Companies; + + public static readonly string Machines = "CREATE TABLE `machines` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`company` int(11) NOT NULL DEFAULT '0',\n" + + "`name` varchar(255) NOT NULL,\n" + + "`type` int(11) NOT NULL DEFAULT '0',\n" + + "`introduced` datetime DEFAULT NULL,\n" + + "`family` int(11) DEFAULT NULL,\n" + + "`model` varchar(50) DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_machines_company` (`company`),\n" + + "KEY `idx_machines_type` (`type`),\n" + + "KEY `idx_machines_introduced` (`introduced`),\n" + + "KEY `idx_machines_family` (`family`),\n" + + "KEY `idx_machines_name` (`name`),\n" + + "KEY `idx_machines_model` (`model`));"; + + public static readonly string Forbidden = V21.Forbidden; + + public static readonly string Gpus = V21.Gpus; + + public static readonly string Logs = V21.Logs; + + public static readonly string MoneyDonations = V21.MoneyDonations; + + public static readonly string News = V21.News; + + public static readonly string OwnedComputers = V21.OwnedComputers; + + public static readonly string OwnedConsoles = V21.OwnedConsoles; + + public static readonly string Processors = V21.Processors; + + public static readonly string SoundSynths = V21.SoundSynths; + + public static readonly string MachinesForeignKeys = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_family` (family) REFERENCES `machine_families` (`id`) ON UPDATE CASCADE;"; + + public static readonly string Iso3166Numeric = V21.Iso3166Numeric; + + public static readonly string Iso3166NumericValues = V21.Iso3166NumericValues; + + public static readonly string CompaniesForeignKeys = V21.CompaniesForeignKeys; + + public static readonly string CompanyLogos = V21.CompanyLogos; + + public static readonly string CompanyDescriptions = V21.CompanyDescriptions; + + public static readonly string InstructionSets = V21.InstructionSets; + + public static readonly string InstructionSetExtensions = V21.InstructionSetExtensions; + + public static readonly string InstructionSetExtensionsByProcessor = V21.InstructionSetExtensionsByProcessor; + + public static readonly string ProcessorsByMachine = V21.ProcessorsByMachine; + + public static readonly string GpusByMachine = V21.GpusByMachine; + + public static readonly string SoundByMachine = V21.SoundByMachine; + + public static readonly string MemoryByMachine = V21.MemoryByMachine; + + public static readonly string Resolutions = V21.Resolutions; + + public static readonly string ResolutionsByGpu = V21.ResolutionsByGpu; + + public static readonly string StorageByMachine = V21.StorageByMachine; + + public static readonly string MachineFamilies = "CREATE TABLE `machine_families` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`company` INT NOT NULL,\n" + + "`name` VARCHAR(255) NOT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_machine_families_company` (`company`),\n" + + "KEY `idx_machine_families_name` (`name`),\n" + + "CONSTRAINT `fk_machine_families_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; + } +} \ No newline at end of file diff --git a/cicm_web/Models/Computer.cs b/cicm_web/Models/Computer.cs index c0e8f007..f3c97bb1 100644 --- a/cicm_web/Models/Computer.cs +++ b/cicm_web/Models/Computer.cs @@ -44,7 +44,7 @@ namespace cicm_web.Models List items = new List(); - return dbItems.Select(Machine.TransformItem).OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return dbItems.Select(Machine.TransformItem).OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static Machine[] GetItemsFromCompany(int id) @@ -54,7 +54,7 @@ namespace cicm_web.Models if(result == null || result.Value == false || dbItems == null) return null; // TODO: Company chosen by DB - return dbItems.Where(t => t.Company == id).Select(Machine.TransformItem).OrderBy(t => t.Model).ToArray(); + return dbItems.Where(t => t.Company == id).Select(Machine.TransformItem).OrderBy(t => t.Name).ToArray(); } public static Machine GetItem(int id) @@ -76,7 +76,7 @@ namespace cicm_web.Models List items = new List(); foreach(Cicm.Database.Schemas.Machine dbItem in dbItems) items.Add(MachineMini.TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsStartingWithLetter(char letter) @@ -87,10 +87,10 @@ namespace cicm_web.Models List items = new List(); foreach(Cicm.Database.Schemas.Machine dbItem in dbItems) - if(dbItem.Model.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase)) + if(dbItem.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase)) items.Add(MachineMini.TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsFromYear(int year) @@ -104,7 +104,7 @@ namespace cicm_web.Models if(dbItem.Introduced.Year == year) items.Add(MachineMini.TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsWithCompany(int id, string companyName) @@ -119,8 +119,8 @@ namespace cicm_web.Models { Company = new Company {Id = id, Name = companyName}, Id = t.Id, - Model = t.Model - }).OrderBy(t => t.Model).ToArray(); + Name = t.Name + }).OrderBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsFromCompany(int id) @@ -130,8 +130,7 @@ namespace cicm_web.Models if(result == null || result.Value == false || dbItems == null) return null; // TODO: Company chosen by DB - return dbItems.Where(t => t.Company == id).Select(MachineMini.TransformItem).OrderBy(t => t.Model) - .ToArray(); + return dbItems.Where(t => t.Company == id).Select(MachineMini.TransformItem).OrderBy(t => t.Name).ToArray(); } } } \ No newline at end of file diff --git a/cicm_web/Models/Console.cs b/cicm_web/Models/Console.cs index f9518c20..40ef71c1 100644 --- a/cicm_web/Models/Console.cs +++ b/cicm_web/Models/Console.cs @@ -52,7 +52,7 @@ namespace cicm_web.Models if(result == null || result.Value == false || dbItems == null) return null; // TODO: Company chosen by DB - return dbItems.Where(t => t.Company == id).Select(Machine.TransformItem).OrderBy(t => t.Model).ToArray(); + return dbItems.Where(t => t.Company == id).Select(Machine.TransformItem).OrderBy(t => t.Name).ToArray(); } public static Machine GetItem(int id) @@ -74,7 +74,7 @@ namespace cicm_web.Models List items = new List(); foreach(Cicm.Database.Schemas.Machine dbItem in dbItems) items.Add(MachineMini.TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsStartingWithLetter(char letter) @@ -85,10 +85,10 @@ namespace cicm_web.Models List items = new List(); foreach(Cicm.Database.Schemas.Machine dbItem in dbItems) - if(dbItem.Model.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase)) + if(dbItem.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase)) items.Add(MachineMini.TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsFromYear(int year) @@ -102,7 +102,7 @@ namespace cicm_web.Models if(dbItem.Introduced.Year == year) items.Add(MachineMini.TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsWithCompany(int id, string companyName) @@ -117,8 +117,8 @@ namespace cicm_web.Models { Company = new Company {Id = id, Name = companyName}, Id = t.Id, - Model = t.Model - }).OrderBy(t => t.Model).ToArray(); + Name = t.Name + }).OrderBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsFromCompany(int id) @@ -128,8 +128,7 @@ namespace cicm_web.Models if(result == null || result.Value == false || dbItems == null) return null; // TODO: Company chosen by DB - return dbItems.Where(t => t.Company == id).Select(MachineMini.TransformItem).OrderBy(t => t.Model) - .ToArray(); + return dbItems.Where(t => t.Company == id).Select(MachineMini.TransformItem).OrderBy(t => t.Name).ToArray(); } } } \ No newline at end of file diff --git a/cicm_web/Models/Machine.cs b/cicm_web/Models/Machine.cs index 0ca897ef..144b3a94 100644 --- a/cicm_web/Models/Machine.cs +++ b/cicm_web/Models/Machine.cs @@ -38,11 +38,13 @@ namespace cicm_web.Models public class Machine { public Company Company; + public MachineFamily Family; public GpuByMachine[] Gpus; public int Id; public DateTime Introduced; public MemoryByMachine[] Memories; public string Model; + public string Name; public ProcessorByMachine[] Processors; public SoundByMachine[] SoundSynths; public StorageByMachine[] Storage; @@ -56,7 +58,7 @@ namespace cicm_web.Models List items = new List(); - return dbItems.Select(TransformItem).OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return dbItems.Select(TransformItem).OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static Machine[] GetItemsFromCompany(int id) @@ -66,7 +68,7 @@ namespace cicm_web.Models if(result == null || result.Value == false || dbItems == null) return null; // TODO: Company chosen by DB - return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Model).ToArray(); + return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Name).ToArray(); } public static Machine GetItem(int id) @@ -82,13 +84,15 @@ namespace cicm_web.Models Company = Company.GetItem(dbItem.Company), Gpus = GpuByMachine.GetAllItems(dbItem.Id), Id = dbItem.Id, - Model = dbItem.Model, + Name = dbItem.Name, Introduced = dbItem.Introduced, Type = dbItem.Type, Processors = ProcessorByMachine.GetAllItems(dbItem.Id), SoundSynths = SoundByMachine.GetAllItems(dbItem.Id), Memories = MemoryByMachine.GetAllItems(dbItem.Id), - Storage = StorageByMachine.GetAllItems(dbItem.Id) + Storage = StorageByMachine.GetAllItems(dbItem.Id), + Family = MachineFamily.GetItem(dbItem.Family), + Model = dbItem.Model }; } } @@ -97,7 +101,7 @@ namespace cicm_web.Models { public Company Company; public int Id; - public string Model; + public string Name; public static MachineMini[] GetAllItems() { @@ -109,7 +113,7 @@ namespace cicm_web.Models List items = new List(); foreach(Cicm.Database.Schemas.Machine dbItem in dbItems) items.Add(TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsStartingWithLetter(char letter) @@ -120,10 +124,10 @@ namespace cicm_web.Models List items = new List(); foreach(Cicm.Database.Schemas.Machine dbItem in dbItems) - if(dbItem.Model.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase)) + if(dbItem.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase)) items.Add(TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsFromYear(int year) @@ -137,7 +141,7 @@ namespace cicm_web.Models if(dbItem.Introduced.Year == year) items.Add(TransformItem(dbItem)); - return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray(); + return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsWithCompany(int id, string companyName) @@ -152,8 +156,8 @@ namespace cicm_web.Models { Company = new Company {Id = id, Name = companyName}, Id = t.Id, - Model = t.Model - }).OrderBy(t => t.Model).ToArray(); + Name = t.Name + }).OrderBy(t => t.Name).ToArray(); } public static MachineMini[] GetItemsFromCompany(int id) @@ -163,12 +167,12 @@ namespace cicm_web.Models if(result == null || result.Value == false || dbItems == null) return null; // TODO: Company chosen by DB - return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Model).ToArray(); + return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Name).ToArray(); } internal static MachineMini TransformItem(Cicm.Database.Schemas.Machine dbItem) { - return new MachineMini {Company = Company.GetItem(dbItem.Company), Id = dbItem.Id, Model = dbItem.Model}; + return new MachineMini {Company = Company.GetItem(dbItem.Company), Id = dbItem.Id, Name = dbItem.Name}; } } } \ No newline at end of file diff --git a/cicm_web/Models/MachineFamily.cs b/cicm_web/Models/MachineFamily.cs new file mode 100644 index 00000000..71238029 --- /dev/null +++ b/cicm_web/Models/MachineFamily.cs @@ -0,0 +1,47 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : GpuByMachine.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Gpu by machine 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 +*******************************************************************************/ + +namespace cicm_web.Models +{ + public class MachineFamily + { + public int Id; + public string Name; + + public static MachineFamily GetItem(int familyId) + { + Cicm.Database.Schemas.MachineFamily result = Program.Database?.Operations.GetMachineFamily(familyId); + + if(result == null || result.Id != familyId) return null; + + return new MachineFamily {Name = result.Name, Id = familyId}; + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/News.cs b/cicm_web/Models/News.cs index c67b56e7..55ca828b 100644 --- a/cicm_web/Models/News.cs +++ b/cicm_web/Models/News.cs @@ -87,56 +87,56 @@ namespace cicm_web.Models imageUrl = "assets/photos/computers/"; targetView = "Computer"; computer = Computer.GetItem(dbItem.AffectedId); - subtext = $"{computer.Company.Name} - {computer.Model}"; + subtext = $"{computer.Company.Name} - {computer.Name}"; break; case NewsType.NewConsoleInDb: text = "New videoconsole added to the database."; imageUrl = "assets/photos/consoles/"; targetView = "Console"; console = Console.GetItem(dbItem.AffectedId); - subtext = $"{console.Company.Name} - {console.Model}"; + subtext = $"{console.Company.Name} - {console.Name}"; break; case NewsType.NewComputerInCollection: text = "New computer added to the museum's collection."; imageUrl = "assets/photos/computers/"; targetView = "CollectionComputer"; owncomputer = OwnedComputer.GetItem(dbItem.AffectedId); - subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Model}"; + subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Name}"; break; case NewsType.NewConsoleInCollection: text = "New videoconsole added to the museum's collection."; imageUrl = "assets/photos/consoles/"; targetView = "CollectionConsole"; ownconsole = OwnedConsole.GetItem(dbItem.AffectedId); - subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Model}"; + subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Name}"; break; case NewsType.UpdatedComputerInDb: text = "Updated computer from the database."; imageUrl = "assets/photos/computers/"; targetView = "Computer"; computer = Computer.GetItem(dbItem.AffectedId); - subtext = $"{computer.Company.Name} - {computer.Model}"; + subtext = $"{computer.Company.Name} - {computer.Name}"; break; case NewsType.UpdatedConsoleInDb: text = "Updated videoconsole from the database."; imageUrl = "assets/photos/consoles/"; targetView = "Console"; console = Console.GetItem(dbItem.AffectedId); - subtext = $"{console.Company.Name} - {console.Model}"; + subtext = $"{console.Company.Name} - {console.Name}"; break; case NewsType.UpdatedComputerInCollection: text = "Updated computer from museum's collection."; imageUrl = "assets/photos/computers/"; targetView = "CollectionComputer"; owncomputer = OwnedComputer.GetItem(dbItem.AffectedId); - subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Model}"; + subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Name}"; break; case NewsType.UpdatedConsoleInCollection: text = "Updated videoconsole from museum's collection."; imageUrl = "assets/photos/consoles/"; targetView = "CollectionConsole"; ownconsole = OwnedConsole.GetItem(dbItem.AffectedId); - subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Model}"; + subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Name}"; break; case NewsType.NewMoneyDonation: text = "New money donation."; diff --git a/cicm_web/Views/Company/View.cshtml b/cicm_web/Views/Company/View.cshtml index 7292024f..f1476e06 100644 --- a/cicm_web/Views/Company/View.cshtml +++ b/cicm_web/Views/Company/View.cshtml @@ -370,7 +370,7 @@ - @computer.Model + @computer.Name
} @@ -412,7 +412,7 @@ - @console.Model + @console.Name
} diff --git a/cicm_web/Views/Computer/ByLetter.cshtml b/cicm_web/Views/Computer/ByLetter.cshtml index 953c7705..f3e06483 100644 --- a/cicm_web/Views/Computer/ByLetter.cshtml +++ b/cicm_web/Views/Computer/ByLetter.cshtml @@ -51,7 +51,7 @@ - @computer.Company.Name @computer.Model + @computer.Company.Name @computer.Name
}

diff --git a/cicm_web/Views/Computer/ByYear.cshtml b/cicm_web/Views/Computer/ByYear.cshtml index 05a1c386..006c6259 100644 --- a/cicm_web/Views/Computer/ByYear.cshtml +++ b/cicm_web/Views/Computer/ByYear.cshtml @@ -47,7 +47,7 @@ - @computer.Company.Name @computer.Model + @computer.Company.Name @computer.Name
}

diff --git a/cicm_web/Views/Console/ByLetter.cshtml b/cicm_web/Views/Console/ByLetter.cshtml index 36c17e99..060e0abc 100644 --- a/cicm_web/Views/Console/ByLetter.cshtml +++ b/cicm_web/Views/Console/ByLetter.cshtml @@ -51,7 +51,7 @@ - @console.Company.Name @console.Model + @console.Company.Name @console.Name
}

diff --git a/cicm_web/Views/Console/ByYear.cshtml b/cicm_web/Views/Console/ByYear.cshtml index 12d04786..3c5571c9 100644 --- a/cicm_web/Views/Console/ByYear.cshtml +++ b/cicm_web/Views/Console/ByYear.cshtml @@ -47,7 +47,7 @@ - @console.Company.Name @console.Model + @console.Company.Name @console.Name
}

diff --git a/cicm_web/Views/Machine/View.cshtml b/cicm_web/Views/Machine/View.cshtml index 52cf4705..4e67e905 100644 --- a/cicm_web/Views/Machine/View.cshtml +++ b/cicm_web/Views/Machine/View.cshtml @@ -70,7 +70,7 @@ - @Model.Company.Name @Model.Model + @Model.Company.Name @Model.Name @if(Model.Introduced.Year != 1000) @@ -90,6 +90,37 @@ } +@if(Model.Family != null) +{ + + + + +} +@if(Model.Model != null) +{ + + + + +} @if(Model.Processors != null && Model.Processors.Length > 0) { @@ -504,143 +535,145 @@
+
+ Family +
+
+ + @Model.Family.Name +
+
+ Model +
+
+ @Model.Model +
@for(int i = 0; i < Model.SoundSynths.Length; i++) { - if(Model.SoundSynths[i] != null) - { - if(Model.SoundSynths[i].SoundSynth.Id == -2) + + @if(Model.SoundSynths[i] != null) { - + + } + else + { + + } } else { - + } - } - else - { - - } + }
- Software - -
-
- This computer directly sends data to a DAC or similar connected to the audio output. + if(Model.SoundSynths[i].SoundSynth.Id == -2) + { +
+ Software + +
+
+ This computer directly sends data to a DAC or similar connected to the audio output. +
- -
+ @($"{Model.SoundSynths[i].SoundSynth.Name}") + +
+
+ + @if(Model.SoundSynths[i].SoundSynth.ModelCode != null && Model.SoundSynths[i].SoundSynth.ModelCode != Model.SoundSynths[i].SoundSynth.Name) + { + + + + + } + @if(Model.SoundSynths[i].SoundSynth.Company != null) + { + + + + + } + @if(Model.SoundSynths[i].SoundSynth.Introduced != DateTime.MinValue) + { + + + + + } + @if(Model.SoundSynths[i].SoundSynth.Voices != 0 || Model.SoundSynths[i].SoundSynth.SquareWave != 0 || Model.SoundSynths[i].SoundSynth.WhiteNoise != 0) + { + + + + + } + @if(Model.SoundSynths[i].SoundSynth.Depth != 0 || Model.SoundSynths[i].SoundSynth.Frequency > 0) + { + + + + + } + @if(Model.SoundSynths[i].SoundSynth.Type != 0) + { + + + + + } +
Model@Model.SoundSynths[i].SoundSynth.ModelCode
Manufacturer + + @Model.SoundSynths[i].SoundSynth.Company.Name +
Introduction date@($"{Model.Gpus[i].Gpu.Introduced:yyyy}")
Generators + + @if(Model.SoundSynths[i].SoundSynth.Voices != 0) + { + + + + } + @if(Model.SoundSynths[i].SoundSynth.SquareWave != 0) + { + + + + } + @if(Model.SoundSynths[i].SoundSynth.WhiteNoise != 0) + { + + + + } +
@Model.SoundSynths[i].SoundSynth.Voices voices
@Model.SoundSynths[i].SoundSynth.SquareWave square wave
@Model.SoundSynths[i].SoundSynth.WhiteNoise white noise
+
Sample rate + + @if(Model.SoundSynths[i].SoundSynth.Depth != 0 && Model.SoundSynths[i].SoundSynth.Frequency > 0) + { + + + + } + else if(Model.SoundSynths[i].SoundSynth.Depth != 0) + { + + + + } + else + { + + + + } +
@Model.SoundSynths[i].SoundSynth.Depth bits at @(Model.SoundSynths[i].SoundSynth.Frequency > 1000 ? $"{Model.SoundSynths[i].SoundSynth.Frequency / 1000}KHz" : $"{Model.SoundSynths[i].SoundSynth.Frequency}Hz")
@Model.SoundSynths[i].SoundSynth.Depth bits
@(Model.SoundSynths[i].SoundSynth.Frequency > 1000 ? $"{Model.SoundSynths[i].SoundSynth.Frequency / 1000}KHz" : $"{Model.SoundSynths[i].SoundSynth.Frequency}Hz")
+
Synthetizer type + @Model.SoundSynths[i].SoundSynth.Type +
+
+
+
- @($"{Model.Gpus[i].Gpu.Name}") - -
-
- - @if(Model.SoundSynths[i].SoundSynth.ModelCode != null && Model.SoundSynths[i].SoundSynth.ModelCode != Model.SoundSynths[i].SoundSynth.Name) - { - - - - - } - @if(Model.SoundSynths[i].SoundSynth.Company != null) - { - - - - - } - @if(Model.SoundSynths[i].SoundSynth.Introduced != DateTime.MinValue) - { - - - - - } - @if(Model.SoundSynths[i].SoundSynth.Voices != 0 || Model.SoundSynths[i].SoundSynth.SquareWave != 0 || Model.SoundSynths[i].SoundSynth.WhiteNoise != 0) - { - - - - - } - @if(Model.SoundSynths[i].SoundSynth.Depth != 0 || Model.SoundSynths[i].SoundSynth.Frequency > 0) - { - - - - - } - @if(Model.SoundSynths[i].SoundSynth.Type != 0) - { - - - - - } -
Model@Model.SoundSynths[i].SoundSynth.ModelCode
Manufacturer - - @Model.SoundSynths[i].SoundSynth.Company.Name -
Introduction date@($"{Model.Gpus[i].Gpu.Introduced:yyyy}")
Generators - - @if(Model.SoundSynths[i].SoundSynth.Voices != 0) - { - - - - } - @if(Model.SoundSynths[i].SoundSynth.SquareWave != 0) - { - - - - } - @if(Model.SoundSynths[i].SoundSynth.WhiteNoise != 0) - { - - - - } -
@Model.SoundSynths[i].SoundSynth.Voices voices
@Model.SoundSynths[i].SoundSynth.SquareWave square wave
@Model.SoundSynths[i].SoundSynth.WhiteNoise white noise
-
Sample rate - - @if(Model.SoundSynths[i].SoundSynth.Depth != 0 && Model.SoundSynths[i].SoundSynth.Frequency > 0) - { - - - - } - else if(Model.SoundSynths[i].SoundSynth.Depth != 0) - { - - - - } - else - { - - - - } -
@Model.SoundSynths[i].SoundSynth.Depth bits at @(Model.SoundSynths[i].SoundSynth.Frequency > 1000 ? $"{Model.SoundSynths[i].SoundSynth.Frequency / 1000}KHz" : $"{Model.SoundSynths[i].SoundSynth.Frequency}Hz")
@Model.SoundSynths[i].SoundSynth.Depth bits
@(Model.SoundSynths[i].SoundSynth.Frequency > 1000 ? $"{Model.SoundSynths[i].SoundSynth.Frequency / 1000}KHz" : $"{Model.SoundSynths[i].SoundSynth.Frequency}Hz")
-
Synthetizer type - @Model.SoundSynths[i].SoundSynth.Type -
-
-
-
Unknown dataUnknown data
diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index 543a8d03..41acd11c 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - 3.0.99.226 + 3.0.99.232 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website