mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Update to database version 3.
This commit is contained in:
@@ -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<Cicm.Database.Schemas.Company> 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<Cicm.Database.Schemas.Company> 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};
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Cicm.Database.Schemas.Computer> 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<Cicm.Database.Schemas.Computer> 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};
|
||||
|
||||
@@ -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<Cicm.Database.Schemas.Console> 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<Cicm.Database.Schemas.Console> 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<ConsoleMini> items = new List<ConsoleMini>();
|
||||
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<Cicm.Database.Schemas.Console> 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<ConsoleMini> items = new List<ConsoleMini>();
|
||||
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<Cicm.Database.Schemas.Console> 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<ConsoleMini> items = new List<ConsoleMini>();
|
||||
@@ -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<Cicm.Database.Schemas.Console> 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<Cicm.Database.Schemas.Console> 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};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/******************************************************************************
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ConsoleCompany.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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<Cicm.Database.Schemas.ConsoleCompany> 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<Cicm.Database.Schemas.ConsoleCompany> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Dsp.cs
|
||||
// Filename : MusicSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ 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<Cicm.Database.Schemas.Dsp> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetDsps(out dbItems);
|
||||
List<Cicm.Database.Schemas.MusicSynth> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetMusicSynths(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<Dsp> items = new List<Dsp>();
|
||||
List<MusicSynth> items = new List<MusicSynth>();
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -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.";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : OwnComputer.cs
|
||||
// Filename : OwnedComputer.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ 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<Cicm.Database.Schemas.OwnComputer> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetOwnComputers(out dbItems);
|
||||
List<Cicm.Database.Schemas.OwnedComputer> 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;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : OwnConsole.cs
|
||||
// Filename : OwnedConsole.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ 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<Cicm.Database.Schemas.OwnConsole> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetOwnConsoles(out dbItems);
|
||||
List<Cicm.Database.Schemas.OwnedConsole> 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",
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Cpu.cs
|
||||
// Filename : Processor.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ 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<Cicm.Database.Schemas.Cpu> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetCpus(out dbItems);
|
||||
List<Cicm.Database.Schemas.Processor> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetProcessors(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<Cpu> items = new List<Cpu>();
|
||||
List<Processor> items = new List<Processor>();
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
// Canary Islands Computer Museum Website
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Mpu.cs
|
||||
// Filename : SoundSynth.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ 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<Cicm.Database.Schemas.Mpu> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetMpus(out dbItems);
|
||||
List<Cicm.Database.Schemas.SoundSynth> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetSoundSynths(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
|
||||
List<Mpu> items = new List<Mpu>();
|
||||
List<SoundSynth> items = new List<SoundSynth>();
|
||||
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user