From ae10cca33a0ce09d538e7dce7bda424ac9a0d8df Mon Sep 17 00:00:00 2001
From: Natalia Portillo
Date: Sun, 15 Apr 2018 17:51:07 +0100
Subject: [PATCH] Update to database version 3.
---
Cicm.Database/Cicm.Database.csproj | 3 -
Cicm.Database/IDbCore.cs | 2 +
Cicm.Database/Mysql.cs | 17 +
Cicm.Database/Operations/Admin.cs | 14 +-
Cicm.Database/Operations/BrowserTest.cs | 28 +-
Cicm.Database/Operations/Company.cs | 18 +-
Cicm.Database/Operations/Computer.cs | 30 +-
Cicm.Database/Operations/Console.cs | 40 +-
Cicm.Database/Operations/DiskFormat.cs | 18 +-
Cicm.Database/Operations/Dsp.cs | 281 ---------------
Cicm.Database/Operations/Gpu.cs | 8 +-
Cicm.Database/Operations/Init.cs | 70 ++--
Cicm.Database/Operations/MoneyDonation.cs | 16 +-
.../Operations/{Mpu.cs => MusicSynth.cs} | 92 ++---
Cicm.Database/Operations/Operations.cs | 2 +-
.../{OwnComputer.cs => OwnedComputer.cs} | 52 +--
.../{OwnConsole.cs => OwnedConsole.cs} | 52 +--
.../Operations/{Cpu.cs => Processor.cs} | 94 ++---
.../{ConsoleCompany.cs => SoundSynth.cs} | 94 ++---
Cicm.Database/Operations/Update.cs | 341 +++++++++++++++++-
Cicm.Database/Schemas/Computer.cs | 8 +-
Cicm.Database/Schemas/Console.cs | 12 +-
Cicm.Database/Schemas/ConsoleCompany.cs | 43 ---
.../Schemas/{Mpu.cs => MusicSynth.cs} | 8 +-
.../{OwnComputer.cs => OwnedComputer.cs} | 2 +-
.../{OwnConsole.cs => OwnedConsole.cs} | 2 +-
.../Schemas/{Cpu.cs => Processor.cs} | 8 +-
.../Schemas/{Dsp.cs => SoundSynth.cs} | 8 +-
Cicm.Database/Schemas/Sql/V3.cs | 231 ++++++++++++
cicm_web/Controllers/CompanyController.cs | 13 +-
.../Controllers/ConsoleCompanyController.cs | 72 ----
cicm_web/Models/Company.cs | 44 +++
cicm_web/Models/Computer.cs | 48 ++-
cicm_web/Models/Console.cs | 112 +++---
cicm_web/Models/ConsoleCompany.cs | 69 ----
cicm_web/Models/{Dsp.cs => MusicSynth.cs} | 24 +-
cicm_web/Models/News.cs | 34 +-
.../{OwnComputer.cs => OwnedComputer.cs} | 29 +-
.../Models/{OwnConsole.cs => OwnedConsole.cs} | 21 +-
cicm_web/Models/{Cpu.cs => Processor.cs} | 24 +-
cicm_web/Models/{Mpu.cs => SoundSynth.cs} | 24 +-
cicm_web/Views/Company/ByLetter.cshtml | 12 +-
cicm_web/Views/Company/View.cshtml | 71 ++--
cicm_web/Views/Computer/View.cshtml | 28 +-
cicm_web/Views/Console/ByLetter.cshtml | 24 +-
cicm_web/Views/Console/ByYear.cshtml | 2 +-
cicm_web/Views/Console/Index.cshtml | 54 +--
cicm_web/Views/Console/View.cshtml | 30 +-
cicm_web/Views/ConsoleCompany/ByLetter.cshtml | 81 -----
cicm_web/Views/ConsoleCompany/View.cshtml | 80 ----
cicm_web/cicm_web.csproj | 2 +-
51 files changed, 1278 insertions(+), 1214 deletions(-)
delete mode 100644 Cicm.Database/Operations/Dsp.cs
rename Cicm.Database/Operations/{Mpu.cs => MusicSynth.cs} (67%)
rename Cicm.Database/Operations/{OwnComputer.cs => OwnedComputer.cs} (87%)
rename Cicm.Database/Operations/{OwnConsole.cs => OwnedConsole.cs} (84%)
rename Cicm.Database/Operations/{Cpu.cs => Processor.cs} (68%)
rename Cicm.Database/Operations/{ConsoleCompany.cs => SoundSynth.cs} (66%)
delete mode 100644 Cicm.Database/Schemas/ConsoleCompany.cs
rename Cicm.Database/Schemas/{Mpu.cs => MusicSynth.cs} (90%)
rename Cicm.Database/Schemas/{OwnComputer.cs => OwnedComputer.cs} (98%)
rename Cicm.Database/Schemas/{OwnConsole.cs => OwnedConsole.cs} (98%)
rename Cicm.Database/Schemas/{Cpu.cs => Processor.cs} (89%)
rename Cicm.Database/Schemas/{Dsp.cs => SoundSynth.cs} (89%)
create mode 100644 Cicm.Database/Schemas/Sql/V3.cs
delete mode 100644 cicm_web/Controllers/ConsoleCompanyController.cs
delete mode 100644 cicm_web/Models/ConsoleCompany.cs
rename cicm_web/Models/{Dsp.cs => MusicSynth.cs} (67%)
rename cicm_web/Models/{OwnComputer.cs => OwnedComputer.cs} (81%)
rename cicm_web/Models/{OwnConsole.cs => OwnedConsole.cs} (81%)
rename cicm_web/Models/{Cpu.cs => Processor.cs} (68%)
rename cicm_web/Models/{Mpu.cs => SoundSynth.cs} (67%)
delete mode 100644 cicm_web/Views/ConsoleCompany/ByLetter.cshtml
delete mode 100644 cicm_web/Views/ConsoleCompany/View.cshtml
diff --git a/Cicm.Database/Cicm.Database.csproj b/Cicm.Database/Cicm.Database.csproj
index 7102c44a..74412869 100644
--- a/Cicm.Database/Cicm.Database.csproj
+++ b/Cicm.Database/Cicm.Database.csproj
@@ -5,7 +5,4 @@
-
-
-
\ No newline at end of file
diff --git a/Cicm.Database/IDbCore.cs b/Cicm.Database/IDbCore.cs
index 3bbc36a4..b91ebbaf 100644
--- a/Cicm.Database/IDbCore.cs
+++ b/Cicm.Database/IDbCore.cs
@@ -73,5 +73,7 @@ namespace Cicm.Database
///
/// Data adapter
IDbDataAdapter GetNewDataAdapter();
+
+ bool TableExists(string tableName);
}
}
\ No newline at end of file
diff --git a/Cicm.Database/Mysql.cs b/Cicm.Database/Mysql.cs
index cb6e458e..c2a16d04 100644
--- a/Cicm.Database/Mysql.cs
+++ b/Cicm.Database/Mysql.cs
@@ -75,6 +75,7 @@ namespace Cicm.Database
$"server={server};user={user};database={database};port={port};password={password}";
connection = new MySqlConnection(connectionString);
+ connection.Open();
Operations = new Operations(connection, this);
@@ -120,6 +121,7 @@ namespace Cicm.Database
$"server={server};user={user};database={database};port={port};password={password}";
connection = new MySqlConnection(connectionString);
+ connection.Open();
IDbCommand command = connection.CreateCommand();
command.CommandText = $"CREATE DATABASE `{database}`;";
@@ -154,6 +156,21 @@ namespace Cicm.Database
return new MySqlDataAdapter();
}
+ public bool TableExists(string tableName)
+ {
+ MySqlCommand cmd = connection.CreateCommand();
+ cmd.CommandText =
+ $"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{connection.Database}' AND table_name = '{tableName}'";
+
+ MySqlDataReader reader = cmd.ExecuteReader();
+
+ reader.Read();
+
+ int count = reader.GetInt32(0);
+ reader.Close();
+ return count > 0;
+ }
+
~Mysql()
{
CloseDb();
diff --git a/Cicm.Database/Operations/Admin.cs b/Cicm.Database/Operations/Admin.cs
index d2db374d..a8702647 100644
--- a/Cicm.Database/Operations/Admin.cs
+++ b/Cicm.Database/Operations/Admin.cs
@@ -51,7 +51,7 @@ namespace Cicm.Database
try
{
- const string SQL = "SELECT * from admin";
+ const string SQL = "SELECT * from admins";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -88,7 +88,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * FROM admin LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM admins LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -123,7 +123,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * from admin WHERE id = '{id}'";
+ string sql = $"SELECT * from admins WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -155,7 +155,7 @@ namespace Cicm.Database
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM admin";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM admins";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -178,7 +178,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO admin (user, password)" + " VALUES (@user, @password)";
+ const string SQL = "INSERT INTO admins (user, password)" + " VALUES (@user, @password)";
dbcmd.CommandText = SQL;
@@ -210,7 +210,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = "UPDATE admin SET user = @user, password = @password " + $"WHERE id = {entry.Id}";
+ string sql = "UPDATE admins SET user = @user, password = @password " + $"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -236,7 +236,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = $"DELETE FROM admin WHERE id = '{id}';";
+ string sql = $"DELETE FROM admins WHERE id = '{id}';";
dbcmd.CommandText = sql;
diff --git a/Cicm.Database/Operations/BrowserTest.cs b/Cicm.Database/Operations/BrowserTest.cs
index 133f8684..f546bb19 100644
--- a/Cicm.Database/Operations/BrowserTest.cs
+++ b/Cicm.Database/Operations/BrowserTest.cs
@@ -179,8 +179,8 @@ namespace Cicm.Database
dbcmd.Transaction = trans;
const string SQL =
- "INSERT INTO browser_test (idstring, browser, version, os, platform, gif87, gif89, jpeg, png, pngt, agif, table, colors, js, frames, flash)" +
- " VALUES (@idstring, @browser, @version, @os, @platform, @gif87, @gif89, @jpeg, @png, @pngt, @agif, @table, @colors, @js, @frames, @flash)";
+ "INSERT INTO browser_test (user_agent, browser, version, os, platform, gif87, gif89, jpeg, png, pngt, agif, table, colors, js, frames, flash)" +
+ " VALUES (@user_agent, @browser, @version, @os, @platform, @gif87, @gif89, @jpeg, @png, @pngt, @agif, @table, @colors, @js, @frames, @flash)";
dbcmd.CommandText = SQL;
@@ -213,7 +213,7 @@ namespace Cicm.Database
dbcmd.Transaction = trans;
string sql =
- "UPDATE browser_test SET idstring = @idstring, browser = @browser, version = @version, os = @os, platform = @platform, gif87 = @gif87, " +
+ "UPDATE browser_test SET user_agent = @user_agent, browser = @browser, version = @version, os = @os, platform = @platform, gif87 = @gif87, " +
"gif89 = @gif89, jpeg = @jpeg, png = @png, pngt = @pngt, agif = @agif, table = @table, colors = @colors, js = @js, frames = @frames, flash = @flash " +
$"WHERE id = {entry.Id}";
@@ -273,7 +273,7 @@ namespace Cicm.Database
IDbDataParameter param15 = dbcmd.CreateParameter();
IDbDataParameter param16 = dbcmd.CreateParameter();
- param1.ParameterName = "@idstring";
+ param1.ParameterName = "@user_agent";
param2.ParameterName = "@browser";
param3.ParameterName = "@version";
param4.ParameterName = "@os";
@@ -353,22 +353,22 @@ namespace Cicm.Database
BrowserTest entry = new BrowserTest
{
Id = ushort.Parse(dataRow["id"].ToString()),
- UserAgent = dataRow["idstring"].ToString(),
+ UserAgent = dataRow["user_agent"].ToString(),
Name = dataRow["browser"].ToString(),
Version = dataRow["version"].ToString(),
OperatingSystem = dataRow["os"].ToString(),
Architecture = dataRow["platform"].ToString(),
- Gif87 = int.Parse(dataRow["gif87"].ToString()) > 0,
- Gif89 = int.Parse(dataRow["gif89"].ToString()) > 0,
- Jpeg = int.Parse(dataRow["jpeg"].ToString()) > 0,
- Png = int.Parse(dataRow["png"].ToString()) > 0,
- AlphaPng = int.Parse(dataRow["pngt"].ToString()) > 0,
- AnimatedGif = int.Parse(dataRow["agif"].ToString()) > 0,
- Tables = int.Parse(dataRow["table"].ToString()) > 0,
+ Gif87 = int.Parse(dataRow["gif87"].ToString()) > 0,
+ Gif89 = int.Parse(dataRow["gif89"].ToString()) > 0,
+ Jpeg = int.Parse(dataRow["jpeg"].ToString()) > 0,
+ Png = int.Parse(dataRow["png"].ToString()) > 0,
+ AlphaPng = int.Parse(dataRow["pngt"].ToString()) > 0,
+ AnimatedGif = int.Parse(dataRow["agif"].ToString()) > 0,
+ Tables = int.Parse(dataRow["table"].ToString()) > 0,
Color = int.Parse(dataRow["colors"].ToString()) > 0,
- Js = int.Parse(dataRow["js"].ToString()) > 0,
+ Js = int.Parse(dataRow["js"].ToString()) > 0,
Frames = int.Parse(dataRow["frames"].ToString()) > 0,
- Flash = int.Parse(dataRow["flash"].ToString()) > 0
+ Flash = int.Parse(dataRow["flash"].ToString()) > 0
};
entries.Add(entry);
diff --git a/Cicm.Database/Operations/Company.cs b/Cicm.Database/Operations/Company.cs
index bbf70a3b..a5358d32 100644
--- a/Cicm.Database/Operations/Company.cs
+++ b/Cicm.Database/Operations/Company.cs
@@ -51,7 +51,7 @@ namespace Cicm.Database
try
{
- const string SQL = "SELECT * from Companias";
+ const string SQL = "SELECT * from companies";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -88,7 +88,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * FROM Companias LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM companies LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -123,7 +123,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * from Companias WHERE id = '{id}'";
+ string sql = $"SELECT * from companies WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -155,7 +155,7 @@ namespace Cicm.Database
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM Companias";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM companies";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -178,7 +178,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO Companias (Compania)" + " VALUES (@Compania)";
+ const string SQL = "INSERT INTO companies (name)" + " VALUES (@name)";
dbcmd.CommandText = SQL;
@@ -210,7 +210,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = "UPDATE Companias SET Compania = @Compania " + $"WHERE id = {entry.Id}";
+ string sql = "UPDATE companies SET name = @name " + $"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -236,7 +236,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = $"DELETE FROM Companias WHERE id = '{id}';";
+ string sql = $"DELETE FROM companies WHERE id = '{id}';";
dbcmd.CommandText = sql;
@@ -253,7 +253,7 @@ namespace Cicm.Database
IDbDataParameter param1 = dbcmd.CreateParameter();
- param1.ParameterName = "@Compania";
+ param1.ParameterName = "@name";
param1.DbType = DbType.String;
@@ -273,7 +273,7 @@ namespace Cicm.Database
Company entry = new Company
{
Id = int.Parse(dataRow["id"].ToString()),
- Name = dataRow["Compania"].ToString()
+ Name = dataRow["name"].ToString()
};
entries.Add(entry);
diff --git a/Cicm.Database/Operations/Computer.cs b/Cicm.Database/Operations/Computer.cs
index d74476ee..99121a51 100644
--- a/Cicm.Database/Operations/Computer.cs
+++ b/Cicm.Database/Operations/Computer.cs
@@ -215,8 +215,8 @@ namespace Cicm.Database
dbcmd.Transaction = trans;
const string SQL =
- "INSERT INTO computers (company, year, model, cpu1, mhz1, cpu2, mhz2, bits, ram, rom, gpu, vram, colors, res, spu, mpu, sound_channels, music_channels, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2, comment)" +
- " VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @bits, @ram, @rom, @gpu, @vram, @colors, @res, @spu, @mpu, @sound_channels, @music_channels, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2, @comment)";
+ "INSERT INTO computers (company, year, model, cpu1, mhz1, cpu2, mhz2, bits, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, sound_channels, music_channels, hdd1, hdd2, hdd3, disk1, cap1, disk2, cap2)" +
+ " VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @bits, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, @sound_channels, @music_channels, @hdd1, @hdd2, @hdd3, @disk1, @cap1, @disk2, @cap2)";
dbcmd.CommandText = SQL;
@@ -249,9 +249,9 @@ namespace Cicm.Database
dbcmd.Transaction = trans;
string sql =
- "UPDATE computers SET company = @company, year = @year, model = @model, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " +
- "mhz2 = @mhz2, bits = @bits, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, spu = @spu, mpu = @mpu " +
- "sound_channels = @sound_channels, music_channels = @music_channels, hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2, comment = @comment " +
+ "UPDATE computers SET company = @company, year = @year, model = @model, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " +
+ "mhz2 = @mhz2, bits = @bits, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, sound_synth = @sound_synth, music_synth = @music_synth " +
+ "sound_channels = @sound_channels, music_channels = @music_channels, hdd1 = @hdd1, hdd2 = @hdd2, hdd3 = @hdd3, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2 " +
$"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -318,7 +318,6 @@ namespace Cicm.Database
IDbDataParameter param23 = dbcmd.CreateParameter();
IDbDataParameter param24 = dbcmd.CreateParameter();
IDbDataParameter param25 = dbcmd.CreateParameter();
- IDbDataParameter param26 = dbcmd.CreateParameter();
param1.ParameterName = "@company";
param2.ParameterName = "@year";
@@ -334,8 +333,8 @@ namespace Cicm.Database
param12.ParameterName = "@vram";
param13.ParameterName = "@colors";
param14.ParameterName = "@res";
- param15.ParameterName = "@spu";
- param16.ParameterName = "@mpu";
+ param15.ParameterName = "@sound_synth";
+ param16.ParameterName = "@music_synth";
param17.ParameterName = "@sound_channels";
param18.ParameterName = "@music_channels";
param19.ParameterName = "@hdd1";
@@ -345,7 +344,6 @@ namespace Cicm.Database
param23.ParameterName = "@cap1";
param24.ParameterName = "@disk2";
param25.ParameterName = "@cap2";
- param26.ParameterName = "@comment";
param1.DbType = DbType.Int32;
param2.DbType = DbType.Int32;
@@ -372,7 +370,6 @@ namespace Cicm.Database
param23.DbType = DbType.String;
param24.DbType = DbType.Int32;
param25.DbType = DbType.String;
- param26.DbType = DbType.String;
param1.Value = entry.Company;
param2.Value = entry.Year;
@@ -388,8 +385,8 @@ namespace Cicm.Database
param12.Value = entry.Vram;
param13.Value = entry.Colors;
param14.Value = entry.Resolution;
- param15.Value = entry.Spu;
- param16.Value = entry.Mpu;
+ param15.Value = entry.SoundSynth;
+ param16.Value = entry.MusicSynth;
param17.Value = entry.SoundChannels;
param18.Value = entry.MusicChannels;
param19.Value = entry.Hdd1;
@@ -399,7 +396,6 @@ namespace Cicm.Database
param23.Value = entry.Cap1;
param24.Value = entry.Disk2;
param25.Value = entry.Cap2;
- param26.Value = entry.Comment;
dbcmd.Parameters.Add(param1);
dbcmd.Parameters.Add(param2);
@@ -426,7 +422,6 @@ namespace Cicm.Database
dbcmd.Parameters.Add(param23);
dbcmd.Parameters.Add(param24);
dbcmd.Parameters.Add(param25);
- dbcmd.Parameters.Add(param26);
return dbcmd;
}
@@ -457,8 +452,8 @@ namespace Cicm.Database
Vram = int.Parse(dataRow["vram"].ToString()),
Colors = int.Parse(dataRow["colors"].ToString()),
Resolution = dataRow["res"].ToString(),
- Spu = int.Parse(dataRow["spu"].ToString()),
- Mpu = int.Parse(dataRow["mpu"].ToString()),
+ SoundSynth = int.Parse(dataRow["sound_synth"].ToString()),
+ MusicSynth = int.Parse(dataRow["music_synth"].ToString()),
SoundChannels = int.Parse(dataRow["sound_channels"].ToString()),
MusicChannels = int.Parse(dataRow["music_channels"].ToString()),
Hdd1 = int.Parse(dataRow["hdd1"].ToString()),
@@ -473,8 +468,7 @@ namespace Cicm.Database
Disk2 = string.IsNullOrEmpty(dataRow["disk2"].ToString())
? 0
: int.Parse(dataRow["disk2"].ToString()),
- Cap2 = dataRow["cap2"].ToString(),
- Comment = dataRow["comment"].ToString()
+ Cap2 = dataRow["cap2"].ToString()
};
entries.Add(entry);
diff --git a/Cicm.Database/Operations/Console.cs b/Cicm.Database/Operations/Console.cs
index 6757adca..789f2564 100644
--- a/Cicm.Database/Operations/Console.cs
+++ b/Cicm.Database/Operations/Console.cs
@@ -206,7 +206,7 @@ namespace Cicm.Database
public bool AddConsole(Console entry, out long id)
{
#if DEBUG
- System.Console.Write("Adding console `{0}`...", entry.Name);
+ System.Console.Write("Adding console `{0}`...", entry.Model);
#endif
IDbCommand dbcmd = GetCommandConsole(entry);
@@ -214,8 +214,8 @@ namespace Cicm.Database
dbcmd.Transaction = trans;
const string SQL =
- "INSERT INTO consoles (company, year, name, cpu1, mhz1, cpu2, mhz2, bits, ram, rom, gpu, vram, colors, res, spu, mpu, schannels, mchannels, palette, format, cap, comments)" +
- " VALUES (@company, @year, @name, @cpu1, @mhz1, @cpu2, @mhz2, @bits, @ram, @rom, @gpu, @vram, @colors, @res, @spu, @mpu, @schannels, @mchannels, @palette, @format, @cap, @comments)";
+ "INSERT INTO consoles (company, year, model, cpu1, mhz1, cpu2, mhz2, bits, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, schannels, mchannels, palette, format, cap)" +
+ " VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @bits, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, @schannels, @mchannels, @palette, @format, @cap)";
dbcmd.CommandText = SQL;
@@ -240,7 +240,7 @@ namespace Cicm.Database
public bool UpdateConsole(Console entry)
{
#if DEBUG
- System.Console.WriteLine("Updating console `{0}`...", entry.Name);
+ System.Console.WriteLine("Updating console `{0}`...", entry.Model);
#endif
IDbCommand dbcmd = GetCommandConsole(entry);
@@ -248,9 +248,9 @@ namespace Cicm.Database
dbcmd.Transaction = trans;
string sql =
- "UPDATE consoles SET company = @company, year = @year, name = @name, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " +
- "mhz2 = @mhz2, bits = @bits, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, spu = @spu, mpu = @mpu " +
- "schannels = @schannels, mchannels = @mchannels, palette = @palette, format = @format, cap = @cap, comments = @comments " +
+ "UPDATE consoles SET company = @company, year = @year, model = @model, cpu1 = @cpu1, mhz1 = @mhz1, cpu2 = @cpu2, " +
+ "mhz2 = @mhz2, bits = @bits, ram = @ram, rom = @rom, gpu = @gpu, vram = @vram, colors = @colors, res = @res, sound_synth = @sound_synth, music_synth = @music_synth " +
+ "schannels = @schannels, mchannels = @mchannels, palette = @palette, format = @format, cap = @cap " +
$"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -313,11 +313,10 @@ namespace Cicm.Database
IDbDataParameter param19 = dbcmd.CreateParameter();
IDbDataParameter param20 = dbcmd.CreateParameter();
IDbDataParameter param21 = dbcmd.CreateParameter();
- IDbDataParameter param22 = dbcmd.CreateParameter();
param1.ParameterName = "@company";
param2.ParameterName = "@year";
- param3.ParameterName = "@name";
+ param3.ParameterName = "@model";
param4.ParameterName = "@cpu1";
param5.ParameterName = "@mhz1";
param6.ParameterName = "@cpu2";
@@ -329,14 +328,13 @@ namespace Cicm.Database
param12.ParameterName = "@vram";
param13.ParameterName = "@colors";
param14.ParameterName = "@res";
- param15.ParameterName = "@spu";
- param16.ParameterName = "@mpu";
+ param15.ParameterName = "@sound_synth";
+ param16.ParameterName = "@music_synth";
param17.ParameterName = "@schannels";
param18.ParameterName = "@mchannels";
param19.ParameterName = "@palette";
param20.ParameterName = "@format";
param21.ParameterName = "@cap";
- param22.ParameterName = "@comments";
param1.DbType = DbType.Int32;
param2.DbType = DbType.Int32;
@@ -359,11 +357,10 @@ namespace Cicm.Database
param19.DbType = DbType.Int32;
param20.DbType = DbType.Int32;
param21.DbType = DbType.Int32;
- param22.DbType = DbType.String;
param1.Value = entry.Company;
param2.Value = entry.Year;
- param3.Value = entry.Name;
+ param3.Value = entry.Model;
param4.Value = entry.Cpu1;
param5.Value = entry.Mhz1;
param6.Value = entry.Cpu2;
@@ -375,14 +372,13 @@ namespace Cicm.Database
param12.Value = entry.Vram;
param13.Value = entry.Colors;
param14.Value = entry.Resolution;
- param15.Value = entry.Spu;
- param16.Value = entry.Mpu;
+ param15.Value = entry.SoundSynth;
+ param16.Value = entry.MusicSynth;
param17.Value = entry.SoundChannels;
param18.Value = entry.MusicChannels;
param19.Value = entry.Palette;
param20.Value = entry.Format;
param21.Value = entry.Cap;
- param22.Value = entry.Comments;
dbcmd.Parameters.Add(param1);
dbcmd.Parameters.Add(param2);
@@ -405,7 +401,6 @@ namespace Cicm.Database
dbcmd.Parameters.Add(param19);
dbcmd.Parameters.Add(param20);
dbcmd.Parameters.Add(param21);
- dbcmd.Parameters.Add(param22);
return dbcmd;
}
@@ -421,7 +416,7 @@ namespace Cicm.Database
Id = int.Parse(dataRow["id"].ToString()),
Company = int.Parse(dataRow["company"].ToString()),
Year = int.Parse(dataRow["year"].ToString()),
- Name = dataRow["name"].ToString(),
+ Model = dataRow["model"].ToString(),
Cpu1 = int.Parse(dataRow["cpu1"].ToString()),
Mhz1 = float.Parse(dataRow["mhz1"].ToString()),
Cpu2 = string.IsNullOrEmpty(dataRow["cpu2"].ToString())
@@ -436,14 +431,13 @@ namespace Cicm.Database
Vram = int.Parse(dataRow["vram"].ToString()),
Colors = int.Parse(dataRow["colors"].ToString()),
Resolution = dataRow["res"].ToString(),
- Spu = int.Parse(dataRow["spu"].ToString()),
- Mpu = int.Parse(dataRow["mpu"].ToString()),
+ SoundSynth = int.Parse(dataRow["sound_synth"].ToString()),
+ MusicSynth = int.Parse(dataRow["music_synth"].ToString()),
SoundChannels = int.Parse(dataRow["schannels"].ToString()),
MusicChannels = int.Parse(dataRow["mchannels"].ToString()),
Palette = int.Parse(dataRow["palette"].ToString()),
Format = int.Parse(dataRow["format"].ToString()),
- Cap = int.Parse(dataRow["cap"].ToString()),
- Comments = dataRow["comments"].ToString()
+ Cap = int.Parse(dataRow["cap"].ToString())
};
entries.Add(entry);
diff --git a/Cicm.Database/Operations/DiskFormat.cs b/Cicm.Database/Operations/DiskFormat.cs
index 4502e64f..24c92ec5 100644
--- a/Cicm.Database/Operations/DiskFormat.cs
+++ b/Cicm.Database/Operations/DiskFormat.cs
@@ -51,7 +51,7 @@ namespace Cicm.Database
try
{
- const string SQL = "SELECT * from Formatos_de_disco";
+ const string SQL = "SELECT * from disk_formats";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -88,7 +88,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * FROM Formatos_de_disco LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM disk_formats LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -123,7 +123,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * from Formatos_de_disco WHERE id = '{id}'";
+ string sql = $"SELECT * from disk_formats WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -155,7 +155,7 @@ namespace Cicm.Database
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM Formatos_de_disco";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM disk_formats";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -178,7 +178,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO Formatos_de_disco (Format)" + " VALUES (@Format)";
+ const string SQL = "INSERT INTO disk_formats (description)" + " VALUES (@description)";
dbcmd.CommandText = SQL;
@@ -210,7 +210,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = "UPDATE Formatos_de_disco SET Format = @Format " + $"WHERE id = {entry.Id}";
+ string sql = "UPDATE disk_formats SET description = @description " + $"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -236,7 +236,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = $"DELETE FROM Formatos_de_disco WHERE id = '{id}';";
+ string sql = $"DELETE FROM disk_formats WHERE id = '{id}';";
dbcmd.CommandText = sql;
@@ -253,7 +253,7 @@ namespace Cicm.Database
IDbDataParameter param1 = dbcmd.CreateParameter();
- param1.ParameterName = "@Format";
+ param1.ParameterName = "@description";
param1.DbType = DbType.String;
@@ -273,7 +273,7 @@ namespace Cicm.Database
DiskFormat entry = new DiskFormat
{
Id = int.Parse(dataRow["id"].ToString()),
- Description = dataRow["Format"].ToString()
+ Description = dataRow["description"].ToString()
};
entries.Add(entry);
diff --git a/Cicm.Database/Operations/Dsp.cs b/Cicm.Database/Operations/Dsp.cs
deleted file mode 100644
index e2baef70..00000000
--- a/Cicm.Database/Operations/Dsp.cs
+++ /dev/null
@@ -1,281 +0,0 @@
-/******************************************************************************
-// Canary Islands Computer Museum Website
-// ----------------------------------------------------------------------------
-//
-// Filename : Dsp.cs
-// Author(s) : Natalia Portillo
-//
-// --[ Description ] ----------------------------------------------------------
-//
-// Contains operations to manage DSPs.
-//
-// --[ 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 DSPs
- ///
- /// All DSPs
- /// true if is correct, false otherwise
- public bool GetDsps(out List entries)
- {
- #if DEBUG
- Console.WriteLine("Getting all DSPs...");
- #endif
-
- try
- {
- const string SQL = "SELECT * from DSPs";
-
- IDbCommand dbCmd = dbCon.CreateCommand();
- IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
- dbCmd.CommandText = SQL;
- DataSet dataSet = new DataSet();
- dataAdapter.SelectCommand = dbCmd;
- dataAdapter.Fill(dataSet);
-
- entries = DspsFromDataTable(dataSet.Tables[0]);
-
- return true;
- }
- catch(Exception ex)
- {
- Console.WriteLine("Error getting DSPs.");
- Console.WriteLine(ex);
- entries = null;
- return false;
- }
- }
-
- ///
- /// Gets the specified number of DSPs since the specified start
- ///
- /// List of DSPs
- /// Start of query
- /// How many entries to retrieve
- /// true if is correct, false otherwise
- public bool GetDsps(out List entries, ulong start, ulong count)
- {
- #if DEBUG
- Console.WriteLine("Getting {0} DSPs from {1}...", count, start);
- #endif
-
- try
- {
- string sql = $"SELECT * FROM DSPs 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 = DspsFromDataTable(dataSet.Tables[0]);
-
- return true;
- }
- catch(Exception ex)
- {
- Console.WriteLine("Error getting DSPs.");
- Console.WriteLine(ex);
- entries = null;
- return false;
- }
- }
-
- ///
- /// Gets DSP by specified id
- ///
- /// Id
- /// DSP with specified id, null if not found or error
- public Dsp GetDsp(int id)
- {
- #if DEBUG
- Console.WriteLine("Getting DSP with id {0}...", id);
- #endif
-
- try
- {
- string sql = $"SELECT * from DSPs 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 = DspsFromDataTable(dataSet.Tables[0]);
-
- return entries == null || entries.Count == 0 ? null : entries[0];
- }
- catch(Exception ex)
- {
- Console.WriteLine("Error getting DSP.");
- Console.WriteLine(ex);
- return null;
- }
- }
-
- ///
- /// Counts the number of DSPs in the database
- ///
- /// Entries in database
- public long CountDsps()
- {
- #if DEBUG
- Console.WriteLine("Counting DSPs...");
- #endif
-
- IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM DSPs";
- object count = dbcmd.ExecuteScalar();
- dbcmd.Dispose();
- try { return Convert.ToInt64(count); }
- catch { return 0; }
- }
-
- ///
- /// Adds a new DSP to the database
- ///
- /// Entry to add
- /// ID of added entry
- /// true if added correctly, false otherwise
- public bool AddDsp(Dsp entry, out long id)
- {
- #if DEBUG
- Console.Write("Adding DSP `{0}`...", entry.Name);
- #endif
-
- IDbCommand dbcmd = GetCommandDsp(entry);
- IDbTransaction trans = dbCon.BeginTransaction();
- dbcmd.Transaction = trans;
-
- const string SQL = "INSERT INTO DSPs (DSP)" + " VALUES (@DSP)";
-
- dbcmd.CommandText = SQL;
-
- dbcmd.ExecuteNonQuery();
- trans.Commit();
- dbcmd.Dispose();
-
- id = dbCore.LastInsertRowId;
-
- #if DEBUG
- Console.WriteLine(" id {0}", id);
- #endif
-
- return true;
- }
-
- ///
- /// Updated a DSP in the database
- ///
- /// Updated entry
- /// true if updated correctly, false otherwise
- public bool UpdateDsp(Dsp entry)
- {
- #if DEBUG
- Console.WriteLine("Updating DSP `{0}`...", entry.Name);
- #endif
-
- IDbCommand dbcmd = GetCommandDsp(entry);
- IDbTransaction trans = dbCon.BeginTransaction();
- dbcmd.Transaction = trans;
-
- string sql = "UPDATE DSPs SET DSP = @DSP " + $"WHERE id = {entry.Id}";
-
- dbcmd.CommandText = sql;
-
- dbcmd.ExecuteNonQuery();
- trans.Commit();
- dbcmd.Dispose();
-
- return true;
- }
-
- ///
- /// Removes a DSP from the database
- ///
- /// ID of entry to remove
- /// true if removed correctly, false otherwise
- public bool RemoveDsp(long id)
- {
- #if DEBUG
- Console.WriteLine("Removing DSP widh id `{0}`...", id);
- #endif
-
- IDbCommand dbcmd = dbCon.CreateCommand();
- IDbTransaction trans = dbCon.BeginTransaction();
- dbcmd.Transaction = trans;
-
- string sql = $"DELETE FROM DSPs WHERE id = '{id}';";
-
- dbcmd.CommandText = sql;
-
- dbcmd.ExecuteNonQuery();
- trans.Commit();
- dbcmd.Dispose();
-
- return true;
- }
-
- IDbCommand GetCommandDsp(Dsp entry)
- {
- IDbCommand dbcmd = dbCon.CreateCommand();
-
- IDbDataParameter param1 = dbcmd.CreateParameter();
-
- param1.ParameterName = "@DSP";
-
- param1.DbType = DbType.String;
-
- param1.Value = entry.Name;
-
- dbcmd.Parameters.Add(param1);
-
- return dbcmd;
- }
-
- static List DspsFromDataTable(DataTable dataTable)
- {
- List entries = new List();
-
- foreach(DataRow dataRow in dataTable.Rows)
- {
- Dsp entry = new Dsp {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["DSP"].ToString()};
-
- entries.Add(entry);
- }
-
- return entries;
- }
- }
-}
\ No newline at end of file
diff --git a/Cicm.Database/Operations/Gpu.cs b/Cicm.Database/Operations/Gpu.cs
index 55466481..6264372e 100644
--- a/Cicm.Database/Operations/Gpu.cs
+++ b/Cicm.Database/Operations/Gpu.cs
@@ -178,7 +178,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO gpus (GPU)" + " VALUES (@GPU)";
+ const string SQL = "INSERT INTO gpus (name)" + " VALUES (@name)";
dbcmd.CommandText = SQL;
@@ -210,7 +210,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = "UPDATE gpus SET GPU = @GPU " + $"WHERE id = {entry.Id}";
+ string sql = "UPDATE gpus SET name = @name " + $"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -253,7 +253,7 @@ namespace Cicm.Database
IDbDataParameter param1 = dbcmd.CreateParameter();
- param1.ParameterName = "@GPU";
+ param1.ParameterName = "@name";
param1.DbType = DbType.String;
@@ -270,7 +270,7 @@ namespace Cicm.Database
foreach(DataRow dataRow in dataTable.Rows)
{
- Gpu entry = new Gpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["GPU"].ToString()};
+ Gpu entry = new Gpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["name"].ToString()};
entries.Add(entry);
}
diff --git a/Cicm.Database/Operations/Init.cs b/Cicm.Database/Operations/Init.cs
index 2bf8ffed..b41dcbea 100644
--- a/Cicm.Database/Operations/Init.cs
+++ b/Cicm.Database/Operations/Init.cs
@@ -49,79 +49,71 @@ namespace Cicm.Database
IDbCommand dbCmd = dbCon.CreateCommand();
Console.WriteLine("Creating table `admins`");
- dbCmd.CommandText = V2.Admins;
+ dbCmd.CommandText = V3.Admins;
dbCmd.ExecuteNonQuery();
- Console.WriteLine("Creating table `browser_test`");
- dbCmd.CommandText = V2.BrowserTests;
+ Console.WriteLine("Creating table `browser_tests`");
+ dbCmd.CommandText = V3.BrowserTests;
dbCmd.ExecuteNonQuery();
- Console.WriteLine("Creating table `Companias`");
- dbCmd.CommandText = V2.Companies;
+ Console.WriteLine("Creating table `cicm_db`");
+ dbCmd.CommandText = V3.CicmDb;
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Creating table `companies`");
+ dbCmd.CommandText = V3.Companies;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `computers`");
- dbCmd.CommandText = V2.Computers;
+ dbCmd.CommandText = V3.Computers;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `consoles`");
- dbCmd.CommandText = V2.Consoles;
+ dbCmd.CommandText = V3.Consoles;
dbCmd.ExecuteNonQuery();
- Console.WriteLine("Creating table `console_company`");
- dbCmd.CommandText = V2.ConsoleCompanies;
- dbCmd.ExecuteNonQuery();
-
- Console.WriteLine("Creating table `cpu`");
- dbCmd.CommandText = V2.Cpus;
- dbCmd.ExecuteNonQuery();
-
- Console.WriteLine("Creating table `admins`");
- dbCmd.CommandText = V2.Admins;
- dbCmd.ExecuteNonQuery();
-
- Console.WriteLine("Creating table `DSPs`");
- dbCmd.CommandText = V2.Dsps;
+ Console.WriteLine("Creating table `disk_formats`");
+ dbCmd.CommandText = V3.DiskFormats;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `forbidden`");
- dbCmd.CommandText = V2.Forbidden;
- dbCmd.ExecuteNonQuery();
-
- Console.WriteLine("Creating table `Formatos_de_disco`");
- dbCmd.CommandText = V2.DiskFormats;
+ dbCmd.CommandText = V3.Forbidden;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `gpus`");
- dbCmd.CommandText = V2.Gpus;
+ dbCmd.CommandText = V3.Gpus;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `log`");
- dbCmd.CommandText = V2.Logs;
+ dbCmd.CommandText = V3.Logs;
dbCmd.ExecuteNonQuery();
- Console.WriteLine("Creating table `money_donation`");
- dbCmd.CommandText = V2.MoneyDonations;
+ Console.WriteLine("Creating table `money_donations`");
+ dbCmd.CommandText = V3.MoneyDonations;
dbCmd.ExecuteNonQuery();
- Console.WriteLine("Creating table `mpus`");
- dbCmd.CommandText = V2.Mpus;
+ Console.WriteLine("Creating table `music_synths`");
+ dbCmd.CommandText = V3.MusicSynths;
dbCmd.ExecuteNonQuery();
Console.WriteLine("Creating table `news`");
- dbCmd.CommandText = V2.News;
+ dbCmd.CommandText = V3.News;
dbCmd.ExecuteNonQuery();
- Console.WriteLine("Creating table `own_computer`");
- dbCmd.CommandText = V2.OwnComputers;
+ Console.WriteLine("Creating table `owned_computers`");
+ dbCmd.CommandText = V3.OwnedComputers;
dbCmd.ExecuteNonQuery();
- Console.WriteLine("Creating table `own_consoles`");
- dbCmd.CommandText = V2.OwnConsoles;
+ Console.WriteLine("Creating table `owned_consoles`");
+ dbCmd.CommandText = V3.OwnedConsoles;
dbCmd.ExecuteNonQuery();
- Console.WriteLine("Creating table `procesadores_principales`");
- dbCmd.CommandText = V2.ProcesadoresPrincipales;
+ Console.WriteLine("Creating table `processors`");
+ dbCmd.CommandText = V3.Processors;
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Creating table `sound_synths`");
+ dbCmd.CommandText = V3.SoundSynths;
dbCmd.ExecuteNonQuery();
return true;
diff --git a/Cicm.Database/Operations/MoneyDonation.cs b/Cicm.Database/Operations/MoneyDonation.cs
index 9478847b..1a0cb45c 100644
--- a/Cicm.Database/Operations/MoneyDonation.cs
+++ b/Cicm.Database/Operations/MoneyDonation.cs
@@ -51,7 +51,7 @@ namespace Cicm.Database
try
{
- const string SQL = "SELECT * from money_donation";
+ const string SQL = "SELECT * from money_donations";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -88,7 +88,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * FROM money_donation LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM money_donations LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -123,7 +123,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * from money_donation WHERE id = '{id}'";
+ string sql = $"SELECT * from money_donations WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -155,7 +155,7 @@ namespace Cicm.Database
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM money_donation";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM money_donations";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -178,7 +178,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO money_donation (donator, quantity)" + " VALUES (@donator, @quantity)";
+ const string SQL = "INSERT INTO money_donations (donator, quantity)" + " VALUES (@donator, @quantity)";
dbcmd.CommandText = SQL;
@@ -210,7 +210,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = "UPDATE money_donation SET donator = @donator, quantity = @quantity " +
+ string sql = "UPDATE money_donations SET donator = @donator, quantity = @quantity " +
$"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -230,14 +230,14 @@ namespace Cicm.Database
public bool RemoveMoneyDonation(long id)
{
#if DEBUG
- Console.WriteLine("Removing money_donation widh id `{0}`...", id);
+ Console.WriteLine("Removing money donation widh id `{0}`...", id);
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = $"DELETE FROM money_donation WHERE id = '{id}';";
+ string sql = $"DELETE FROM money_donations WHERE id = '{id}';";
dbcmd.CommandText = sql;
diff --git a/Cicm.Database/Operations/Mpu.cs b/Cicm.Database/Operations/MusicSynth.cs
similarity index 67%
rename from Cicm.Database/Operations/Mpu.cs
rename to Cicm.Database/Operations/MusicSynth.cs
index 83e1d784..a17ddda1 100644
--- a/Cicm.Database/Operations/Mpu.cs
+++ b/Cicm.Database/Operations/MusicSynth.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : Mpu.cs
+// Filename : MusicSynth.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// Contains operations to manage MPUs.
+// Contains operations to manage music synthetizer.
//
// --[ License ] --------------------------------------------------------------
//
@@ -39,19 +39,19 @@ namespace Cicm.Database
public partial class Operations
{
///
- /// Gets all MPUs
+ /// Gets all music synthetizers
///
- /// All MPUs
+ /// All music synthetizers
/// true if is correct, false otherwise
- public bool GetMpus(out List entries)
+ public bool GetMusicSynths(out List entries)
{
#if DEBUG
- Console.WriteLine("Getting all MPUs...");
+ Console.WriteLine("Getting all music synthetizers...");
#endif
try
{
- const string SQL = "SELECT * from mpus";
+ const string SQL = "SELECT * from music_synths";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -60,13 +60,13 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = MpusFromDataTable(dataSet.Tables[0]);
+ entries = MusicSynthFromDataTable(dataSet.Tables[0]);
return true;
}
catch(Exception ex)
{
- Console.WriteLine("Error getting MPUs.");
+ Console.WriteLine("Error getting music synthetizers.");
Console.WriteLine(ex);
entries = null;
return false;
@@ -74,21 +74,21 @@ namespace Cicm.Database
}
///
- /// Gets the specified number of MPUs since the specified start
+ /// Gets the specified number of music synthetizers since the specified start
///
- /// List of MPUs
+ /// List of music synthetizers
/// Start of query
/// How many entries to retrieve
/// true if is correct, false otherwise
- public bool GetMpus(out List entries, ulong start, ulong count)
+ public bool GetMusicSynths(out List entries, ulong start, ulong count)
{
#if DEBUG
- Console.WriteLine("Getting {0} MPUs from {1}...", count, start);
+ Console.WriteLine("Getting {0} music synthetizers from {1}...", count, start);
#endif
try
{
- string sql = $"SELECT * FROM mpus LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM music_synths LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -97,13 +97,13 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = MpusFromDataTable(dataSet.Tables[0]);
+ entries = MusicSynthFromDataTable(dataSet.Tables[0]);
return true;
}
catch(Exception ex)
{
- Console.WriteLine("Error getting MPUs.");
+ Console.WriteLine("Error getting music synthetizers.");
Console.WriteLine(ex);
entries = null;
return false;
@@ -111,19 +111,19 @@ namespace Cicm.Database
}
///
- /// Gets MPU by specified id
+ /// Gets music synthetizer by specified id
///
/// Id
- /// MPU with specified id, null if not found or error
- public Mpu GetMpu(int id)
+ /// music synthetizer with specified id, null if not found or error
+ public MusicSynth GetMusicSynth(int id)
{
#if DEBUG
- Console.WriteLine("Getting MPU with id {0}...", id);
+ Console.WriteLine("Getting music synthetizer with id {0}...", id);
#endif
try
{
- string sql = $"SELECT * from mpus WHERE id = '{id}'";
+ string sql = $"SELECT * from music_synths WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -132,30 +132,30 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- List entries = MpusFromDataTable(dataSet.Tables[0]);
+ List entries = MusicSynthFromDataTable(dataSet.Tables[0]);
return entries == null || entries.Count == 0 ? null : entries[0];
}
catch(Exception ex)
{
- Console.WriteLine("Error getting MPU.");
+ Console.WriteLine("Error getting music synthetizer.");
Console.WriteLine(ex);
return null;
}
}
///
- /// Counts the number of MPUs in the database
+ /// Counts the number of music synthetizers in the database
///
/// Entries in database
- public long CountMpus()
+ public long CountMusicSynths()
{
#if DEBUG
Console.WriteLine("Counting mpus...");
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM mpus";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM music_synths";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -163,22 +163,22 @@ namespace Cicm.Database
}
///
- /// Adds a new MPU to the database
+ /// Adds a new music synthetizer to the database
///
/// Entry to add
/// ID of added entry
/// true if added correctly, false otherwise
- public bool AddMpu(Mpu entry, out long id)
+ public bool AddMusicSynth(MusicSynth entry, out long id)
{
#if DEBUG
- Console.Write("Adding MPU `{0}`...", entry.Name);
+ Console.Write("Adding music synthetizer `{0}`...", entry.Name);
#endif
- IDbCommand dbcmd = GetCommandMpu(entry);
+ IDbCommand dbcmd = GetCommandMusicSynth(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO mpus (MPU)" + " VALUES (@MPU)";
+ const string SQL = "INSERT INTO music_synths (name)" + " VALUES (@name)";
dbcmd.CommandText = SQL;
@@ -196,21 +196,21 @@ namespace Cicm.Database
}
///
- /// Updated an MPU in the database
+ /// Updated an music synthetizer in the database
///
/// Updated entry
/// true if updated correctly, false otherwise
- public bool UpdateMpu(Mpu entry)
+ public bool UpdateMusicSynth(MusicSynth entry)
{
#if DEBUG
- Console.WriteLine("Updating MPU `{0}`...", entry.Name);
+ Console.WriteLine("Updating music synthetizer `{0}`...", entry.Name);
#endif
- IDbCommand dbcmd = GetCommandMpu(entry);
+ IDbCommand dbcmd = GetCommandMusicSynth(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = "UPDATE mpus SET MPU = @MPU " + $"WHERE id = {entry.Id}";
+ string sql = "UPDATE music_synths SET name = @name " + $"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -221,17 +221,17 @@ namespace Cicm.Database
return true;
}
- public bool RemoveMpu(long id)
+ public bool RemoveMusicSynth(long id)
{
#if DEBUG
- Console.WriteLine("Removing MPU widh id `{0}`...", id);
+ 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 mpus WHERE id = '{id}';";
+ string sql = $"DELETE FROM music_synths WHERE id = '{id}';";
dbcmd.CommandText = sql;
@@ -242,13 +242,13 @@ namespace Cicm.Database
return true;
}
- IDbCommand GetCommandMpu(Mpu entry)
+ IDbCommand GetCommandMusicSynth(MusicSynth entry)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataParameter param1 = dbcmd.CreateParameter();
- param1.ParameterName = "@MPU";
+ param1.ParameterName = "@name";
param1.DbType = DbType.String;
@@ -259,13 +259,17 @@ namespace Cicm.Database
return dbcmd;
}
- static List MpusFromDataTable(DataTable dataTable)
+ static List MusicSynthFromDataTable(DataTable dataTable)
{
- List entries = new List();
+ List entries = new List();
foreach(DataRow dataRow in dataTable.Rows)
{
- Mpu entry = new Mpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["MPU"].ToString()};
+ MusicSynth entry = new MusicSynth
+ {
+ Id = int.Parse(dataRow["id"].ToString()),
+ Name = dataRow["name"].ToString()
+ };
entries.Add(entry);
}
diff --git a/Cicm.Database/Operations/Operations.cs b/Cicm.Database/Operations/Operations.cs
index 9c9ca768..0637de35 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 = 2;
+ const int DB_VERSION = 3;
readonly IDbConnection dbCon;
readonly IDbCore dbCore;
diff --git a/Cicm.Database/Operations/OwnComputer.cs b/Cicm.Database/Operations/OwnedComputer.cs
similarity index 87%
rename from Cicm.Database/Operations/OwnComputer.cs
rename to Cicm.Database/Operations/OwnedComputer.cs
index 4844a3fa..768fdb5a 100644
--- a/Cicm.Database/Operations/OwnComputer.cs
+++ b/Cicm.Database/Operations/OwnedComputer.cs
@@ -2,7 +2,7 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : OwnConsole.cs
+// Filename : OwnedConsole.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
@@ -43,7 +43,7 @@ namespace Cicm.Database
///
/// All owned computers
/// true if is correct, false otherwise
- public bool GetOwnComputers(out List entries)
+ public bool GetOwnedComputers(out List entries)
{
#if DEBUG
Console.WriteLine("Getting all owned computers...");
@@ -51,7 +51,7 @@ namespace Cicm.Database
try
{
- const string SQL = "SELECT * from own_computer";
+ const string SQL = "SELECT * from owned_computers";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -60,7 +60,7 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = OwnComputersFromDataTable(dataSet.Tables[0]);
+ entries = OwnedComputersFromDataTable(dataSet.Tables[0]);
return true;
}
@@ -80,7 +80,7 @@ namespace Cicm.Database
/// Start of query
/// How many entries to retrieve
/// true if is correct, false otherwise
- public bool GetOwnComputers(out List entries, ulong start, ulong count)
+ public bool GetOwnedComputers(out List entries, ulong start, ulong count)
{
#if DEBUG
Console.WriteLine("Getting {0} owned computers from {1}...", count, start);
@@ -88,7 +88,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * FROM own_computer LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM owned_computers LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -97,7 +97,7 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = OwnComputersFromDataTable(dataSet.Tables[0]);
+ entries = OwnedComputersFromDataTable(dataSet.Tables[0]);
return true;
}
@@ -115,7 +115,7 @@ namespace Cicm.Database
///
/// Id
/// Owned computer with specified id, null if not found or error
- public OwnComputer GetOwnComputer(int id)
+ public OwnedComputer GetOwnedComputer(int id)
{
#if DEBUG
Console.WriteLine("Getting owned computer with id {0}...", id);
@@ -123,7 +123,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * from own_computer WHERE id = '{id}'";
+ string sql = $"SELECT * from owned_computers WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -132,7 +132,7 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- List entries = OwnComputersFromDataTable(dataSet.Tables[0]);
+ List entries = OwnedComputersFromDataTable(dataSet.Tables[0]);
return entries == null || entries.Count == 0 ? null : entries[0];
}
@@ -148,14 +148,14 @@ namespace Cicm.Database
/// Counts the number of owned computers in the database
///
/// Entries in database
- public long CountOwnComputers()
+ public long CountOwnedComputers()
{
#if DEBUG
Console.WriteLine("Counting owned computers...");
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM own_computer";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM owned_computers";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -168,18 +168,18 @@ namespace Cicm.Database
/// Entry to add
/// ID of added entry
/// true if added correctly, false otherwise
- public bool AddOwnComputer(OwnComputer entry, out long id)
+ public bool AddOwnedComputer(OwnedComputer entry, out long id)
{
#if DEBUG
Console.Write("Adding owned computer `{0}`...", entry.ComputerId);
#endif
- IDbCommand dbcmd = GetCommandOwnComputer(entry);
+ IDbCommand dbcmd = GetCommandOwnedComputer(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
const string SQL =
- "INSERT INTO own_computer (db_id, date, status, trade, boxed, manuals, cpu1, mhz1, cpu2, mhz2, ram, vram, rigid, disk1, cap1, disk2, cap2)" +
+ "INSERT INTO owned_computers (db_id, date, status, trade, boxed, manuals, cpu1, mhz1, cpu2, mhz2, ram, vram, rigid, disk1, cap1, disk2, cap2)" +
" VALUES (@db_id, @date, @status, @trade, @boxed, @manuals, @cpu1, @mhz1, @cpu2, @mhz2, @ram, @vram, @rigid, @disk1, @cap1, @disk2, @cap2)";
dbcmd.CommandText = SQL;
@@ -202,18 +202,18 @@ namespace Cicm.Database
///
/// Updated entry
/// true if updated correctly, false otherwise
- public bool UpdateOwnComputer(OwnComputer entry)
+ public bool UpdateOwnedComputer(OwnedComputer entry)
{
#if DEBUG
Console.WriteLine("Updating computer `{0}`...", entry.ComputerId);
#endif
- IDbCommand dbcmd = GetCommandOwnComputer(entry);
+ IDbCommand dbcmd = GetCommandOwnedComputer(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
string sql =
- "UPDATE own_computer SET db_id = @db_id, date = @date, status = @status, trade = @trade, boxed = @boxed, manuals = @manuals, cpu1 = @cpu1" +
+ "UPDATE owned_computers SET db_id = @db_id, date = @date, status = @status, trade = @trade, boxed = @boxed, manuals = @manuals, cpu1 = @cpu1" +
"mhz1 = @mhz1, cpu2 = @cpu2, mhz2 = @mhz2, ram = @ram, vram = @vram, rigid = @rigid, disk1 = @disk1, cap1 = @cap1, disk2 = @disk2, cap2 = @cap2 " +
$"WHERE id = {entry.Id}";
@@ -231,7 +231,7 @@ namespace Cicm.Database
///
/// ID of entry to remove
/// true if removed correctly, false otherwise
- public bool RemoveOwnComputer(long id)
+ public bool RemoveOwnedComputer(long id)
{
#if DEBUG
Console.WriteLine("Removing owned computer widh id `{0}`...", id);
@@ -241,7 +241,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = $"DELETE FROM own_computer WHERE id = '{id}';";
+ string sql = $"DELETE FROM owned_computers WHERE id = '{id}';";
dbcmd.CommandText = sql;
@@ -252,7 +252,7 @@ namespace Cicm.Database
return true;
}
- IDbCommand GetCommandOwnComputer(OwnComputer entry)
+ IDbCommand GetCommandOwnedComputer(OwnedComputer entry)
{
IDbCommand dbcmd = dbCon.CreateCommand();
@@ -349,20 +349,20 @@ namespace Cicm.Database
return dbcmd;
}
- static List OwnComputersFromDataTable(DataTable dataTable)
+ static List OwnedComputersFromDataTable(DataTable dataTable)
{
- List entries = new List();
+ List entries = new List();
foreach(DataRow dataRow in dataTable.Rows)
{
- OwnComputer entry = new OwnComputer
+ OwnedComputer entry = new OwnedComputer
{
Id = int.Parse(dataRow["id"].ToString()),
ComputerId = int.Parse(dataRow["db_id"].ToString()),
Acquired = dataRow["date"].ToString(),
Status = (StatusType)int.Parse(dataRow["status"].ToString()),
- Trade = int.Parse(dataRow["trade"].ToString()) > 0,
- Boxed = int.Parse(dataRow["boxed"].ToString()) > 0,
+ Trade = int.Parse(dataRow["trade"].ToString()) > 0,
+ Boxed = int.Parse(dataRow["boxed"].ToString()) > 0,
Manuals = int.Parse(dataRow["manuals"].ToString()) > 0,
Cpu1 = int.Parse(dataRow["cpu1"].ToString()),
Mhz1 = float.Parse(dataRow["mhz1"].ToString()),
diff --git a/Cicm.Database/Operations/OwnConsole.cs b/Cicm.Database/Operations/OwnedConsole.cs
similarity index 84%
rename from Cicm.Database/Operations/OwnConsole.cs
rename to Cicm.Database/Operations/OwnedConsole.cs
index 25ed9d9a..da156c24 100644
--- a/Cicm.Database/Operations/OwnConsole.cs
+++ b/Cicm.Database/Operations/OwnedConsole.cs
@@ -43,7 +43,7 @@ namespace Cicm.Database
///
/// All owned consoles
/// true if is correct, false otherwise
- public bool GetOwnConsoles(out List entries)
+ public bool GetOwnedConsoles(out List entries)
{
#if DEBUG
Console.WriteLine("Getting all owned consoles...");
@@ -51,7 +51,7 @@ namespace Cicm.Database
try
{
- const string SQL = "SELECT * from own_consoles";
+ const string SQL = "SELECT * from owned_consoles";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -60,7 +60,7 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = OwnConsolesFromDataTable(dataSet.Tables[0]);
+ entries = OwnedConsolesFromDataTable(dataSet.Tables[0]);
return true;
}
@@ -80,7 +80,7 @@ namespace Cicm.Database
/// Start of query
/// How many entries to retrieve
/// true if is correct, false otherwise
- public bool GetOwnConsoles(out List entries, ulong start, ulong count)
+ public bool GetOwnedConsoles(out List entries, ulong start, ulong count)
{
#if DEBUG
Console.WriteLine("Getting {0} owned consoles from {1}...", count, start);
@@ -88,7 +88,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * FROM own_consoles LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM owned_consoles LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -97,7 +97,7 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = OwnConsolesFromDataTable(dataSet.Tables[0]);
+ entries = OwnedConsolesFromDataTable(dataSet.Tables[0]);
return true;
}
@@ -115,7 +115,7 @@ namespace Cicm.Database
///
/// Id
/// Owned console with specified id, null if not found or error
- public OwnConsole GetOwnConsole(int id)
+ public OwnedConsole GetOwnedConsole(int id)
{
#if DEBUG
Console.WriteLine("Getting owned console with id {0}...", id);
@@ -123,7 +123,7 @@ namespace Cicm.Database
try
{
- string sql = $"SELECT * from own_consoles WHERE id = '{id}'";
+ string sql = $"SELECT * from owned_consoles WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -132,7 +132,7 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- List entries = OwnConsolesFromDataTable(dataSet.Tables[0]);
+ List entries = OwnedConsolesFromDataTable(dataSet.Tables[0]);
return entries == null || entries.Count == 0 ? null : entries[0];
}
@@ -148,14 +148,14 @@ namespace Cicm.Database
/// Counts the number of owned consoles in the database
///
/// Entries in database
- public long CountOwnConsoles()
+ public long CountOwnedConsoles()
{
#if DEBUG
Console.WriteLine("Counting owned consoles...");
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM own_consoles";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM owned_consoles";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -168,17 +168,17 @@ namespace Cicm.Database
/// Entry to add
/// ID of added entry
/// true if added correctly, false otherwise
- public bool AddOwnConsole(OwnConsole entry, out long id)
+ public bool AddOwnedConsole(OwnedConsole entry, out long id)
{
#if DEBUG
Console.Write("Adding owned console `{0}`...", entry.ConsoleId);
#endif
- IDbCommand dbcmd = GetCommandOwnConsole(entry);
+ IDbCommand dbcmd = GetCommandOwnedConsole(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO own_consoles (db_id, date, status, trade, boxed, manuals)" +
+ const string SQL = "INSERT INTO owned_consoles (db_id, date, status, trade, boxed, manuals)" +
" VALUES (@db_id, @date, @status, @trade, @boxed, @manuals)";
dbcmd.CommandText = SQL;
@@ -201,18 +201,18 @@ namespace Cicm.Database
///
/// Updated entry
/// true if updated correctly, false otherwise
- public bool UpdateOwnConsole(OwnConsole entry)
+ public bool UpdateOwnedConsole(OwnedConsole entry)
{
#if DEBUG
- Console.WriteLine("Updating console `{0}`...", entry.ConsoleId);
+ Console.WriteLine("Updating owned console `{0}`...", entry.ConsoleId);
#endif
- IDbCommand dbcmd = GetCommandOwnConsole(entry);
+ IDbCommand dbcmd = GetCommandOwnedConsole(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
string sql =
- "UPDATE own_consoles SET db_id = @db_id, date = @date, status = @status, trade = @trade, boxed = @boxed, manuals = @manuals " +
+ "UPDATE owned_consoles SET db_id = @db_id, date = @date, status = @status, trade = @trade, boxed = @boxed, manuals = @manuals " +
$"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -229,7 +229,7 @@ namespace Cicm.Database
///
/// ID of entry to remove
/// true if removed correctly, false otherwise
- public bool RemoveOwnConsole(long id)
+ public bool RemoveOwnedConsole(long id)
{
#if DEBUG
Console.WriteLine("Removing owned console widh id `{0}`...", id);
@@ -239,7 +239,7 @@ namespace Cicm.Database
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = $"DELETE FROM own_consoles WHERE id = '{id}';";
+ string sql = $"DELETE FROM owned_consoles WHERE id = '{id}';";
dbcmd.CommandText = sql;
@@ -250,7 +250,7 @@ namespace Cicm.Database
return true;
}
- IDbCommand GetCommandOwnConsole(OwnConsole entry)
+ IDbCommand GetCommandOwnedConsole(OwnedConsole entry)
{
IDbCommand dbcmd = dbCon.CreateCommand();
@@ -292,20 +292,20 @@ namespace Cicm.Database
return dbcmd;
}
- static List OwnConsolesFromDataTable(DataTable dataTable)
+ static List OwnedConsolesFromDataTable(DataTable dataTable)
{
- List entries = new List();
+ List entries = new List();
foreach(DataRow dataRow in dataTable.Rows)
{
- OwnConsole entry = new OwnConsole
+ OwnedConsole entry = new OwnedConsole
{
Id = int.Parse(dataRow["id"].ToString()),
ConsoleId = int.Parse(dataRow["db_id"].ToString()),
Acquired = dataRow["date"].ToString(),
Status = (StatusType)int.Parse(dataRow["status"].ToString()),
- Trade = int.Parse(dataRow["trade"].ToString()) > 0,
- Boxed = int.Parse(dataRow["boxed"].ToString()) > 0,
+ Trade = int.Parse(dataRow["trade"].ToString()) > 0,
+ Boxed = int.Parse(dataRow["boxed"].ToString()) > 0,
Manuals = int.Parse(dataRow["manuals"].ToString()) > 0
};
diff --git a/Cicm.Database/Operations/Cpu.cs b/Cicm.Database/Operations/Processor.cs
similarity index 68%
rename from Cicm.Database/Operations/Cpu.cs
rename to Cicm.Database/Operations/Processor.cs
index e5f04483..73838c82 100644
--- a/Cicm.Database/Operations/Cpu.cs
+++ b/Cicm.Database/Operations/Processor.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : Cpu.cs
+// Filename : Processor.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// Contains operations to manage CPUs.
+// Contains operations to manage processors.
//
// --[ License ] --------------------------------------------------------------
//
@@ -39,19 +39,19 @@ namespace Cicm.Database
public partial class Operations
{
///
- /// Gets all CPUs
+ /// Gets all processors
///
/// All CPUs
/// true if is correct, false otherwise
- public bool GetCpus(out List entries)
+ public bool GetProcessors(out List entries)
{
#if DEBUG
- Console.WriteLine("Getting all CPUs...");
+ Console.WriteLine("Getting all processors...");
#endif
try
{
- const string SQL = "SELECT * from cpu";
+ const string SQL = "SELECT * from processors";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -60,13 +60,13 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = CpusFromDataTable(dataSet.Tables[0]);
+ entries = ProcessorsFromDataTable(dataSet.Tables[0]);
return true;
}
catch(Exception ex)
{
- Console.WriteLine("Error getting CPUs.");
+ Console.WriteLine("Error getting processors.");
Console.WriteLine(ex);
entries = null;
return false;
@@ -74,21 +74,21 @@ namespace Cicm.Database
}
///
- /// Gets the specified number of CPUs since the specified start
+ /// Gets the specified number of processors since the specified start
///
- /// List of CPUs
+ /// List of processors
/// Start of query
/// How many entries to retrieve
/// true if is correct, false otherwise
- public bool GetCpus(out List entries, ulong start, ulong count)
+ public bool GetProcessors(out List entries, ulong start, ulong count)
{
#if DEBUG
- Console.WriteLine("Getting {0} CPUs from {1}...", count, start);
+ Console.WriteLine("Getting {0} processors from {1}...", count, start);
#endif
try
{
- string sql = $"SELECT * FROM cpu LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM processors LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -97,13 +97,13 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = CpusFromDataTable(dataSet.Tables[0]);
+ entries = ProcessorsFromDataTable(dataSet.Tables[0]);
return true;
}
catch(Exception ex)
{
- Console.WriteLine("Error getting CPUs.");
+ Console.WriteLine("Error getting processors.");
Console.WriteLine(ex);
entries = null;
return false;
@@ -111,19 +111,19 @@ namespace Cicm.Database
}
///
- /// Gets CPU by specified id
+ /// Gets processor by specified id
///
/// Id
- /// CPU with specified id, null if not found or error
- public Cpu GetCpu(int id)
+ /// Processor with specified id, null if not found or error
+ public Processor GetProcessor(int id)
{
#if DEBUG
- Console.WriteLine("Getting CPU with id {0}...", id);
+ Console.WriteLine("Getting processor with id {0}...", id);
#endif
try
{
- string sql = $"SELECT * from cpu WHERE id = '{id}'";
+ string sql = $"SELECT * from processors WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -132,30 +132,30 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- List entries = CpusFromDataTable(dataSet.Tables[0]);
+ List entries = ProcessorsFromDataTable(dataSet.Tables[0]);
return entries == null || entries.Count == 0 ? null : entries[0];
}
catch(Exception ex)
{
- Console.WriteLine("Error getting CPU.");
+ Console.WriteLine("Error getting processor.");
Console.WriteLine(ex);
return null;
}
}
///
- /// Counts the number of CPUs in the database
+ /// Counts the number of processors in the database
///
/// Entries in database
- public long CountCpus()
+ public long CountProcessors()
{
#if DEBUG
- Console.WriteLine("Counting CPUs...");
+ Console.WriteLine("Counting processors...");
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM cpu";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM processors";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -163,22 +163,22 @@ namespace Cicm.Database
}
///
- /// Adds a new CPU to the database
+ /// Adds a new processor to the database
///
/// Entry to add
/// ID of added entry
/// true if added correctly, false otherwise
- public bool AddCpu(Cpu entry, out long id)
+ public bool AddProcessor(Processor entry, out long id)
{
#if DEBUG
- Console.Write("Adding CPU `{0}`...", entry.Name);
+ Console.Write("Adding processor `{0}`...", entry.Name);
#endif
- IDbCommand dbcmd = GetCommandCpu(entry);
+ IDbCommand dbcmd = GetCommandProcessor(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO cpu (cpu)" + " VALUES (@cpu)";
+ const string SQL = "INSERT INTO processors (name)" + " VALUES (@name)";
dbcmd.CommandText = SQL;
@@ -196,21 +196,21 @@ namespace Cicm.Database
}
///
- /// Updated a CPU in the database
+ /// Updated a processor in the database
///
/// Updated entry
/// true if updated correctly, false otherwise
- public bool UpdateCpu(Cpu entry)
+ public bool UpdateProcessor(Processor entry)
{
#if DEBUG
- Console.WriteLine("Updating CPU `{0}`...", entry.Name);
+ Console.WriteLine("Updating processor `{0}`...", entry.Name);
#endif
- IDbCommand dbcmd = GetCommandCpu(entry);
+ IDbCommand dbcmd = GetCommandProcessor(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = "UPDATE cpu SET cpu = @cpu " + $"WHERE id = {entry.Id}";
+ string sql = "UPDATE processors SET name = @name " + $"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -222,21 +222,21 @@ namespace Cicm.Database
}
///
- /// Removes a CPU from the database
+ /// Removes a processor from the database
///
/// ID of entry to remove
/// true if removed correctly, false otherwise
- public bool RemoveCpu(long id)
+ public bool RemoveProcessor(long id)
{
#if DEBUG
- Console.WriteLine("Removing CPU widh id `{0}`...", id);
+ Console.WriteLine("Removing processor widh id `{0}`...", id);
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = $"DELETE FROM cpu WHERE id = '{id}';";
+ string sql = $"DELETE FROM processors WHERE id = '{id}';";
dbcmd.CommandText = sql;
@@ -247,13 +247,13 @@ namespace Cicm.Database
return true;
}
- IDbCommand GetCommandCpu(Cpu entry)
+ IDbCommand GetCommandProcessor(Processor entry)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataParameter param1 = dbcmd.CreateParameter();
- param1.ParameterName = "@cpu";
+ param1.ParameterName = "@name";
param1.DbType = DbType.String;
@@ -264,13 +264,17 @@ namespace Cicm.Database
return dbcmd;
}
- static List CpusFromDataTable(DataTable dataTable)
+ static List ProcessorsFromDataTable(DataTable dataTable)
{
- List entries = new List();
+ List entries = new List();
foreach(DataRow dataRow in dataTable.Rows)
{
- Cpu entry = new Cpu {Id = int.Parse(dataRow["id"].ToString()), Name = dataRow["cpu"].ToString()};
+ Processor entry = new Processor
+ {
+ Id = int.Parse(dataRow["id"].ToString()),
+ Name = dataRow["name"].ToString()
+ };
entries.Add(entry);
}
diff --git a/Cicm.Database/Operations/ConsoleCompany.cs b/Cicm.Database/Operations/SoundSynth.cs
similarity index 66%
rename from Cicm.Database/Operations/ConsoleCompany.cs
rename to Cicm.Database/Operations/SoundSynth.cs
index f364bad3..36f7c631 100644
--- a/Cicm.Database/Operations/ConsoleCompany.cs
+++ b/Cicm.Database/Operations/SoundSynth.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : ConsoleCompany.cs
+// Filename : SoundSynth.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// Contains operations to manage console manufacturers.
+// Contains operations to manage sound synthetizers.
//
// --[ License ] --------------------------------------------------------------
//
@@ -39,19 +39,19 @@ namespace Cicm.Database
public partial class Operations
{
///
- /// Gets all console companies
+ /// Gets all sound synthetizers
///
- /// All console companies
+ /// All sound synthetizers
/// true if is correct, false otherwise
- public bool GetConsoleCompanies(out List entries)
+ public bool GetSoundSynths(out List entries)
{
#if DEBUG
- Console.WriteLine("Getting all console companies...");
+ Console.WriteLine("Getting all sound synthetizers...");
#endif
try
{
- const string SQL = "SELECT * from console_company";
+ const string SQL = "SELECT * from sound_synths";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -60,13 +60,13 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = ConsoleCompaniesFromDataTable(dataSet.Tables[0]);
+ entries = SoundSynthFromDataTable(dataSet.Tables[0]);
return true;
}
catch(Exception ex)
{
- Console.WriteLine("Error getting console companies.");
+ Console.WriteLine("Error getting sound synthetizers.");
Console.WriteLine(ex);
entries = null;
return false;
@@ -74,21 +74,21 @@ namespace Cicm.Database
}
///
- /// Gets the specified number of console companies since the specified start
+ /// Gets the specified number of sound synthetizers since the specified start
///
- /// List of console companies
+ /// List of sound synthetizers
/// Start of query
/// How many entries to retrieve
/// true if is correct, false otherwise
- public bool GetConsoleCompanies(out List entries, ulong start, ulong count)
+ public bool GetSoundSynths(out List entries, ulong start, ulong count)
{
#if DEBUG
- Console.WriteLine("Getting {0} console companies from {1}...", count, start);
+ Console.WriteLine("Getting {0} sound synthetizers from {1}...", count, start);
#endif
try
{
- string sql = $"SELECT * FROM console_company LIMIT {start}, {count}";
+ string sql = $"SELECT * FROM sound_synths LIMIT {start}, {count}";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -97,13 +97,13 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- entries = ConsoleCompaniesFromDataTable(dataSet.Tables[0]);
+ entries = SoundSynthFromDataTable(dataSet.Tables[0]);
return true;
}
catch(Exception ex)
{
- Console.WriteLine("Error getting console companies.");
+ Console.WriteLine("Error getting sound synthetizers.");
Console.WriteLine(ex);
entries = null;
return false;
@@ -111,19 +111,19 @@ namespace Cicm.Database
}
///
- /// Gets console company by specified id
+ /// Gets sound synthetizer by specified id
///
/// Id
- /// Console company with specified id, null if not found or error
- public ConsoleCompany GetConsoleCompany(int id)
+ /// Sound synthetizer with specified id, null if not found or error
+ public SoundSynth GetSoundSynth(int id)
{
#if DEBUG
- Console.WriteLine("Getting console company with id {0}...", id);
+ Console.WriteLine("Getting sound synthetizer with id {0}...", id);
#endif
try
{
- string sql = $"SELECT * from console_company WHERE id = '{id}'";
+ string sql = $"SELECT * from sound_synths WHERE id = '{id}'";
IDbCommand dbCmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -132,30 +132,30 @@ namespace Cicm.Database
dataAdapter.SelectCommand = dbCmd;
dataAdapter.Fill(dataSet);
- List entries = ConsoleCompaniesFromDataTable(dataSet.Tables[0]);
+ List entries = SoundSynthFromDataTable(dataSet.Tables[0]);
return entries == null || entries.Count == 0 ? null : entries[0];
}
catch(Exception ex)
{
- Console.WriteLine("Error getting console company.");
+ Console.WriteLine("Error getting sound synthetizer.");
Console.WriteLine(ex);
return null;
}
}
///
- /// Counts the number of console companies in the database
+ /// Counts the number of sound synthetizers in the database
///
/// Entries in database
- public long CountConsoleCompanies()
+ public long CountSoundSynths()
{
#if DEBUG
- Console.WriteLine("Counting console companies...");
+ Console.WriteLine("Counting sound synthetizers...");
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
- dbcmd.CommandText = "SELECT COUNT(*) FROM console_company";
+ dbcmd.CommandText = "SELECT COUNT(*) FROM sound_synths";
object count = dbcmd.ExecuteScalar();
dbcmd.Dispose();
try { return Convert.ToInt64(count); }
@@ -163,22 +163,22 @@ namespace Cicm.Database
}
///
- /// Adds a new console company to the database
+ /// Adds a new sound synthetizer to the database
///
/// Entry to add
/// ID of added entry
/// true if added correctly, false otherwise
- public bool AddConsoleCompany(ConsoleCompany entry, out long id)
+ public bool AddSoundSynth(SoundSynth entry, out long id)
{
#if DEBUG
- Console.Write("Adding console company `{0}`...", entry.Name);
+ Console.Write("Adding sound synthetizer `{0}`...", entry.Name);
#endif
- IDbCommand dbcmd = GetCommandConsoleCompany(entry);
+ IDbCommand dbcmd = GetCommandSoundSynth(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- const string SQL = "INSERT INTO console_company (company)" + " VALUES (@company)";
+ const string SQL = "INSERT INTO sound_synths (name)" + " VALUES (@name)";
dbcmd.CommandText = SQL;
@@ -196,21 +196,21 @@ namespace Cicm.Database
}
///
- /// Updated a console company in the database
+ /// Updated a sound synthetizer in the database
///
/// Updated entry
/// true if updated correctly, false otherwise
- public bool UpdateConsoleCompany(ConsoleCompany entry)
+ public bool UpdateSoundSynth(SoundSynth entry)
{
#if DEBUG
- Console.WriteLine("Updating console company `{0}`...", entry.Name);
+ Console.WriteLine("Updating sound synthetizer `{0}`...", entry.Name);
#endif
- IDbCommand dbcmd = GetCommandConsoleCompany(entry);
+ IDbCommand dbcmd = GetCommandSoundSynth(entry);
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = "UPDATE console_company SET company = @company " + $"WHERE id = {entry.Id}";
+ string sql = "UPDATE sound_synths SET name = @name " + $"WHERE id = {entry.Id}";
dbcmd.CommandText = sql;
@@ -222,21 +222,21 @@ namespace Cicm.Database
}
///
- /// Removes a console company from the database
+ /// Removes a sound synthetizer from the database
///
/// ID of entry to remove
/// true if removed correctly, false otherwise
- public bool RemoveConsoleCompany(long id)
+ public bool RemoveSoundSynth(long id)
{
#if DEBUG
- Console.WriteLine("Removing console company widh id `{0}`...", id);
+ Console.WriteLine("Removing sound synthetizer widh id `{0}`...", id);
#endif
IDbCommand dbcmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
dbcmd.Transaction = trans;
- string sql = $"DELETE FROM console_company WHERE id = '{id}';";
+ string sql = $"DELETE FROM sound_synths WHERE id = '{id}';";
dbcmd.CommandText = sql;
@@ -247,13 +247,13 @@ namespace Cicm.Database
return true;
}
- IDbCommand GetCommandConsoleCompany(ConsoleCompany entry)
+ IDbCommand GetCommandSoundSynth(SoundSynth entry)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataParameter param1 = dbcmd.CreateParameter();
- param1.ParameterName = "@company";
+ param1.ParameterName = "@name";
param1.DbType = DbType.String;
@@ -264,16 +264,16 @@ namespace Cicm.Database
return dbcmd;
}
- static List ConsoleCompaniesFromDataTable(DataTable dataTable)
+ static List SoundSynthFromDataTable(DataTable dataTable)
{
- List entries = new List();
+ List entries = new List();
foreach(DataRow dataRow in dataTable.Rows)
{
- ConsoleCompany entry = new ConsoleCompany
+ SoundSynth entry = new SoundSynth
{
Id = int.Parse(dataRow["id"].ToString()),
- Name = dataRow["company"].ToString()
+ Name = dataRow["name"].ToString()
};
entries.Add(entry);
diff --git a/Cicm.Database/Operations/Update.cs b/Cicm.Database/Operations/Update.cs
index 13b05dd5..387a1fad 100644
--- a/Cicm.Database/Operations/Update.cs
+++ b/Cicm.Database/Operations/Update.cs
@@ -28,6 +28,11 @@
// Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+
namespace Cicm.Database
{
public partial class Operations
@@ -38,8 +43,342 @@ namespace Cicm.Database
/// true if updated correctly, false otherwise
public bool UpdateDatabase()
{
- // Do nothing
+ bool dbV2 = !dbCore.TableExists("cicm_db");
+ int currentDbVersion = 2;
+
+ if(!dbV2)
+ {
+ IDbCommand dbCmd = dbCon.CreateCommand();
+ IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
+ dbCmd.CommandText = "SELECT * FROM cicm_db";
+ DataSet dataSet = new DataSet();
+ dataAdapter.SelectCommand = dbCmd;
+ dataAdapter.Fill(dataSet);
+
+ foreach(DataRow dataRow in dataSet.Tables[0].Rows)
+ {
+ int newId = int.Parse(dataRow["version"].ToString());
+
+ if(newId > currentDbVersion) currentDbVersion = newId;
+ }
+ }
+
+ Console.WriteLine("Database version: {0}", currentDbVersion);
+
+ if(currentDbVersion > DB_VERSION)
+ {
+ Console.WriteLine("Current database version is higher than last supported version {0}, cannot continue...",
+ DB_VERSION);
+ return false;
+ }
+
+ if(currentDbVersion == DB_VERSION) return true;
+
+ for(int i = currentDbVersion; i < DB_VERSION; i++)
+ switch(i)
+ {
+ case 2:
+ {
+ UpdateDatabaseV2ToV3();
+ break;
+ }
+ }
+
+ OptimizeDatabase();
return true;
}
+
+ void UpdateDatabaseV2ToV3()
+ {
+ Console.WriteLine("Updating database to version 3");
+
+ Console.WriteLine("Creating versioning table");
+ IDbCommand dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"CREATE TABLE `cicm_db` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `version` INT NOT NULL,
+ `updated` DATETIME DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`) )";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming table `admin` to `admins`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `admin` RENAME TO `admins`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `browser_test.idstring` to `browser_test.user_agent`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText =
+ @"ALTER TABLE `browser_test` CHANGE COLUMN `idstring` `user_agent` varchar(128) NOT NULL DEFAULT '';";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming table `browser_test` to `browser_tests`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `browser_test` RENAME TO `browser_tests`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `Companias.Compania` to `Companias.name`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText =
+ @"ALTER TABLE `Companias` CHANGE COLUMN `Compania` `name` varchar(128) NOT NULL DEFAULT '';";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming table `Companias` to `companies`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `Companias` RENAME TO `companies`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `computers.spu` to `computers.sound_synth`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText =
+ @"ALTER TABLE `computers` CHANGE COLUMN `spu` `sound_synth` int(11) NOT NULL DEFAULT '0'";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming column `computers.mpu` to `music_synth.name`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText =
+ @"ALTER TABLE `computers` CHANGE COLUMN `mpu` `music_synth` int(11) NOT NULL DEFAULT '0'";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Dropping column `computers.comment`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `computers` DROP COLUMN `comment`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `consoles.name` to `consoles.model`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `consoles` CHANGE COLUMN `name` `model` char(50) NOT NULL DEFAULT ''";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming column `consoles.spu` to `consoles.sound_synth`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText =
+ @"ALTER TABLE `consoles` CHANGE COLUMN `spu` `sound_synth` int(11) NOT NULL DEFAULT '0'";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming column `consoles.mpu` to `consoles.music_synth`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText =
+ @"ALTER TABLE `consoles` CHANGE COLUMN `mpu` `music_synth` int(11) NOT NULL DEFAULT '0'";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Dropping column `consoles.comments`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `consoles` DROP COLUMN `comments`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `cpu.cpu` to `cpu.name`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `cpu` CHANGE COLUMN `cpu` `name` char(50) NOT NULL DEFAULT ''";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming table `cpu` to `processors`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `cpu` RENAME TO `processors`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `DSPs.DSP` to `DSPs.name`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `DSPs` CHANGE COLUMN `DSP` `name` char(50) NOT NULL DEFAULT ''";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming table `DSPs` to `sound_synths`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `DSPs` RENAME TO `sound_synths`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `Formatos_de_disco.Format` to `Formatos_de_disco.description`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText =
+ @"ALTER TABLE `Formatos_de_disco` CHANGE COLUMN `Format` `description` char(50) NOT NULL DEFAULT ''";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming table `Formatos_de_disco` to `disk_formats`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `Formatos_de_disco` RENAME TO `disk_formats`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `gpus.gpu` to `gpus.name`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `gpus` CHANGE COLUMN `gpu` `name` char(128) NOT NULL DEFAULT ''";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming table `money_donation` to `money_donations`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `money_donation` RENAME TO `money_donations`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming column `mpus.mpu` to `mpus.name`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `mpus` CHANGE COLUMN `mpu` `name` char(50) NOT NULL DEFAULT ''";
+ dbCmd.ExecuteNonQuery();
+ Console.WriteLine("Renaming table `mpus` to `music_synths`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `mpus` RENAME TO `music_synths`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming table `own_computer` to `owned_computers`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `own_computer` RENAME TO `owned_computers`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Renaming table `own_consoles` to `owned_consoles`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"ALTER TABLE `own_consoles` RENAME TO `owned_consoles`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Dropping table `procesadores_principales`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"DROP TABLE `procesadores_principales`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Getting all items from `console_company`");
+
+ Dictionary consoleCompanies = new Dictionary();
+ dbCmd = dbCon.CreateCommand();
+ IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
+ dbCmd.CommandText = "SELECT * from console_company";
+ DataSet dataSet = new DataSet();
+ dataAdapter.SelectCommand = dbCmd;
+ dataAdapter.Fill(dataSet);
+
+ foreach(DataRow dataRow in dataSet.Tables[0].Rows)
+ consoleCompanies.Add(int.Parse(dataRow["id"].ToString()), dataRow["company"].ToString());
+
+ Dictionary conversionEquivalents = new Dictionary();
+ IDbTransaction trans;
+
+ Console.WriteLine("Converting all items from `console_company` to `companies`");
+ foreach(KeyValuePair consoleCompany in consoleCompanies)
+ {
+ dbCmd = dbCon.CreateCommand();
+ dataAdapter = dbCore.GetNewDataAdapter();
+ dbCmd.CommandText = $"SELECT * from companies WHERE name LIKE '{consoleCompany.Value}'";
+ dataSet = new DataSet();
+ dataAdapter.SelectCommand = dbCmd;
+ dataAdapter.Fill(dataSet);
+
+ if(dataSet.Tables[0].Rows.Count == 1)
+ {
+ Console.WriteLine("Converting console company `{0}` to company `{1}`", consoleCompany.Value,
+ dataSet.Tables[0].Rows[0]["name"]);
+ conversionEquivalents.Add(consoleCompany.Key,
+ int.Parse(dataSet.Tables[0].Rows[0]["id"].ToString()));
+ }
+ else
+ {
+ Console.Write("Adding new company `{0}`... ", consoleCompany.Value);
+ dbCmd = dbCon.CreateCommand();
+ trans = dbCon.BeginTransaction();
+ dbCmd.Transaction = trans;
+ dbCmd.CommandText = $"INSERT INTO companies (name) VALUES ('{consoleCompany.Value}')";
+
+ dbCmd.ExecuteNonQuery();
+ trans.Commit();
+ dbCmd.Dispose();
+
+ long id = dbCore.LastInsertRowId;
+ Console.WriteLine("got id {0}", id);
+ conversionEquivalents.Add(consoleCompany.Key, (int)id);
+ }
+ }
+
+ Console.WriteLine("Getting all items from `consoles`");
+ Dictionary consoleIdAndCompanyId = new Dictionary();
+ dbCmd = dbCon.CreateCommand();
+ dataAdapter = dbCore.GetNewDataAdapter();
+ dbCmd.CommandText = "SELECT id,company from consoles";
+ dataSet = new DataSet();
+ dataAdapter.SelectCommand = dbCmd;
+ dataAdapter.Fill(dataSet);
+ foreach(DataRow dataRow in dataSet.Tables[0].Rows)
+ consoleIdAndCompanyId.Add(int.Parse(dataRow["id"].ToString()),
+ int.Parse(dataRow["company"].ToString()));
+
+ trans = dbCon.BeginTransaction();
+ foreach(KeyValuePair keyValuePair in consoleIdAndCompanyId)
+ {
+ conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId);
+ Console.WriteLine("Converting console company {0} to company {1} for console {2}... ",
+ keyValuePair.Value, newId, keyValuePair.Key);
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.Transaction = trans;
+ dbCmd.CommandText = $"UPDATE consoles SET company = {newId} WHERE id = {keyValuePair.Key}";
+ dbCmd.ExecuteNonQuery();
+ dbCmd.Dispose();
+ }
+
+ Console.WriteLine("Comitting changes...");
+ trans.Commit();
+
+ Console.WriteLine("Moving company logos...");
+ foreach(string file in Directory.GetFiles("wwwroot/assets/logos/computers/", "*",
+ SearchOption.TopDirectoryOnly))
+ {
+ string newPath = Path.Combine("wwwroot/assets/logos/", Path.GetFileName(file));
+ Console.WriteLine("Moving {0} to {1}...", file, newPath);
+ File.Move(file, newPath);
+ }
+
+ Console.WriteLine("Removing old computer company logos directory...");
+ Directory.Delete("wwwroot/assets/logos/computers");
+
+ Console.WriteLine("Moving console company logos...");
+ foreach(string file in Directory.GetFiles("wwwroot/assets/logos/consoles/", "*",
+ SearchOption.TopDirectoryOnly))
+ {
+ string oldNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
+ if(!int.TryParse(oldNameWithoutExtension, out int oldId))
+ {
+ Console.WriteLine("Removing stray file {0}...", file);
+ File.Delete(file);
+ continue;
+ }
+
+ conversionEquivalents.TryGetValue(oldId, out int newId);
+ string extension = Path.GetExtension(file);
+
+ string newPath = Path.Combine("wwwroot/assets/logos/", $"{newId}{extension}");
+ if(File.Exists(newPath))
+ {
+ Console.WriteLine("Removing duplicate file {0}...", file);
+ File.Delete(file);
+ }
+ else
+ {
+ Console.WriteLine("Moving {0} to {1}...", file, newPath);
+ File.Move(file, newPath);
+ }
+ }
+
+ Console.WriteLine("Removing old console company logos directory...");
+ Directory.Delete("wwwroot/assets/logos/consoles");
+
+ Console.WriteLine("Dropping table `console_company`");
+ dbCmd = dbCon.CreateCommand();
+ dbCmd.CommandText = @"DROP TABLE `console_company`;";
+ dbCmd.ExecuteNonQuery();
+
+ Console.WriteLine("Setting new database version to 3...");
+ dbCmd = dbCon.CreateCommand();
+ trans = dbCon.BeginTransaction();
+ dbCmd.Transaction = trans;
+ dbCmd.CommandText = $"INSERT INTO cicm_db (version) VALUES ('3')";
+ dbCmd.ExecuteNonQuery();
+ trans.Commit();
+ dbCmd.Dispose();
+
+ Console.WriteLine("Finished update version to 3...");
+ }
+
+ void OptimizeDatabase()
+ {
+ IDbCommand dbCmd = dbCon.CreateCommand();
+ IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
+ dbCmd.CommandText = "SHOW TABLES";
+ DataSet dataSet = new DataSet();
+ dataAdapter.SelectCommand = dbCmd;
+ dataAdapter.Fill(dataSet);
+
+ foreach(DataRow dataRow in dataSet.Tables[0].Rows)
+ {
+ string tableName = dataRow[0].ToString();
+
+ Console.WriteLine("Optimizing table `{0}`", tableName);
+ dbCmd = dbCon.CreateCommand();
+ dataAdapter = dbCore.GetNewDataAdapter();
+ dbCmd.CommandText = $"OPTIMIZE TABLE '{tableName}'";
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Cicm.Database/Schemas/Computer.cs b/Cicm.Database/Schemas/Computer.cs
index 857f7599..a9ae1ccf 100644
--- a/Cicm.Database/Schemas/Computer.cs
+++ b/Cicm.Database/Schemas/Computer.cs
@@ -41,8 +41,6 @@ namespace Cicm.Database.Schemas
public string Cap2;
/// Maximum colors on screen
public int Colors;
- /// Free-form comments
- public string Comment;
/// Manufacturer's company ID
public int Company;
/// Primary CPU
@@ -69,10 +67,10 @@ namespace Cicm.Database.Schemas
public float Mhz2;
/// Model name
public string Model;
- /// ID of MPU
- public int Mpu;
/// Audio channels supported by the MPU
public int MusicChannels;
+ /// ID of MPU
+ public int MusicSynth;
/// Size in kibibytes of program RAM
public int Ram;
/// Resolution in WxH pixels
@@ -82,7 +80,7 @@ namespace Cicm.Database.Schemas
/// Audio channels supported by the DSP
public int SoundChannels;
/// ID of DSP
- public int Spu;
+ public int SoundSynth;
/// Size in kibibytes for video RAM
public int Vram;
/// Introduction date, 0 if unknown, 1000 if prototype
diff --git a/Cicm.Database/Schemas/Console.cs b/Cicm.Database/Schemas/Console.cs
index c3001353..abb2e757 100644
--- a/Cicm.Database/Schemas/Console.cs
+++ b/Cicm.Database/Schemas/Console.cs
@@ -38,8 +38,6 @@ namespace Cicm.Database.Schemas
public int Cap;
/// Maximum colors on screen
public int Colors;
- /// Free-form comments
- public string Comments;
/// Manufacturer's company ID
public int Company;
/// Primary CPU
@@ -56,12 +54,12 @@ namespace Cicm.Database.Schemas
public float Mhz1;
/// Frequency in MHz of secondary CPU
public float Mhz2;
- /// ID of MPU
- public int Mpu;
+ /// Model name
+ public string Model;
/// Audio channels supported by the MPU
public int MusicChannels;
- /// Model name
- public string Name;
+ /// ID of MPU
+ public int MusicSynth;
/// Colors on palette
public int Palette;
/// Size in kibibytes of program RAM
@@ -73,7 +71,7 @@ namespace Cicm.Database.Schemas
/// Audio channels supported by the DSP
public int SoundChannels;
/// ID of DSP
- public int Spu;
+ public int SoundSynth;
/// Size in kibibytes for video RAM
public int Vram;
/// Introduction date, 0 if unknown, 1000 if prototype
diff --git a/Cicm.Database/Schemas/ConsoleCompany.cs b/Cicm.Database/Schemas/ConsoleCompany.cs
deleted file mode 100644
index fcbd899d..00000000
--- a/Cicm.Database/Schemas/ConsoleCompany.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************
-// Canary Islands Computer Museum Website
-// ----------------------------------------------------------------------------
-//
-// Filename : ConsoleCompany.cs
-// Author(s) : Natalia Portillo
-//
-// --[ Description ] ----------------------------------------------------------
-//
-// High level representation of a console manufacturer.
-//
-// --[ 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
-{
- ///
- /// Videogame console manufacturing company
- ///
- public class ConsoleCompany
- {
- /// ID
- public int Id;
- /// Name
- public string Name;
- }
-}
\ No newline at end of file
diff --git a/Cicm.Database/Schemas/Mpu.cs b/Cicm.Database/Schemas/MusicSynth.cs
similarity index 90%
rename from Cicm.Database/Schemas/Mpu.cs
rename to Cicm.Database/Schemas/MusicSynth.cs
index 30e319d9..5864f56e 100644
--- a/Cicm.Database/Schemas/Mpu.cs
+++ b/Cicm.Database/Schemas/MusicSynth.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : Mpu.cs
+// Filename : MusicSynth.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// High level representation of a MPU (Music Processing Unit).
+// High level representation of a music synthetizer.
//
// --[ License ] --------------------------------------------------------------
//
@@ -30,8 +30,8 @@
namespace Cicm.Database.Schemas
{
- /// Music Processing Unit
- public class Mpu
+ /// Music synthetizer
+ public class MusicSynth
{
/// ID
public int Id;
diff --git a/Cicm.Database/Schemas/OwnComputer.cs b/Cicm.Database/Schemas/OwnedComputer.cs
similarity index 98%
rename from Cicm.Database/Schemas/OwnComputer.cs
rename to Cicm.Database/Schemas/OwnedComputer.cs
index 1a4e1f44..3a3a7d5d 100644
--- a/Cicm.Database/Schemas/OwnComputer.cs
+++ b/Cicm.Database/Schemas/OwnedComputer.cs
@@ -31,7 +31,7 @@
namespace Cicm.Database.Schemas
{
/// Owned computer
- public class OwnComputer
+ public class OwnedComputer
{
/// Acquired date
public string Acquired;
diff --git a/Cicm.Database/Schemas/OwnConsole.cs b/Cicm.Database/Schemas/OwnedConsole.cs
similarity index 98%
rename from Cicm.Database/Schemas/OwnConsole.cs
rename to Cicm.Database/Schemas/OwnedConsole.cs
index 86496033..38773e48 100644
--- a/Cicm.Database/Schemas/OwnConsole.cs
+++ b/Cicm.Database/Schemas/OwnedConsole.cs
@@ -31,7 +31,7 @@
namespace Cicm.Database.Schemas
{
/// Owned videogame console
- public class OwnConsole
+ public class OwnedConsole
{
/// Acquired date
public string Acquired;
diff --git a/Cicm.Database/Schemas/Cpu.cs b/Cicm.Database/Schemas/Processor.cs
similarity index 89%
rename from Cicm.Database/Schemas/Cpu.cs
rename to Cicm.Database/Schemas/Processor.cs
index 6d481c6b..e9314527 100644
--- a/Cicm.Database/Schemas/Cpu.cs
+++ b/Cicm.Database/Schemas/Processor.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : Cpu.cs
+// Filename : Processor.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// High level representation of a CPU (Central Processing Unit).
+// High level representation of a processor .
//
// --[ License ] --------------------------------------------------------------
//
@@ -30,8 +30,8 @@
namespace Cicm.Database.Schemas
{
- /// Central Processing Unit
- public class Cpu
+ /// Processor
+ public class Processor
{
/// ID
public int Id;
diff --git a/Cicm.Database/Schemas/Dsp.cs b/Cicm.Database/Schemas/SoundSynth.cs
similarity index 89%
rename from Cicm.Database/Schemas/Dsp.cs
rename to Cicm.Database/Schemas/SoundSynth.cs
index 76f47296..07a5e103 100644
--- a/Cicm.Database/Schemas/Dsp.cs
+++ b/Cicm.Database/Schemas/SoundSynth.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : Dsp.cs
+// Filename : SoundSynth.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// High level representation of a DSP (Digital Sound Processor).
+// High level representation of a sound synthetizer.
//
// --[ License ] --------------------------------------------------------------
//
@@ -30,8 +30,8 @@
namespace Cicm.Database.Schemas
{
- /// Digital Sound Processor
- public class Dsp
+ /// Sound synthetizer
+ public class SoundSynth
{
/// ID
public int Id;
diff --git a/Cicm.Database/Schemas/Sql/V3.cs b/Cicm.Database/Schemas/Sql/V3.cs
new file mode 100644
index 00000000..657380ef
--- /dev/null
+++ b/Cicm.Database/Schemas/Sql/V3.cs
@@ -0,0 +1,231 @@
+/******************************************************************************
+// Canary Islands Computer Museum Website
+// ----------------------------------------------------------------------------
+//
+// Filename : V3.cs
+// Author(s) : Natalia Portillo
+//
+// --[ Description ] ----------------------------------------------------------
+//
+// Contains SQL queries to create the database version 3.
+//
+// --[ 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 V3
+ {
+ public static readonly string Admins = @"CREATE TABLE `admins` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `user` char(50) NOT NULL DEFAULT '',
+ `password` char(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string BrowserTests = @"CREATE TABLE IF NOT EXISTS `browser_tests` (
+ `id` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT,
+ `user_agent` varchar(128) NOT NULL DEFAULT '',
+ `browser` varchar(64) NOT NULL DEFAULT '',
+ `version` varchar(16) NOT NULL DEFAULT '',
+ `os` varchar(32) NOT NULL DEFAULT '',
+ `platform` varchar(8) NOT NULL DEFAULT '',
+ `gif87` tinyint(1) NOT NULL DEFAULT '0',
+ `gif89` tinyint(1) NOT NULL DEFAULT '0',
+ `jpeg` tinyint(1) NOT NULL DEFAULT '0',
+ `png` tinyint(1) NOT NULL DEFAULT '0',
+ `pngt` tinyint(1) NOT NULL DEFAULT '0',
+ `agif` tinyint(1) NOT NULL DEFAULT '0',
+ `table` tinyint(1) NOT NULL DEFAULT '0',
+ `colors` tinyint(1) NOT NULL DEFAULT '0',
+ `js` tinyint(1) NOT NULL DEFAULT '0',
+ `frames` tinyint(1) NOT NULL DEFAULT '0',
+ `flash` tinyint(1) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string CicmDb = @"CREATE TABLE `cicm_db` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `version` int(11) NOT NULL,
+ `updated` datetime DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`)
+ );
+ INSERT INTO cicm_db (version) VALUES ('3');";
+
+ public static readonly string Companies = @"CREATE TABLE IF NOT EXISTS `companies` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` char(128) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string Computers = @"CREATE TABLE IF NOT EXISTS `computers` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `company` int(11) NOT NULL DEFAULT '0',
+ `year` int(11) NOT NULL DEFAULT '0',
+ `model` char(50) NOT NULL DEFAULT '',
+ `cpu1` int(11) NOT NULL DEFAULT '0',
+ `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00',
+ `cpu2` int(11) DEFAULT NULL,
+ `mhz2` decimal(11,2) DEFAULT NULL,
+ `bits` int(11) NOT NULL DEFAULT '0',
+ `ram` int(11) NOT NULL DEFAULT '0',
+ `rom` int(11) NOT NULL DEFAULT '0',
+ `gpu` int(11) NOT NULL DEFAULT '0',
+ `vram` int(11) NOT NULL DEFAULT '0',
+ `colors` int(11) NOT NULL DEFAULT '0',
+ `res` char(10) NOT NULL DEFAULT '',
+ `sound_synth` int(11) NOT NULL DEFAULT '0',
+ `music_synth` int(11) NOT NULL DEFAULT '0',
+ `sound_channels` int(11) NOT NULL DEFAULT '0',
+ `music_channels` int(11) NOT NULL DEFAULT '0',
+ `hdd1` int(11) NOT NULL DEFAULT '0',
+ `hdd2` int(11) DEFAULT NULL,
+ `hdd3` int(11) DEFAULT NULL,
+ `disk1` int(11) NOT NULL DEFAULT '0',
+ `cap1` char(25) NOT NULL DEFAULT '0',
+ `disk2` int(11) DEFAULT NULL,
+ `cap2` char(25) DEFAULT NULL,
+ `comment` char(255) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string Consoles = @"CREATE TABLE IF NOT EXISTS `consoles` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `company` int(11) NOT NULL DEFAULT '0',
+ `model` char(50) NOT NULL DEFAULT '',
+ `year` int(11) NOT NULL DEFAULT '0',
+ `cpu1` int(11) NOT NULL DEFAULT '0',
+ `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00',
+ `cpu2` int(11) DEFAULT NULL,
+ `mhz2` decimal(11,2) DEFAULT NULL,
+ `bits` int(11) NOT NULL DEFAULT '0',
+ `ram` int(11) NOT NULL DEFAULT '0',
+ `rom` int(11) NOT NULL DEFAULT '0',
+ `gpu` int(11) NOT NULL DEFAULT '0',
+ `vram` int(11) NOT NULL DEFAULT '0',
+ `res` char(11) NOT NULL DEFAULT '',
+ `colors` int(11) NOT NULL DEFAULT '0',
+ `palette` int(11) NOT NULL DEFAULT '0',
+ `sound_synth` int(11) NOT NULL DEFAULT '0',
+ `schannels` int(11) NOT NULL DEFAULT '0',
+ `music_channels` int(11) NOT NULL DEFAULT '0',
+ `mchannels` int(11) NOT NULL DEFAULT '0',
+ `format` int(11) NOT NULL DEFAULT '0',
+ `cap` int(11) NOT NULL DEFAULT '0',
+ `comments` char(255) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string DiskFormats = @"CREATE TABLE IF NOT EXISTS `disk_formats` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `description` char(50) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string Forbidden = @"CREATE TABLE IF NOT EXISTS `forbidden` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `browser` char(128) NOT NULL DEFAULT '',
+ `date` char(20) NOT NULL DEFAULT '',
+ `ip` char(16) NOT NULL DEFAULT '',
+ `referer` char(255) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string Gpus = @"CREATE TABLE IF NOT EXISTS `gpus` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` char(128) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string Logs = @"CREATE TABLE IF NOT EXISTS `log` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `browser` char(128) NOT NULL DEFAULT '',
+ `ip` char(16) NOT NULL DEFAULT '',
+ `date` char(20) NOT NULL DEFAULT '',
+ `referer` char(255) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string MoneyDonations = @"CREATE TABLE IF NOT EXISTS `money_donation` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `donator` char(128) NOT NULL DEFAULT '',
+ `quantity` decimal(11,2) NOT NULL DEFAULT '0.00',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string MusicSynths = @"CREATE TABLE IF NOT EXISTS `music_synths` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` char(50) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string News = @"CREATE TABLE IF NOT EXISTS `news` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `date` char(20) NOT NULL DEFAULT '',
+ `type` int(11) NOT NULL DEFAULT '0',
+ `added_id` int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string OwnedComputers = @"CREATE TABLE IF NOT EXISTS `owned_computers` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `db_id` int(11) NOT NULL DEFAULT '0',
+ `date` varchar(20) NOT NULL DEFAULT '',
+ `status` int(11) NOT NULL DEFAULT '0',
+ `trade` int(11) NOT NULL DEFAULT '0',
+ `boxed` int(11) NOT NULL DEFAULT '0',
+ `manuals` int(11) NOT NULL DEFAULT '0',
+ `cpu1` int(11) NOT NULL DEFAULT '0',
+ `mhz1` decimal(10,0) NOT NULL DEFAULT '0',
+ `cpu2` int(11) NOT NULL DEFAULT '0',
+ `mhz2` decimal(10,0) NOT NULL DEFAULT '0',
+ `ram` int(11) NOT NULL DEFAULT '0',
+ `vram` int(11) NOT NULL DEFAULT '0',
+ `rigid` varchar(64) NOT NULL DEFAULT '',
+ `disk1` int(11) NOT NULL DEFAULT '0',
+ `cap1` int(11) NOT NULL DEFAULT '0',
+ `disk2` int(11) NOT NULL DEFAULT '0',
+ `cap2` int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string OwnedConsoles = @"CREATE TABLE IF NOT EXISTS `owned_consoles` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `db_id` int(11) NOT NULL DEFAULT '0',
+ `date` char(20) NOT NULL DEFAULT '',
+ `status` int(11) NOT NULL DEFAULT '0',
+ `trade` int(11) NOT NULL DEFAULT '0',
+ `boxed` int(11) NOT NULL DEFAULT '0',
+ `manuals` int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`)
+ );";
+
+ public static readonly string Processors = @"CREATE TABLE IF NOT EXISTS `processors` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` char(50) NOT NULL DEFAULT '',
+ KEY `id` (`id`)
+ );";
+
+ public static readonly string SoundSynths = @"CREATE TABLE IF NOT EXISTS `sound_synths` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` char(50) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+ );";
+ }
+}
\ No newline at end of file
diff --git a/cicm_web/Controllers/CompanyController.cs b/cicm_web/Controllers/CompanyController.cs
index a188d908..9717f217 100644
--- a/cicm_web/Controllers/CompanyController.cs
+++ b/cicm_web/Controllers/CompanyController.cs
@@ -42,7 +42,7 @@ namespace cicm_web.Controllers
{
hostingEnvironment = env;
}
-
+
public IActionResult ByLetter(char id)
{
// ToUpper()
@@ -52,21 +52,18 @@ namespace cicm_web.Controllers
ViewBag.Letter = id;
- Company[] companies =
- id == '\0' ? Company.GetAllItems() : Company.GetItemsStartingWithLetter(id);
+ Company[] companies = id == '\0' ? Company.GetAllItems() : Company.GetItemsStartingWithLetter(id);
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
return View(companies);
}
-
+
public IActionResult View(int id)
{
- Company company = Company.GetItem(id);
- ViewBag.Company = company;
- Computer[] computers = Computer.GetItemsFromCompany(id);
+ CompanyWithItems company = CompanyWithItems.GetItem(id);
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
- return View(computers);
+ return View(company);
}
}
}
\ No newline at end of file
diff --git a/cicm_web/Controllers/ConsoleCompanyController.cs b/cicm_web/Controllers/ConsoleCompanyController.cs
deleted file mode 100644
index 9cb7150e..00000000
--- a/cicm_web/Controllers/ConsoleCompanyController.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-/******************************************************************************
-// Canary Islands Computer Museum Website
-// ----------------------------------------------------------------------------
-//
-// Filename : ConsoleCompanyController.cs
-// Author(s) : Natalia Portillo
-//
-// --[ Description ] ----------------------------------------------------------
-//
-// Console company controller
-//
-// --[ 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 cicm_web.Models;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Mvc;
-
-namespace cicm_web.Controllers
-{
- public class ConsoleCompanyController : Controller
- {
- readonly IHostingEnvironment hostingEnvironment;
-
- public ConsoleCompanyController(IHostingEnvironment env)
- {
- hostingEnvironment = env;
- }
-
- public IActionResult ByLetter(char id)
- {
- // ToUpper()
- if(id >= 'a' && id <= 'z') id -= (char)32;
- // Check if not letter
- if(id < 'A' || id > 'Z') id = '\0';
-
- ViewBag.Letter = id;
-
- ConsoleCompany[] companies =
- id == '\0' ? ConsoleCompany.GetAllItems() : ConsoleCompany.GetItemsStartingWithLetter(id);
-
- ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
- return View(companies);
- }
-
- public IActionResult View(int id)
- {
- ConsoleCompany company = ConsoleCompany.GetItem(id);
- ViewBag.Company = company;
- Console[] consoles = Console.GetItemsFromCompany(id);
-
- ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
- return View(consoles);
- }
- }
-}
\ No newline at end of file
diff --git a/cicm_web/Models/Company.cs b/cicm_web/Models/Company.cs
index ce69e7a3..12617d8e 100644
--- a/cicm_web/Models/Company.cs
+++ b/cicm_web/Models/Company.cs
@@ -34,6 +34,49 @@ using System.Linq;
namespace cicm_web.Models
{
+ public class CompanyWithItems
+ {
+ public ComputerMini[] Computers;
+ public ConsoleMini[] Consoles;
+ public int Id;
+ public string Name;
+
+ public static CompanyWithItems GetItem(int id)
+ {
+ Cicm.Database.Schemas.Company dbItem = Program.Database?.Operations.GetCompany(id);
+
+ return dbItem == null
+ ? null
+ : new CompanyWithItems
+ {
+ Name = dbItem.Name,
+ Id = dbItem.Id,
+ Computers = ComputerMini.GetItemsWithCompany(id, dbItem.Name),
+ Consoles = ConsoleMini.GetItemsWithCompany(id, dbItem.Name)
+ };
+ }
+
+ public static CompanyWithItems[] GetAllItems()
+ {
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetCompanies(out dbItems);
+ if(result == null || result.Value == false || dbItems == null) return null;
+
+ return dbItems.Select(t => new CompanyWithItems {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
+ }
+
+ public static CompanyWithItems[] GetItemsStartingWithLetter(char letter)
+ {
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetCompanies(out dbItems);
+ if(result == null || result.Value == false || dbItems == null) return null;
+
+ return dbItems
+ .Where(t => t.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
+ .Select(t => new CompanyWithItems {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
+ }
+ }
+
public class Company
{
public int Id;
@@ -42,6 +85,7 @@ namespace cicm_web.Models
public static Company GetItem(int id)
{
Cicm.Database.Schemas.Company dbItem = Program.Database?.Operations.GetCompany(id);
+
return dbItem == null ? null : new Company {Name = dbItem.Name, Id = dbItem.Id};
}
diff --git a/cicm_web/Models/Computer.cs b/cicm_web/Models/Computer.cs
index 75f11c89..5a0c01b0 100644
--- a/cicm_web/Models/Computer.cs
+++ b/cicm_web/Models/Computer.cs
@@ -40,10 +40,9 @@ namespace cicm_web.Models
public string Cap1;
public string Cap2;
public int Colors;
- public string Comment;
public Company Company;
- public Cpu Cpu1;
- public Cpu Cpu2;
+ public Processor Cpu1;
+ public Processor Cpu2;
public DiskFormat Disk1;
public DiskFormat Disk2;
public Gpu Gpu;
@@ -54,13 +53,13 @@ namespace cicm_web.Models
public float Mhz1;
public float Mhz2;
public string Model;
- public Mpu Mpu;
public int MusicChannels;
+ public MusicSynth MusicSynth;
public int Ram;
public string Resolution;
public int Rom;
public int SoundChannels;
- public Dsp Spu;
+ public SoundSynth SoundSynth;
public int Vram;
public int Year;
@@ -97,7 +96,6 @@ namespace cicm_web.Models
{
Bits = dbItem.Bits,
Colors = dbItem.Colors,
- Comment = dbItem.Comment,
Company = Company.GetItem(dbItem.Company),
Gpu = Gpu.GetItem(dbItem.Gpu),
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
@@ -126,25 +124,25 @@ namespace cicm_web.Models
if(dbItem.Cpu1 > 0)
{
- item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
+ item.Cpu1 = Processor.GetItem(dbItem.Cpu1);
item.Mhz1 = dbItem.Mhz1;
}
if(dbItem.Cpu2 > 0)
{
- item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
+ item.Cpu2 = Processor.GetItem(dbItem.Cpu2);
item.Mhz2 = dbItem.Mhz2;
}
- if(dbItem.Mpu > 0)
+ if(dbItem.MusicSynth > 0)
{
- item.Mpu = Mpu.GetItem(dbItem.Mpu);
+ item.MusicSynth = MusicSynth.GetItem(dbItem.MusicSynth);
item.MusicChannels = dbItem.MusicChannels;
}
- if(dbItem.Spu > 0)
+ if(dbItem.SoundSynth > 0)
{
- item.Spu = Dsp.GetItem(dbItem.Spu);
+ item.SoundSynth = SoundSynth.GetItem(dbItem.SoundSynth);
item.SoundChannels = dbItem.SoundChannels;
}
@@ -199,6 +197,32 @@ namespace cicm_web.Models
return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
}
+ public static ComputerMini[] GetItemsWithCompany(int id, string companyName)
+ {
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetComputers(out dbItems);
+ if(result == null || result.Value == false || dbItems == null) return null;
+
+ // TODO: Company chosen by DB
+ return dbItems.Where(t => t.Company == id)
+ .Select(t => new ComputerMini
+ {
+ Company = new Company {Id = id, Name = companyName},
+ Id = t.Id,
+ Model = t.Model
+ }).OrderBy(t => t.Model).ToArray();
+ }
+
+ public static ComputerMini[] GetItemsFromCompany(int id)
+ {
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetComputers(out dbItems);
+ 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();
+ }
+
static ComputerMini TransformItem(Cicm.Database.Schemas.Computer dbItem)
{
return new ComputerMini {Company = Company.GetItem(dbItem.Company), Id = dbItem.Id, Model = dbItem.Model};
diff --git a/cicm_web/Models/Console.cs b/cicm_web/Models/Console.cs
index 389fa46a..d3f76694 100644
--- a/cicm_web/Models/Console.cs
+++ b/cicm_web/Models/Console.cs
@@ -36,29 +36,28 @@ namespace cicm_web.Models
{
public class Console
{
- public int Bits;
- public int Cap;
- public int Colors;
- public string Comments;
- public ConsoleCompany Company;
- public Cpu Cpu1;
- public Cpu Cpu2;
- public DiskFormat Format;
- public Gpu Gpu;
- public int Id;
- public float Mhz1;
- public float Mhz2;
- public Mpu Mpu;
- public int MusicChannels;
- public string Name;
- public int Palette;
- public int Ram;
- public string Resolution;
- public int Rom;
- public int SoundChannels;
- public Dsp Spu;
- public int Vram;
- public int Year;
+ public int Bits;
+ public int Cap;
+ public int Colors;
+ public Company Company;
+ public Processor Cpu1;
+ public Processor Cpu2;
+ public DiskFormat Format;
+ public Gpu Gpu;
+ public int Id;
+ public float Mhz1;
+ public float Mhz2;
+ public string Model;
+ public int MusicChannels;
+ public MusicSynth MusicSynth;
+ public int Palette;
+ public int Ram;
+ public string Resolution;
+ public int Rom;
+ public int SoundChannels;
+ public SoundSynth SoundSynth;
+ public int Vram;
+ public int Year;
public static Console[] GetAllItems()
{
@@ -72,11 +71,11 @@ namespace cicm_web.Models
public static Console[] GetItemsFromCompany(int id)
{
List dbItems = null;
- bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
+ bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
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.Name).ToArray();
+ return dbItems.Where(t => t.Company == id).Select(TransformItem).OrderBy(t => t.Model).ToArray();
}
public static Console GetItem(int id)
@@ -91,11 +90,10 @@ namespace cicm_web.Models
{
Bits = dbItem.Bits,
Colors = dbItem.Colors,
- Comments = dbItem.Comments,
- Company = ConsoleCompany.GetItem(dbItem.Company),
+ Company = Company.GetItem(dbItem.Company),
Gpu = Gpu.GetItem(dbItem.Gpu),
Id = dbItem.Id,
- Name = dbItem.Name,
+ Model = dbItem.Model,
Palette = dbItem.Palette,
Ram = dbItem.Ram,
Resolution = dbItem.Resolution,
@@ -112,25 +110,25 @@ namespace cicm_web.Models
if(dbItem.Cpu1 > 0)
{
- item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
+ item.Cpu1 = Processor.GetItem(dbItem.Cpu1);
item.Mhz1 = dbItem.Mhz1;
}
if(dbItem.Cpu2 > 0)
{
- item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
+ item.Cpu2 = Processor.GetItem(dbItem.Cpu2);
item.Mhz2 = dbItem.Mhz2;
}
- if(dbItem.Mpu > 0)
+ if(dbItem.MusicSynth > 0)
{
- item.Mpu = Mpu.GetItem(dbItem.Mpu);
+ item.MusicSynth = MusicSynth.GetItem(dbItem.MusicSynth);
item.MusicChannels = dbItem.MusicChannels;
}
- if(dbItem.Spu > 0)
+ if(dbItem.SoundSynth > 0)
{
- item.Spu = Dsp.GetItem(dbItem.Spu);
+ item.SoundSynth = SoundSynth.GetItem(dbItem.SoundSynth);
item.SoundChannels = dbItem.SoundChannels;
}
@@ -140,41 +138,41 @@ namespace cicm_web.Models
public class ConsoleMini
{
- public ConsoleCompany Company;
+ public Company Company;
public int Id;
- public string Name;
+ public string Model;
public static ConsoleMini[] GetAllItems()
{
List dbItems = null;
- bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
+ bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List items = new List();
foreach(Cicm.Database.Schemas.Console dbItem in dbItems) items.Add(TransformItem(dbItem));
- return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
+ return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
}
public static ConsoleMini[] GetItemsStartingWithLetter(char letter)
{
List dbItems = null;
- bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
+ bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List items = new List();
foreach(Cicm.Database.Schemas.Console dbItem in dbItems)
- if(dbItem.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
+ if(dbItem.Model.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
items.Add(TransformItem(dbItem));
- return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
+ return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
}
public static ConsoleMini[] GetItemsFromYear(int year)
{
List dbItems = null;
- bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
+ bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List items = new List();
@@ -182,12 +180,38 @@ namespace cicm_web.Models
if(dbItem.Year == year)
items.Add(TransformItem(dbItem));
- return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Name).ToArray();
+ return items.OrderBy(t => t.Company.Name).ThenBy(t => t.Model).ToArray();
+ }
+
+ public static ConsoleMini[] GetItemsWithCompany(int id, string companyName)
+ {
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
+ if(result == null || result.Value == false || dbItems == null) return null;
+
+ // TODO: Company chosen by DB
+ return dbItems.Where(t => t.Company == id)
+ .Select(t => new ConsoleMini
+ {
+ Company = new Company {Id = id, Name = companyName},
+ Id = t.Id,
+ Model = t.Model
+ }).OrderBy(t => t.Model).ToArray();
+ }
+
+ public static ConsoleMini[] GetItemsFromCompany(int id)
+ {
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetConsoles(out dbItems);
+ 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();
}
static ConsoleMini TransformItem(Cicm.Database.Schemas.Console dbItem)
{
- return new ConsoleMini {Company = ConsoleCompany.GetItem(dbItem.Company), Id = dbItem.Id, Name = dbItem.Name};
+ return new ConsoleMini {Company = Company.GetItem(dbItem.Company), Id = dbItem.Id, Model = dbItem.Model};
}
}
}
\ No newline at end of file
diff --git a/cicm_web/Models/ConsoleCompany.cs b/cicm_web/Models/ConsoleCompany.cs
deleted file mode 100644
index f99a252d..00000000
--- a/cicm_web/Models/ConsoleCompany.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-/******************************************************************************
-// Canary Islands Computer Museum Website
-// ----------------------------------------------------------------------------
-//
-// Filename : ConsoleCompany.cs
-// Author(s) : Natalia Portillo
-//
-// --[ Description ] ----------------------------------------------------------
-//
-// Videogame console company 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;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace cicm_web.Models
-{
- public class ConsoleCompany
- {
- public int Id;
- public string Name;
-
- public static ConsoleCompany GetItem(int id)
- {
- Cicm.Database.Schemas.ConsoleCompany dbItem = Program.Database?.Operations.GetConsoleCompany(id);
- return dbItem == null ? null : new ConsoleCompany {Name = dbItem.Name, Id = dbItem.Id};
- }
-
- public static ConsoleCompany[] GetAllItems()
- {
- List dbItems = null;
- bool? result =
- Program.Database?.Operations.GetConsoleCompanies(out dbItems);
- if(result == null || result.Value == false || dbItems == null) return null;
-
- return dbItems.Select(t => new ConsoleCompany {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
- }
-
- public static ConsoleCompany[] GetItemsStartingWithLetter(char letter)
- {
- List dbItems = null;
- bool? result = Program.Database?.Operations.GetConsoleCompanies(out dbItems);
- if(result == null || result.Value == false || dbItems == null) return null;
-
- return dbItems
- .Where(t => t.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
- .Select(t => new ConsoleCompany {Id = t.Id, Name = t.Name}).OrderBy(t => t.Name).ToArray();
- }
- }
-}
\ No newline at end of file
diff --git a/cicm_web/Models/Dsp.cs b/cicm_web/Models/MusicSynth.cs
similarity index 67%
rename from cicm_web/Models/Dsp.cs
rename to cicm_web/Models/MusicSynth.cs
index 465ee1ca..a3229487 100644
--- a/cicm_web/Models/Dsp.cs
+++ b/cicm_web/Models/MusicSynth.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : Dsp.cs
+// Filename : MusicSynth.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// Digital Sound Processor model
+// Music Synthetizer model
//
// --[ License ] --------------------------------------------------------------
//
@@ -32,27 +32,27 @@ using System.Collections.Generic;
namespace cicm_web.Models
{
- public class Dsp
+ public class MusicSynth
{
public int Id;
public string Name;
- public static Dsp GetItem(int id)
+ public static MusicSynth GetItem(int id)
{
- Cicm.Database.Schemas.Dsp dbItem = Program.Database?.Operations.GetDsp(id);
- return dbItem == null ? null : new Dsp {Name = dbItem.Name, Id = dbItem.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 Dsp[] GetAllItems()
+ public static MusicSynth[] GetAllItems()
{
- List dbItems = null;
- bool? result = Program.Database?.Operations.GetDsps(out dbItems);
+ 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();
+ List items = new List();
- foreach(Cicm.Database.Schemas.Dsp dbItem in dbItems)
- items.Add(new Dsp {Id = dbItem.Id, Name = dbItem.Name});
+ foreach(Cicm.Database.Schemas.MusicSynth dbItem in dbItems)
+ items.Add(new MusicSynth {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
diff --git a/cicm_web/Models/News.cs b/cicm_web/Models/News.cs
index f78ead34..23f34e8f 100644
--- a/cicm_web/Models/News.cs
+++ b/cicm_web/Models/News.cs
@@ -76,9 +76,9 @@ namespace cicm_web.Models
string targetView;
string subtext;
Computer computer;
- OwnComputer owncomputer;
+ OwnedComputer owncomputer;
Console console;
- OwnConsole ownconsole;
+ OwnedConsole ownconsole;
switch(dbItem.Type)
{
@@ -92,51 +92,51 @@ namespace cicm_web.Models
case NewsType.NewConsoleInDb:
text = "New videoconsole added to the database.";
imageUrl = "assets/photos/consoles/";
- targetView = "console";
+ targetView = "Console";
console = Console.GetItem(dbItem.AffectedId);
- subtext = $"{console.Company.Name} - {console.Name}";
+ subtext = $"{console.Company.Name} - {console.Model}";
break;
case NewsType.NewComputerInCollection:
text = "New computer added to the museum's collection.";
imageUrl = "assets/photos/computers/";
- targetView = "collection_computer";
- owncomputer = OwnComputer.GetItem(dbItem.AffectedId);
+ targetView = "CollectionComputer";
+ owncomputer = OwnedComputer.GetItem(dbItem.AffectedId);
subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Model}";
break;
case NewsType.NewConsoleInCollection:
text = "New videoconsole added to the museum's collection.";
imageUrl = "assets/photos/consoles/";
- targetView = "collection_console";
- ownconsole = OwnConsole.GetItem(dbItem.AffectedId);
- subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Name}";
+ targetView = "CollectionConsole";
+ ownconsole = OwnedConsole.GetItem(dbItem.AffectedId);
+ subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Model}";
break;
case NewsType.UpdatedComputerInDb:
text = "Updated computer from the database.";
imageUrl = "assets/photos/computers/";
- targetView = "computer";
+ targetView = "Computer";
computer = Computer.GetItem(dbItem.AffectedId);
subtext = $"{computer.Company.Name} - {computer.Model}";
break;
case NewsType.UpdatedConsoleInDb:
text = "Updated videoconsole from the database.";
imageUrl = "assets/photos/consoles/";
- targetView = "console";
+ targetView = "Console";
console = Console.GetItem(dbItem.AffectedId);
- subtext = $"{console.Company.Name} - {console.Name}";
+ subtext = $"{console.Company.Name} - {console.Model}";
break;
case NewsType.UpdatedComputerInCollection:
text = "Updated computer from museum's collection.";
imageUrl = "assets/photos/computers/";
- targetView = "collection_computer";
- owncomputer = OwnComputer.GetItem(dbItem.AffectedId);
+ targetView = "CollectionComputer";
+ owncomputer = OwnedComputer.GetItem(dbItem.AffectedId);
subtext = $"{owncomputer.Computer.Company.Name} - {owncomputer.Computer.Model}";
break;
case NewsType.UpdatedConsoleInCollection:
text = "Updated videoconsole from museum's collection.";
imageUrl = "assets/photos/consoles/";
- targetView = "collection_console";
- ownconsole = OwnConsole.GetItem(dbItem.AffectedId);
- subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Name}";
+ targetView = "CollectionConsole";
+ ownconsole = OwnedConsole.GetItem(dbItem.AffectedId);
+ subtext = $"{ownconsole.Console.Company.Name} - {ownconsole.Console.Model}";
break;
case NewsType.NewMoneyDonation:
text = "New money donation.";
diff --git a/cicm_web/Models/OwnComputer.cs b/cicm_web/Models/OwnedComputer.cs
similarity index 81%
rename from cicm_web/Models/OwnComputer.cs
rename to cicm_web/Models/OwnedComputer.cs
index 0f058376..c3b5a341 100644
--- a/cicm_web/Models/OwnComputer.cs
+++ b/cicm_web/Models/OwnedComputer.cs
@@ -2,7 +2,7 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : OwnComputer.cs
+// Filename : OwnedComputer.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
@@ -36,15 +36,15 @@ using Cicm.Database.Schemas;
namespace cicm_web.Models
{
- public class OwnComputer
+ public class OwnedComputer
{
public DateTime Acquired;
public bool Boxed;
public int Cap1;
public int Cap2;
public Computer Computer;
- public Cpu Cpu1;
- public Cpu Cpu2;
+ public Processor Cpu1;
+ public Processor Cpu2;
public DiskFormat Disk1;
public DiskFormat Disk2;
public int Id;
@@ -57,26 +57,27 @@ namespace cicm_web.Models
public bool Trade;
public int Vram;
- public static OwnComputer[] GetAllItems()
+ public static OwnedComputer[] GetAllItems()
{
- List dbItems = null;
- bool? result = Program.Database?.Operations.GetOwnComputers(out dbItems);
+ List dbItems = null;
+ bool? result =
+ Program.Database?.Operations.GetOwnedComputers(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
- return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnComputer[];
+ return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnedComputer[];
}
- public static OwnComputer GetItem(int id)
+ public static OwnedComputer GetItem(int id)
{
- Cicm.Database.Schemas.OwnComputer dbItem = Program.Database?.Operations.GetOwnComputer(id);
+ Cicm.Database.Schemas.OwnedComputer dbItem = Program.Database?.Operations.GetOwnedComputer(id);
return dbItem == null ? null : TransformItem(dbItem);
}
- static OwnComputer TransformItem(Cicm.Database.Schemas.OwnComputer dbItem)
+ static OwnedComputer TransformItem(Cicm.Database.Schemas.OwnedComputer dbItem)
{
Computer computer = Computer.GetItem(dbItem.ComputerId);
- OwnComputer item = new OwnComputer
+ OwnedComputer item = new OwnedComputer
{
Acquired = DateTime.ParseExact(dbItem.Acquired, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture),
Boxed = dbItem.Boxed,
@@ -104,13 +105,13 @@ namespace cicm_web.Models
if(dbItem.Cpu1 > 0)
{
- item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
+ item.Cpu1 = Processor.GetItem(dbItem.Cpu1);
item.Mhz1 = dbItem.Mhz1;
}
if(dbItem.Cpu2 > 0)
{
- item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
+ item.Cpu2 = Processor.GetItem(dbItem.Cpu2);
item.Mhz2 = dbItem.Mhz2;
}
diff --git a/cicm_web/Models/OwnConsole.cs b/cicm_web/Models/OwnedConsole.cs
similarity index 81%
rename from cicm_web/Models/OwnConsole.cs
rename to cicm_web/Models/OwnedConsole.cs
index c476dc27..5a02ca64 100644
--- a/cicm_web/Models/OwnConsole.cs
+++ b/cicm_web/Models/OwnedConsole.cs
@@ -2,7 +2,7 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : OwnConsole.cs
+// Filename : OwnedConsole.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
@@ -36,7 +36,7 @@ using Cicm.Database.Schemas;
namespace cicm_web.Models
{
- public class OwnConsole
+ public class OwnedConsole
{
public DateTime Acquired;
public bool Boxed;
@@ -46,28 +46,29 @@ namespace cicm_web.Models
public StatusType Status;
public bool Trade;
- public static OwnConsole[] GetAllItems()
+ public static OwnedConsole[] GetAllItems()
{
- List dbItems = null;
- bool? result = Program.Database?.Operations.GetOwnConsoles(out dbItems);
+ List dbItems = null;
+ bool? result =
+ Program.Database?.Operations.GetOwnedConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
- return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnConsole[];
+ return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnedConsole[];
}
- public static OwnConsole GetItem(int id)
+ public static OwnedConsole GetItem(int id)
{
- Cicm.Database.Schemas.OwnConsole dbItem = Program.Database?.Operations.GetOwnConsole(id);
+ Cicm.Database.Schemas.OwnedConsole dbItem = Program.Database?.Operations.GetOwnedConsole(id);
return dbItem == null ? null : TransformItem(dbItem);
}
- static OwnConsole TransformItem(Cicm.Database.Schemas.OwnConsole dbItem)
+ static OwnedConsole TransformItem(Cicm.Database.Schemas.OwnedConsole dbItem)
{
Console console = Console.GetItem(dbItem.ConsoleId);
return console == null
? null
- : new OwnConsole
+ : new OwnedConsole
{
Acquired =
DateTime.ParseExact(dbItem.Acquired, "yyyy/MM/dd HH:mm:ss",
diff --git a/cicm_web/Models/Cpu.cs b/cicm_web/Models/Processor.cs
similarity index 68%
rename from cicm_web/Models/Cpu.cs
rename to cicm_web/Models/Processor.cs
index 40339776..ad64dc88 100644
--- a/cicm_web/Models/Cpu.cs
+++ b/cicm_web/Models/Processor.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : Cpu.cs
+// Filename : Processor.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// Central Processing Unit model
+// Processor model
//
// --[ License ] --------------------------------------------------------------
//
@@ -32,27 +32,27 @@ using System.Collections.Generic;
namespace cicm_web.Models
{
- public class Cpu
+ public class Processor
{
public int Id;
public string Name;
- public static Cpu GetItem(int id)
+ public static Processor GetItem(int id)
{
- Cicm.Database.Schemas.Cpu dbItem = Program.Database?.Operations.GetCpu(id);
- return dbItem == null ? null : new Cpu {Name = dbItem.Name, Id = dbItem.Id};
+ Cicm.Database.Schemas.Processor dbItem = Program.Database?.Operations.GetProcessor(id);
+ return dbItem == null ? null : new Processor {Name = dbItem.Name, Id = dbItem.Id};
}
- public static Cpu[] GetAllItems()
+ public static Processor[] GetAllItems()
{
- List dbItems = null;
- bool? result = Program.Database?.Operations.GetCpus(out dbItems);
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetProcessors(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
- List items = new List();
+ List items = new List();
- foreach(Cicm.Database.Schemas.Cpu dbItem in dbItems)
- items.Add(new Cpu {Id = dbItem.Id, Name = dbItem.Name});
+ foreach(Cicm.Database.Schemas.Processor dbItem in dbItems)
+ items.Add(new Processor {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
diff --git a/cicm_web/Models/Mpu.cs b/cicm_web/Models/SoundSynth.cs
similarity index 67%
rename from cicm_web/Models/Mpu.cs
rename to cicm_web/Models/SoundSynth.cs
index e01a4122..31ff84a3 100644
--- a/cicm_web/Models/Mpu.cs
+++ b/cicm_web/Models/SoundSynth.cs
@@ -2,12 +2,12 @@
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
-// Filename : Mpu.cs
+// Filename : SoundSynth.cs
// Author(s) : Natalia Portillo
//
// --[ Description ] ----------------------------------------------------------
//
-// Music Processing Unit model
+// Digital Sound Synthetizer model
//
// --[ License ] --------------------------------------------------------------
//
@@ -32,27 +32,27 @@ using System.Collections.Generic;
namespace cicm_web.Models
{
- public class Mpu
+ public class SoundSynth
{
public int Id;
public string Name;
- public static Mpu GetItem(int id)
+ public static SoundSynth GetItem(int id)
{
- Cicm.Database.Schemas.Mpu dbItem = Program.Database?.Operations.GetMpu(id);
- return dbItem == null ? null : new Mpu {Name = dbItem.Name, Id = dbItem.Id};
+ Cicm.Database.Schemas.SoundSynth dbItem = Program.Database?.Operations.GetSoundSynth(id);
+ return dbItem == null ? null : new SoundSynth {Name = dbItem.Name, Id = dbItem.Id};
}
- public static Mpu[] GetAllItems()
+ public static SoundSynth[] GetAllItems()
{
- List dbItems = null;
- bool? result = Program.Database?.Operations.GetMpus(out dbItems);
+ List dbItems = null;
+ bool? result = Program.Database?.Operations.GetSoundSynths(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
- List items = new List();
+ List items = new List();
- foreach(Cicm.Database.Schemas.Mpu dbItem in dbItems)
- items.Add(new Mpu {Id = dbItem.Id, Name = dbItem.Name});
+ foreach(Cicm.Database.Schemas.SoundSynth dbItem in dbItems)
+ items.Add(new SoundSynth {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
diff --git a/cicm_web/Views/Company/ByLetter.cshtml b/cicm_web/Views/Company/ByLetter.cshtml
index 323dad91..a7586a84 100644
--- a/cicm_web/Views/Company/ByLetter.cshtml
+++ b/cicm_web/Views/Company/ByLetter.cshtml
@@ -48,21 +48,21 @@
@Model.Count() companies found in the database.
@foreach(Company company in Model)
{
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", company.Id + ".gif")))
+ if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.Id + ".gif")))
{
-
}
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", company.Id + ".jpg")))
+ if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.Id + ".jpg")))
{
-
}
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", company.Id + ".png")))
+ if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", company.Id + ".png")))
{
-
}
diff --git a/cicm_web/Views/Company/View.cshtml b/cicm_web/Views/Company/View.cshtml
index 9510336f..a8e84996 100644
--- a/cicm_web/Views/Company/View.cshtml
+++ b/cicm_web/Views/Company/View.cshtml
@@ -32,49 +32,72 @@
ViewData["Title"] = "Companies";
}
@using System.IO
-@model IEnumerable
+@model CompanyWithItems
Search results:
- @if(ViewBag.Company != null)
+ @if(Model != null)
{
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", ViewBag.Company.Id + ".gif")))
+ if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".gif")))
{
-
}
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", ViewBag.Company.Id + ".jpg")))
+ if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".jpg")))
{
-
}
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", ViewBag.Company.Id + ".png")))
+ if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Id + ".png")))
{
-
}
- @ViewBag.Company.Name
+ @Model.Name
- }
- @if(Model.Any())
- {
-
- @Model.Count() computers found in the database.
- @foreach(Computer computer in Model)
- {
-
- @computer.Model
-
- }
-
+ if(Model.Computers.Any())
+ {
+
+ @Model.Computers.Count() computers found in the database.
+ @foreach(ComputerMini computer in Model.Computers)
+ {
+
+ @computer.Model
+
+ }
+
+ }
+ else
+ {
+ There are no computers found in the database that belong to that company.
+ }
+
+ if(Model.Consoles.Any())
+ {
+
+ @Model.Consoles.Count() videoconsoles found in the database.
+ @foreach(ConsoleMini console in Model.Consoles)
+ {
+
+ @console.Model
+
+ }
+
+ }
+ else
+ {
+ There are no videoconsoles found in the database that belong to that company.
+ }
}
else
{
- There are no computers found in the database that belong to that company.
+ Company not found!
}
\ No newline at end of file
diff --git a/cicm_web/Views/Computer/View.cshtml b/cicm_web/Views/Computer/View.cshtml
index 5eaf2dd1..25652b42 100644
--- a/cicm_web/Views/Computer/View.cshtml
+++ b/cicm_web/Views/Computer/View.cshtml
@@ -34,21 +34,21 @@
@using System.IO
@model Computer
-@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", Model.Company.Id + ".gif")))
+@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".gif")))
{
-
}
-@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", Model.Company.Id + ".jpg")))
+@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".jpg")))
{
-
}
-@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/computers", Model.Company.Id + ".png")))
+@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".png")))
{
-
}
@@ -294,17 +294,17 @@
Sound processor
- @if(Model.Spu.Id > 1)
+ @if(Model.SoundSynth.Id > 1)
{
- if(Model.Spu.Id > 2)
+ if(Model.SoundSynth.Id > 2)
{
if(Model.SoundChannels > 0)
{
- @Model.Spu.Name (@Model.SoundChannels channels) |
+ @Model.SoundSynth.Name (@Model.SoundChannels channels) |
}
else
{
- @Model.Spu.Name |
+ @Model.SoundSynth.Name |
}
}
else
@@ -321,17 +321,17 @@
Music synthetizer
- @if(Model.Mpu.Id > 1)
+ @if(Model.MusicSynth.Id > 1)
{
- if(Model.Mpu.Id > 2)
+ if(Model.MusicSynth.Id > 2)
{
if(Model.MusicChannels > 0)
{
- @Model.Mpu.Name (@Model.MusicChannels channels) |
+ @Model.MusicSynth.Name (@Model.MusicChannels channels) |
}
else
{
- @Model.Mpu.Name |
+ @Model.MusicSynth.Name |
}
}
else
diff --git a/cicm_web/Views/Console/ByLetter.cshtml b/cicm_web/Views/Console/ByLetter.cshtml
index 6ab1c149..e3859c40 100644
--- a/cicm_web/Views/Console/ByLetter.cshtml
+++ b/cicm_web/Views/Console/ByLetter.cshtml
@@ -1,5 +1,5 @@
@{
-/******************************************************************************
+ /******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
@@ -35,23 +35,29 @@
@model IEnumerable
Search results:
-
+
@if(ViewBag.Letter != '\0')
{
- @ViewBag.Letter
+ @ViewBag.Letter
+
}
@if(Model.Any())
{
-
@Model.Count() computers found in the database.
- @foreach(ConsoleMini console in @Model)
- {
- @console.Company.Name @console.Name
- }
+
+ @Model.Count() computers found in the database.
+ @foreach(ConsoleMini console in Model)
+ {
+
+ @console.Company.Name @console.Model
+
+ }
}
else
{
There are no videoconsoles found in the database that start with this letter.
}
-
+
\ No newline at end of file
diff --git a/cicm_web/Views/Console/ByYear.cshtml b/cicm_web/Views/Console/ByYear.cshtml
index 3ead0ebd..dd89f243 100644
--- a/cicm_web/Views/Console/ByYear.cshtml
+++ b/cicm_web/Views/Console/ByYear.cshtml
@@ -47,7 +47,7 @@
- @console.Company.Name @console.Name
+ @console.Company.Name @console.Model
}
diff --git a/cicm_web/Views/Console/Index.cshtml b/cicm_web/Views/Console/Index.cshtml
index 98fae57c..fe1fbd46 100644
--- a/cicm_web/Views/Console/Index.cshtml
+++ b/cicm_web/Views/Console/Index.cshtml
@@ -44,140 +44,140 @@
Search by companies
Q
W
E
R
T
Y
U
I
O
P
A
S
D
F
G
H
J
K
L
Z
X
C
V
B
N
M
+ asp-controller=Company>
All companies
diff --git a/cicm_web/Views/Console/View.cshtml b/cicm_web/Views/Console/View.cshtml
index 7b35b983..f921219f 100644
--- a/cicm_web/Views/Console/View.cshtml
+++ b/cicm_web/Views/Console/View.cshtml
@@ -34,21 +34,21 @@
@using System.IO
@model cicm_web.Models.Console
-@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".gif")))
+@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".gif")))
{
-
}
-@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".jpg")))
+@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".jpg")))
{
-
}
-@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", Model.Company.Id + ".png")))
+@if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.Company.Id + ".png")))
{
-
}
@@ -59,7 +59,7 @@
}
-@Model.Company.Name @Model.Name
+@Model.Company.Name @Model.Model
@if(Model.Year != 1000)
@@ -300,17 +300,17 @@
Sound processor
- @if(Model.Spu.Id > 1)
+ @if(Model.SoundSynth.Id > 1)
{
- if(Model.Spu.Id > 2)
+ if(Model.SoundSynth.Id > 2)
{
if(Model.SoundChannels > 0)
{
- | @Model.Spu.Name (@Model.SoundChannels channels) |
+ @Model.SoundSynth.Name (@Model.SoundChannels channels) |
}
else
{
- @Model.Spu.Name |
+ @Model.SoundSynth.Name |
}
}
else
@@ -327,17 +327,17 @@
Music synthetizer
- @if(Model.Mpu.Id > 1)
+ @if(Model.MusicSynth.Id > 1)
{
- if(Model.Mpu.Id > 2)
+ if(Model.MusicSynth.Id > 2)
{
if(Model.MusicChannels > 0)
{
- @Model.Mpu.Name (@Model.MusicChannels channels) |
+ @Model.MusicSynth.Name (@Model.MusicChannels channels) |
}
else
{
- @Model.Mpu.Name |
+ @Model.MusicSynth.Name |
}
}
else
diff --git a/cicm_web/Views/ConsoleCompany/ByLetter.cshtml b/cicm_web/Views/ConsoleCompany/ByLetter.cshtml
deleted file mode 100644
index d68db188..00000000
--- a/cicm_web/Views/ConsoleCompany/ByLetter.cshtml
+++ /dev/null
@@ -1,81 +0,0 @@
-@{
- /******************************************************************************
-// Canary Islands Computer Museum Website
-// ----------------------------------------------------------------------------
-//
-// Filename : ByLetter.cshtml
-// Author(s) : Natalia Portillo
-//
-// --[ Description ] ----------------------------------------------------------
-//
-// Lists companies by letter (or all)
-//
-// --[ 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
-*******************************************************************************/
-
- ViewData["Title"] = "Console companies";
-}
-@using System.IO
-@model IEnumerable
-
-Search results:
-
- @if(ViewBag.Letter != '\0')
- {
- @ViewBag.Letter
-
- }
-
- @if(Model.Any())
- {
-
- @Model.Count() companies found in the database.
- @foreach(ConsoleCompany company in Model)
- {
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".gif")))
- {
-
- }
-
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".jpg")))
- {
-
- }
-
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", company.Id + ".png")))
- {
-
- }
-
-
- @company.Name
-
- }
-
- }
- else
- {
- There are no console companies found in the database that start with this letter.
- }
-
\ No newline at end of file
diff --git a/cicm_web/Views/ConsoleCompany/View.cshtml b/cicm_web/Views/ConsoleCompany/View.cshtml
deleted file mode 100644
index cba07ebe..00000000
--- a/cicm_web/Views/ConsoleCompany/View.cshtml
+++ /dev/null
@@ -1,80 +0,0 @@
-@{
- /******************************************************************************
-// Canary Islands Computer Museum Website
-// ----------------------------------------------------------------------------
-//
-// Filename : ByLetter.cshtml
-// Author(s) : Natalia Portillo
-//
-// --[ Description ] ----------------------------------------------------------
-//
-// Lists computers by company
-//
-// --[ 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
-*******************************************************************************/
-
- ViewData["Title"] = "Companies";
-}
-@using System.IO
-@model IEnumerable
-
-Search results:
-
- @if(ViewBag.Company != null)
- {
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".gif")))
- {
-
- }
-
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".jpg")))
- {
-
- }
-
- if(File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos/consoles", ViewBag.Company.Id + ".png")))
- {
-
- }
- @ViewBag.Company.Name
-
- }
-
- @if(Model.Any())
- {
-
- @Model.Count() computers found in the database.
- @foreach(cicm_web.Models.Console console in Model)
- {
-
- @console.Name
-
- }
-
- }
- else
- {
- There are no videoconsoles found in the database that belong to that company.
- }
-
\ No newline at end of file
diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj
index b788cf6b..0c64e25c 100644
--- a/cicm_web/cicm_web.csproj
+++ b/cicm_web/cicm_web.csproj
@@ -2,7 +2,7 @@
netcoreapp2.0
- 3.0.99.86
+ 3.0.99.100
Canary Islands Computer Museum
Copyright © 2003-2018 Natalia Portillo
Canary Islands Computer Museum Website