mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Update DB to version 9 (company descriptions).
This commit is contained in:
@@ -394,6 +394,10 @@ namespace Cicm.Database
|
|||||||
entry.LastLogo = entry.Logos[0];
|
entry.LastLogo = entry.Logos[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GetCompanyDescriptionsByCompany(out List<CompanyDescription> descriptions, entry.Id))
|
||||||
|
if(descriptions != null && descriptions.Count > 0)
|
||||||
|
entry.Description = descriptions[0].Text;
|
||||||
|
|
||||||
entries.Add(entry);
|
entries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
329
Cicm.Database/Operations/CompanyDescription.cs
Normal file
329
Cicm.Database/Operations/CompanyDescription.cs
Normal file
@@ -0,0 +1,329 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : CompanyDescription.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains operations to manage company descriptions.
|
||||||
|
//
|
||||||
|
// --[ 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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all company descriptions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entries">All company descriptions</param>
|
||||||
|
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||||
|
public bool GetCompanyDescriptions(out List<CompanyDescription> entries)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting all company descriptions...");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const string SQL = "SELECT * from company_descriptions";
|
||||||
|
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||||
|
dbCmd.CommandText = SQL;
|
||||||
|
DataSet dataSet = new DataSet();
|
||||||
|
dataAdapter.SelectCommand = dbCmd;
|
||||||
|
dataAdapter.Fill(dataSet);
|
||||||
|
|
||||||
|
entries = CompanyDescriptionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting company descriptions.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the specified number of company descriptions since the specified start
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entries">List of company_descriptions</param>
|
||||||
|
/// <param name="start">Start of query</param>
|
||||||
|
/// <param name="count">How many entries to retrieve</param>
|
||||||
|
/// <returns><c>true</c> if <see cref="entries" /> is correct, <c>false</c> otherwise</returns>
|
||||||
|
public bool GetCompanyDescriptions(out List<CompanyDescription> entries, ulong start, ulong count)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting {0} company descriptions from {1}...", count, start);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * FROM company_descriptions 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 = CompanyDescriptionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting company descriptions.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets company description by specified id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id</param>
|
||||||
|
/// <returns>CompanyDescription with specified id, <c>null</c> if not found or error</returns>
|
||||||
|
public CompanyDescription GetCompanyDescription(int id)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting company description with id {0}...", id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * from company_descriptions 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<CompanyDescription> entries = CompanyDescriptionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return entries == null || entries.Count == 0 ? null : entries[0];
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting company.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets company description by specified id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entries">List of company_descriptions</param>
|
||||||
|
/// <param name="company">Company id</param>
|
||||||
|
/// <returns>CompanyDescription with specified id, <c>null</c> if not found or error</returns>
|
||||||
|
public bool GetCompanyDescriptionsByCompany(out List<CompanyDescription> entries, int company)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Getting company descriptions for company {0}...", company);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = $"SELECT * FROM company_descriptions WHERE company_id = {company}";
|
||||||
|
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
|
||||||
|
dbCmd.CommandText = sql;
|
||||||
|
DataSet dataSet = new DataSet();
|
||||||
|
dataAdapter.SelectCommand = dbCmd;
|
||||||
|
dataAdapter.Fill(dataSet);
|
||||||
|
|
||||||
|
entries = CompanyDescriptionsFromDataTable(dataSet.Tables[0]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error getting company descriptions.");
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
entries = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts the number of company descriptions in the database
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Entries in database</returns>
|
||||||
|
public long CountCompanyDescriptions()
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Counting company descriptions...");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
dbcmd.CommandText = "SELECT COUNT(*) FROM company_descriptions";
|
||||||
|
object count = dbcmd.ExecuteScalar();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
try { return Convert.ToInt64(count); }
|
||||||
|
catch { return 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new company description to the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entry">Entry to add</param>
|
||||||
|
/// <param name="id">ID of added entry</param>
|
||||||
|
/// <returns><c>true</c> if added correctly, <c>false</c> otherwise</returns>
|
||||||
|
public bool AddCompanyDescription(CompanyDescription entry, out long id)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.Write("Adding description for company id `{0}`...", entry.CompanyId);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDbCommand dbcmd = GetCommandCompanyDescription(entry);
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
const string SQL =
|
||||||
|
"INSERT INTO company_descriptions (company_id, text) VALUES (@company_id, @text)";
|
||||||
|
|
||||||
|
dbcmd.CommandText = SQL;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
|
||||||
|
id = dbCore.LastInsertRowId;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine(" id {0}", id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updated a company description in the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entry">Updated entry</param>
|
||||||
|
/// <returns><c>true</c> if updated correctly, <c>false</c> otherwise</returns>
|
||||||
|
public bool UpdateCompanyDescription(CompanyDescription entry)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Updating company description id `{0}`...", entry.Id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDbCommand dbcmd = GetCommandCompanyDescription(entry);
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
string sql = "UPDATE company_descriptions SET company_id = @company_id, text = @text " +
|
||||||
|
$"WHERE id = {entry.Id}";
|
||||||
|
|
||||||
|
dbcmd.CommandText = sql;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a company description from the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">ID of entry to remove</param>
|
||||||
|
/// <returns><c>true</c> if removed correctly, <c>false</c> otherwise</returns>
|
||||||
|
public bool RemoveCompanyDescription(long id)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine("Removing company description with id `{0}`...", id);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbcmd.Transaction = trans;
|
||||||
|
|
||||||
|
string sql = $"DELETE FROM company_descriptions WHERE id = '{id}';";
|
||||||
|
|
||||||
|
dbcmd.CommandText = sql;
|
||||||
|
|
||||||
|
dbcmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbcmd.Dispose();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IDbCommand GetCommandCompanyDescription(CompanyDescription entry)
|
||||||
|
{
|
||||||
|
IDbCommand dbcmd = dbCon.CreateCommand();
|
||||||
|
|
||||||
|
IDbDataParameter param1 = dbcmd.CreateParameter();
|
||||||
|
IDbDataParameter param2 = dbcmd.CreateParameter();
|
||||||
|
|
||||||
|
param1.ParameterName = "@company_id";
|
||||||
|
param2.ParameterName = "@text";
|
||||||
|
|
||||||
|
param1.DbType = DbType.String;
|
||||||
|
param2.DbType = DbType.String;
|
||||||
|
|
||||||
|
param1.Value = entry.CompanyId;
|
||||||
|
param2.Value = entry.Text;
|
||||||
|
|
||||||
|
dbcmd.Parameters.Add(param1);
|
||||||
|
dbcmd.Parameters.Add(param2);
|
||||||
|
|
||||||
|
return dbcmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<CompanyDescription> CompanyDescriptionsFromDataTable(DataTable dataTable)
|
||||||
|
{
|
||||||
|
List<CompanyDescription> entries = new List<CompanyDescription>();
|
||||||
|
|
||||||
|
foreach(DataRow dataRow in dataTable.Rows)
|
||||||
|
{
|
||||||
|
CompanyDescription entry = new CompanyDescription
|
||||||
|
{
|
||||||
|
Id = int.Parse(dataRow["id"].ToString()),
|
||||||
|
CompanyId = int.Parse(dataRow["company_id"].ToString()),
|
||||||
|
Text = dataRow["text"].ToString()
|
||||||
|
};
|
||||||
|
|
||||||
|
entries.Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ namespace Cicm.Database
|
|||||||
public partial class Operations
|
public partial class Operations
|
||||||
{
|
{
|
||||||
/// <summary>Last known database version</summary>
|
/// <summary>Last known database version</summary>
|
||||||
const int DB_VERSION = 8;
|
const int DB_VERSION = 9;
|
||||||
|
|
||||||
readonly IDbConnection dbCon;
|
readonly IDbConnection dbCon;
|
||||||
readonly IDbCore dbCore;
|
readonly IDbCore dbCore;
|
||||||
|
|||||||
@@ -108,6 +108,11 @@ namespace Cicm.Database
|
|||||||
UpdateDatabaseToV8();
|
UpdateDatabaseToV8();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
UpdateDatabaseToV9();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OptimizeDatabase();
|
OptimizeDatabase();
|
||||||
@@ -804,6 +809,26 @@ namespace Cicm.Database
|
|||||||
dbCmd.Dispose();
|
dbCmd.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateDatabaseToV9()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Updating database to version 9");
|
||||||
|
|
||||||
|
Console.WriteLine("Creating table `company_descriptions`");
|
||||||
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
IDbTransaction trans = dbCon.BeginTransaction();
|
||||||
|
dbCmd.Transaction = trans;
|
||||||
|
dbCmd.CommandText = V9.CompanyDescriptions;
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
trans.Commit();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine("Setting new database version to 9...");
|
||||||
|
dbCmd = dbCon.CreateCommand();
|
||||||
|
dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('9')";
|
||||||
|
dbCmd.ExecuteNonQuery();
|
||||||
|
dbCmd.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
void OptimizeDatabase()
|
void OptimizeDatabase()
|
||||||
{
|
{
|
||||||
IDbCommand dbCmd = dbCon.CreateCommand();
|
IDbCommand dbCmd = dbCon.CreateCommand();
|
||||||
|
|||||||
@@ -67,5 +67,7 @@ namespace Cicm.Database.Schemas
|
|||||||
public string Twitter;
|
public string Twitter;
|
||||||
/// <summary>Website</summary>
|
/// <summary>Website</summary>
|
||||||
public string Website;
|
public string Website;
|
||||||
|
/// <summary>Description</summary>
|
||||||
|
public string Description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
45
Cicm.Database/Schemas/CompanyDescription.cs
Normal file
45
Cicm.Database/Schemas/CompanyDescription.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : Company.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// High level representation of a 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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Cicm.Database.Schemas
|
||||||
|
{
|
||||||
|
/// <summary>Company description</summary>
|
||||||
|
public class CompanyDescription
|
||||||
|
{
|
||||||
|
/// <summary>ID</summary>
|
||||||
|
public int Id;
|
||||||
|
/// <summary>Company ID</summary>
|
||||||
|
public int CompanyId;
|
||||||
|
/// <summary>Description</summary>
|
||||||
|
public string Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
97
Cicm.Database/Schemas/Sql/V9.cs
Normal file
97
Cicm.Database/Schemas/Sql/V9.cs
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
// Canary Islands Computer Museum Website
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : V8.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains SQL queries to create the database version 7.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
namespace Cicm.Database.Schemas.Sql
|
||||||
|
{
|
||||||
|
public static class V9
|
||||||
|
{
|
||||||
|
public static readonly string Admins = V8.Admins;
|
||||||
|
|
||||||
|
public static readonly string BrowserTests = V8.BrowserTests;
|
||||||
|
|
||||||
|
public static readonly string CicmDb = "CREATE TABLE `cicm_db` (\n" +
|
||||||
|
"`id` int(11) NOT NULL AUTO_INCREMENT,\n" +
|
||||||
|
"`version` int(11) NOT NULL,\n" +
|
||||||
|
"`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" +
|
||||||
|
"PRIMARY KEY (`id`)\n" + ");\n" +
|
||||||
|
"INSERT INTO cicm_db (version) VALUES ('9');";
|
||||||
|
|
||||||
|
public static readonly string Companies = V8.Companies;
|
||||||
|
|
||||||
|
public static readonly string Computers = V8.Computers;
|
||||||
|
|
||||||
|
public static readonly string Consoles = V8.Consoles;
|
||||||
|
|
||||||
|
public static readonly string DiskFormats = V8.DiskFormats;
|
||||||
|
|
||||||
|
public static readonly string Forbidden = V8.Forbidden;
|
||||||
|
|
||||||
|
public static readonly string Gpus = V8.Gpus;
|
||||||
|
|
||||||
|
public static readonly string Logs = V8.Logs;
|
||||||
|
|
||||||
|
public static readonly string MoneyDonations = V8.MoneyDonations;
|
||||||
|
|
||||||
|
public static readonly string MusicSynths = V8.MusicSynths;
|
||||||
|
|
||||||
|
public static readonly string News = V8.News;
|
||||||
|
|
||||||
|
public static readonly string OwnedComputers = V8.OwnedComputers;
|
||||||
|
|
||||||
|
public static readonly string OwnedConsoles = V8.OwnedConsoles;
|
||||||
|
|
||||||
|
public static readonly string Processors = V8.Processors;
|
||||||
|
|
||||||
|
public static readonly string SoundSynths = V8.SoundSynths;
|
||||||
|
|
||||||
|
public static readonly string ComputersForeignKeys = V8.ComputersForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string ConsolesForeignKeys = V8.ConsolesForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string Iso3166Numeric = V8.Iso3166Numeric;
|
||||||
|
|
||||||
|
public static readonly string Iso3166NumericValues = V8.Iso3166NumericValues;
|
||||||
|
|
||||||
|
public static readonly string CompaniesForeignKeys = V8.CompaniesForeignKeys;
|
||||||
|
|
||||||
|
public static readonly string CompanyLogos = V8.CompanyLogos;
|
||||||
|
|
||||||
|
public static readonly string CompanyDescriptions =
|
||||||
|
"CREATE TABLE `company_descriptions` (\n" +
|
||||||
|
"`id` INT NOT NULL AUTO_INCREMENT,\n" +
|
||||||
|
"`company_id` INT NOT NULL,\n" +
|
||||||
|
"`text` text,\n" +
|
||||||
|
"PRIMARY KEY (`id`),\n" +
|
||||||
|
"INDEX `idx_company_id` (`company_id` ASC),\n" +
|
||||||
|
"FULLTEXT KEY `idx_text` (`text`),\n" +
|
||||||
|
"CONSTRAINT `fk_company_id` FOREIGN KEY (`id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n" +
|
||||||
|
")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,7 @@ namespace cicm_web.Models
|
|||||||
public CompanyStatus Status;
|
public CompanyStatus Status;
|
||||||
public string Twitter;
|
public string Twitter;
|
||||||
public string Website;
|
public string Website;
|
||||||
|
public string Description;
|
||||||
|
|
||||||
public static CompanyWithItems GetItem(int id)
|
public static CompanyWithItems GetItem(int id)
|
||||||
{
|
{
|
||||||
@@ -81,7 +82,8 @@ namespace cicm_web.Models
|
|||||||
Twitter = dbItem.Twitter,
|
Twitter = dbItem.Twitter,
|
||||||
Website = dbItem.Website,
|
Website = dbItem.Website,
|
||||||
Logos = dbItem.Logos,
|
Logos = dbItem.Logos,
|
||||||
LastLogo = dbItem.LastLogo
|
LastLogo = dbItem.LastLogo,
|
||||||
|
Description = dbItem.Description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +112,8 @@ namespace cicm_web.Models
|
|||||||
Twitter = t.Twitter,
|
Twitter = t.Twitter,
|
||||||
Website = t.Website,
|
Website = t.Website,
|
||||||
Logos = t.Logos,
|
Logos = t.Logos,
|
||||||
LastLogo = t.LastLogo
|
LastLogo = t.LastLogo,
|
||||||
|
Description = t.Description
|
||||||
}).OrderBy(t => t.Name).ToArray();
|
}).OrderBy(t => t.Name).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +144,8 @@ namespace cicm_web.Models
|
|||||||
Twitter = t.Twitter,
|
Twitter = t.Twitter,
|
||||||
Website = t.Website,
|
Website = t.Website,
|
||||||
Logos = t.Logos,
|
Logos = t.Logos,
|
||||||
LastLogo = t.LastLogo
|
LastLogo = t.LastLogo,
|
||||||
|
Description = t.Description
|
||||||
}).OrderBy(t => t.Name).ToArray();
|
}).OrderBy(t => t.Name).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
@if(Model != null)
|
@if(Model != null)
|
||||||
{
|
{
|
||||||
<div class="container">
|
<div class="container-fluid">
|
||||||
<p align=center>
|
<p align=center>
|
||||||
@if(Model.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.LastLogo.Guid + ".svg")))
|
@if(Model.LastLogo != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, "assets/logos", Model.LastLogo.Guid + ".svg")))
|
||||||
{
|
{
|
||||||
@@ -121,6 +121,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -337,11 +338,29 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row"
|
||||||
|
id="itemsAccordion">
|
||||||
|
<div class="card">
|
||||||
@if(Model.Computers.Any())
|
@if(Model.Computers.Any())
|
||||||
{
|
{
|
||||||
<p>
|
<div class="card-header"
|
||||||
@Model.Computers.Count() computers made by this company found in the database.<br />
|
id="headingComputers">
|
||||||
|
<h5 class="mb-0">
|
||||||
|
<button aria-controls="collapseComputers"
|
||||||
|
aria-expanded="false"
|
||||||
|
class="btn btn-info"
|
||||||
|
data-target="#collapseComputers"
|
||||||
|
data-toggle="collapse">
|
||||||
|
<span class="badge badge-success">@Model.Computers.Count()</span> computers known.
|
||||||
|
</button>
|
||||||
|
</h5>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div aria-labelledby="headingComputers"
|
||||||
|
class="collapse"
|
||||||
|
data-parent="#itemsAccordion"
|
||||||
|
id="collapseComputers">
|
||||||
|
<div class="card-body">
|
||||||
@foreach(ComputerMini computer in Model.Computers)
|
@foreach(ComputerMini computer in Model.Computers)
|
||||||
{
|
{
|
||||||
<a asp-controller="Computer"
|
<a asp-controller="Computer"
|
||||||
@@ -350,19 +369,40 @@
|
|||||||
@computer.Model</a>
|
@computer.Model</a>
|
||||||
<br />
|
<br />
|
||||||
}
|
}
|
||||||
</p>
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<p>There are no computers made by this company in the database.</p>
|
<div class="card-header"
|
||||||
}
|
id="headingComputers">
|
||||||
|
<h5 class="mb-0">
|
||||||
|
<button class="btn btn-info">
|
||||||
|
<span class="badge badge-danger">No</span> computers known.
|
||||||
|
</button>
|
||||||
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
<div class="row">
|
|
||||||
@if(Model.Consoles.Any())
|
@if(Model.Consoles.Any())
|
||||||
{
|
{
|
||||||
<p>
|
<div class="card-header"
|
||||||
@Model.Consoles.Count() videogame consoles made by this company found in the database.<br />
|
id="headingConsoles">
|
||||||
|
<h5 class="mb-0">
|
||||||
|
<button aria-controls="collapseConsoles"
|
||||||
|
aria-expanded="false"
|
||||||
|
class="btn btn-info"
|
||||||
|
data-target="#collapseConsoles"
|
||||||
|
data-toggle="collapse">
|
||||||
|
<span class="badge badge-success">@Model.Consoles.Count()</span> videogame consoles known.
|
||||||
|
</button>
|
||||||
|
</h5>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div aria-labelledby="headingConsoles"
|
||||||
|
class="collapse"
|
||||||
|
data-parent="#itemsAccordion"
|
||||||
|
id="collapseConsoles">
|
||||||
|
<div class="card-body">
|
||||||
@foreach(ConsoleMini console in Model.Consoles)
|
@foreach(ConsoleMini console in Model.Consoles)
|
||||||
{
|
{
|
||||||
<a asp-controller="Console"
|
<a asp-controller="Console"
|
||||||
@@ -371,14 +411,30 @@
|
|||||||
@console.Model</a>
|
@console.Model</a>
|
||||||
<br />
|
<br />
|
||||||
}
|
}
|
||||||
</p>
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<p>There are no videogame consoles made by this company found in the database.</p>
|
<div class="card-header"
|
||||||
|
id="headingComputers">
|
||||||
|
<h5 class="mb-0">
|
||||||
|
<button class="btn btn-info">
|
||||||
|
<span class="badge badge-danger">No</span> videogame consoles known.
|
||||||
|
</button>
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if(Model.Description != null)
|
||||||
|
{
|
||||||
|
<div class="row container-fluid">
|
||||||
|
@Model.Description
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<Version>3.0.99.149</Version>
|
<Version>3.0.99.150</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user