Add all models.

This commit is contained in:
2018-04-13 17:53:12 +01:00
parent 57d1e4de33
commit 1a412a9e80
13 changed files with 945 additions and 2 deletions

View File

@@ -0,0 +1,60 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Company.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// 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.Collections.Generic;
namespace cicm_web.Models
{
public class Company
{
public int Id;
public string Name;
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};
}
public static Company[] 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;
List<Company> items = new List<Company>();
foreach(Cicm.Database.Schemas.Company dbItem in dbItems)
items.Add(new Company {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
}
}

150
cicm_web/Models/Computer.cs Normal file
View File

@@ -0,0 +1,150 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Computer.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Videogame console 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.Collections.Generic;
using System.Linq;
namespace cicm_web.Models
{
public class Computer
{
public int Bits;
public string Cap1;
public string Cap2;
public int Colors;
public string Comment;
public Company Company;
public Cpu Cpu1;
public Cpu Cpu2;
public DiskFormat Disk1;
public DiskFormat Disk2;
public Gpu Gpu;
public DiskFormat Hdd1;
public DiskFormat Hdd2;
public DiskFormat Hdd3;
public int Id;
public float Mhz1;
public float Mhz2;
public string Model;
public Mpu Mpu;
public int MusicChannels;
public int Ram;
public string Resolution;
public int Rom;
public int SoundChannels;
public Dsp Spu;
public int Vram;
public int Year;
public static Computer[] GetAllItems()
{
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;
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as Computer[];
}
public static Computer[] GetItemsFromCompany(int id)
{
List<Cicm.Database.Schemas.Computer> dbItems = null;
bool? result = Program.Database?.Operations.GetComputers(out dbItems, id);
if(result == null || result.Value == false || dbItems == null) return null;
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as Computer[];
}
public static Computer GetItem(int id)
{
Cicm.Database.Schemas.Computer dbItem = Program.Database?.Operations.GetComputer(id);
return dbItem == null ? null : TransformItem(dbItem);
}
static Computer TransformItem(Cicm.Database.Schemas.Computer dbItem)
{
Computer item = new Computer
{
Bits = dbItem.Bits,
Colors = dbItem.Colors,
Comment = dbItem.Comment,
Company = Company.GetItem(dbItem.Company),
Gpu = Gpu.GetItem(dbItem.Gpu),
Hdd1 = DiskFormat.GetItem(dbItem.Hdd1),
Hdd2 = DiskFormat.GetItem(dbItem.Hdd2),
Hdd3 = DiskFormat.GetItem(dbItem.Hdd3),
Id = dbItem.Id,
Model = dbItem.Model,
Ram = dbItem.Ram,
Resolution = dbItem.Resolution,
Rom = dbItem.Rom,
Vram = dbItem.Vram,
Year = dbItem.Year
};
if(dbItem.Disk1 > 0)
{
item.Cap1 = dbItem.Cap1;
item.Disk1 = DiskFormat.GetItem(dbItem.Disk1);
}
if(dbItem.Disk2 > 0)
{
item.Cap2 = dbItem.Cap2;
item.Disk2 = DiskFormat.GetItem(dbItem.Disk2);
}
if(dbItem.Cpu1 > 0)
{
item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
item.Mhz1 = dbItem.Mhz1;
}
if(dbItem.Cpu2 > 0)
{
item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
item.Mhz2 = dbItem.Mhz2;
}
if(dbItem.Mpu > 0)
{
item.Mpu = Mpu.GetItem(dbItem.Mpu);
item.MusicChannels = dbItem.MusicChannels;
}
if(dbItem.Spu > 0)
{
item.Spu = Dsp.GetItem(dbItem.Spu);
item.SoundChannels = dbItem.SoundChannels;
}
return item;
}
}
}

138
cicm_web/Models/Console.cs Normal file
View File

@@ -0,0 +1,138 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Console.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Videogame console 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.Collections.Generic;
using System.Linq;
namespace cicm_web.Models
{
public class Console
{
public int Bits;
public int Cap;
public int Colors;
public string Comments;
public Company 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 static Console[] GetAllItems()
{
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;
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as Console[];
}
public static Console[] GetItemsFromCompany(int id)
{
List<Cicm.Database.Schemas.Console> dbItems = null;
bool? result = Program.Database?.Operations.GetConsoles(out dbItems, id);
if(result == null || result.Value == false || dbItems == null) return null;
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as Console[];
}
public static Console GetItem(int id)
{
Cicm.Database.Schemas.Console dbItem = Program.Database?.Operations.GetConsole(id);
return dbItem == null ? null : TransformItem(dbItem);
}
static Console TransformItem(Cicm.Database.Schemas.Console dbItem)
{
Console item = new Console
{
Bits = dbItem.Bits,
Colors = dbItem.Colors,
Comments = dbItem.Comments,
Company = Company.GetItem(dbItem.Company),
Gpu = Gpu.GetItem(dbItem.Gpu),
Id = dbItem.Id,
Name = dbItem.Name,
Palette = dbItem.Palette,
Ram = dbItem.Ram,
Resolution = dbItem.Resolution,
Rom = dbItem.Rom,
Vram = dbItem.Vram,
Year = dbItem.Year
};
if(dbItem.Format > 0)
{
item.Cap = dbItem.Cap;
item.Format = DiskFormat.GetItem(dbItem.Format);
}
if(dbItem.Cpu1 > 0)
{
item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
item.Mhz1 = dbItem.Mhz1;
}
if(dbItem.Cpu2 > 0)
{
item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
item.Mhz2 = dbItem.Mhz2;
}
if(dbItem.Mpu > 0)
{
item.Mpu = Mpu.GetItem(dbItem.Mpu);
item.MusicChannels = dbItem.MusicChannels;
}
if(dbItem.Spu > 0)
{
item.Spu = Dsp.GetItem(dbItem.Spu);
item.SoundChannels = dbItem.SoundChannels;
}
return item;
}
}
}

View File

@@ -0,0 +1,61 @@
/******************************************************************************
// 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.Collections.Generic;
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;
List<ConsoleCompany> items = new List<ConsoleCompany>();
foreach(Cicm.Database.Schemas.ConsoleCompany dbItem in dbItems)
items.Add(new ConsoleCompany {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
}
}

60
cicm_web/Models/Cpu.cs Normal file
View File

@@ -0,0 +1,60 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Cpu.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Central Processing Unit 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.Collections.Generic;
namespace cicm_web.Models
{
public class Cpu
{
public int Id;
public string Name;
public static Cpu 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};
}
public static Cpu[] GetAllItems()
{
List<Cicm.Database.Schemas.Cpu> dbItems = null;
bool? result = Program.Database?.Operations.GetCpus(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List<Cpu> items = new List<Cpu>();
foreach(Cicm.Database.Schemas.Cpu dbItem in dbItems)
items.Add(new Cpu {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
}
}

View File

@@ -0,0 +1,60 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : DiskFormat.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Disk format 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.Collections.Generic;
namespace cicm_web.Models
{
public class DiskFormat
{
public string Description;
public int Id;
public static DiskFormat GetItem(int id)
{
Cicm.Database.Schemas.DiskFormat dbItem = Program.Database?.Operations.GetDiskFormat(id);
return dbItem == null ? null : new DiskFormat {Description = dbItem.Description, Id = dbItem.Id};
}
public static DiskFormat[] GetAllItems()
{
List<Cicm.Database.Schemas.DiskFormat> dbItems = null;
bool? result = Program.Database?.Operations.GetDiskFormats(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List<DiskFormat> items = new List<DiskFormat>();
foreach(Cicm.Database.Schemas.DiskFormat dbItem in dbItems)
items.Add(new DiskFormat {Id = dbItem.Id, Description = dbItem.Description});
return items.ToArray();
}
}
}

60
cicm_web/Models/Dsp.cs Normal file
View File

@@ -0,0 +1,60 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Dsp.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Digital Sound Processor 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.Collections.Generic;
namespace cicm_web.Models
{
public class Dsp
{
public int Id;
public string Name;
public static Dsp 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};
}
public static Dsp[] GetAllItems()
{
List<Cicm.Database.Schemas.Dsp> dbItems = null;
bool? result = Program.Database?.Operations.GetDsps(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List<Dsp> items = new List<Dsp>();
foreach(Cicm.Database.Schemas.Dsp dbItem in dbItems)
items.Add(new Dsp {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
}
}

60
cicm_web/Models/Gpu.cs Normal file
View File

@@ -0,0 +1,60 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Gpu.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Graphics Processing Unit 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.Collections.Generic;
namespace cicm_web.Models
{
public class Gpu
{
public int Id;
public string Name;
public static Gpu GetItem(int id)
{
Cicm.Database.Schemas.Gpu dbItem = Program.Database?.Operations.GetGpu(id);
return dbItem == null ? null : new Gpu {Name = dbItem.Name, Id = dbItem.Id};
}
public static Gpu[] GetAllItems()
{
List<Cicm.Database.Schemas.Gpu> dbItems = null;
bool? result = Program.Database?.Operations.GetGpus(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List<Gpu> items = new List<Gpu>();
foreach(Cicm.Database.Schemas.Gpu dbItem in dbItems)
items.Add(new Gpu {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
}
}

60
cicm_web/Models/Mpu.cs Normal file
View File

@@ -0,0 +1,60 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : Mpu.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Music Processing Unit 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.Collections.Generic;
namespace cicm_web.Models
{
public class Mpu
{
public int Id;
public string Name;
public static Mpu 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};
}
public static Mpu[] GetAllItems()
{
List<Cicm.Database.Schemas.Mpu> dbItems = null;
bool? result = Program.Database?.Operations.GetMpus(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
List<Mpu> items = new List<Mpu>();
foreach(Cicm.Database.Schemas.Mpu dbItem in dbItems)
items.Add(new Mpu {Id = dbItem.Id, Name = dbItem.Name});
return items.ToArray();
}
}
}

View File

@@ -1,4 +1,34 @@
using System; /******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : News.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Website news 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.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;

View File

@@ -0,0 +1,120 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : OwnComputer.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Videogame console 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.Globalization;
using System.Linq;
using Cicm.Database.Schemas;
namespace cicm_web.Models
{
public class OwnComputer
{
public DateTime Acquired;
public bool Boxed;
public int Cap1;
public int Cap2;
public Computer Computer;
public Cpu Cpu1;
public Cpu Cpu2;
public DiskFormat Disk1;
public DiskFormat Disk2;
public int Id;
public bool Manuals;
public float Mhz1;
public float Mhz2;
public int Ram;
public string Rigid;
public StatusType Status;
public bool Trade;
public int Vram;
public static OwnComputer[] GetAllItems()
{
List<Cicm.Database.Schemas.OwnComputer> dbItems = null;
bool? result = Program.Database?.Operations.GetOwnComputers(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnComputer[];
}
public static OwnComputer GetItem(int id)
{
Cicm.Database.Schemas.OwnComputer dbItem = Program.Database?.Operations.GetOwnComputer(id);
return dbItem == null ? null : TransformItem(dbItem);
}
static OwnComputer TransformItem(Cicm.Database.Schemas.OwnComputer dbItem)
{
Computer computer = Computer.GetItem(dbItem.ComputerId);
OwnComputer item = new OwnComputer
{
Acquired = DateTime.ParseExact(dbItem.Acquired, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture),
Boxed = dbItem.Boxed,
Computer = computer,
Id = dbItem.Id,
Manuals = dbItem.Manuals,
Ram = dbItem.Ram,
Rigid = dbItem.Rigid,
Status = dbItem.Status,
Trade = dbItem.Trade,
Vram = dbItem.Vram
};
if(dbItem.Disk1 > 0)
{
item.Cap1 = dbItem.Cap1;
item.Disk1 = DiskFormat.GetItem(dbItem.Disk1);
}
if(dbItem.Disk2 > 0)
{
item.Cap2 = dbItem.Cap2;
item.Disk2 = DiskFormat.GetItem(dbItem.Disk2);
}
if(dbItem.Cpu1 > 0)
{
item.Cpu1 = Cpu.GetItem(dbItem.Cpu1);
item.Mhz1 = dbItem.Mhz1;
}
if(dbItem.Cpu2 > 0)
{
item.Cpu2 = Cpu.GetItem(dbItem.Cpu2);
item.Mhz2 = dbItem.Mhz2;
}
return computer == null ? null : item;
}
}
}

View File

@@ -0,0 +1,84 @@
/******************************************************************************
// Canary Islands Computer Museum Website
// ----------------------------------------------------------------------------
//
// Filename : OwnConsole.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Videogame console 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.Globalization;
using System.Linq;
using Cicm.Database.Schemas;
namespace cicm_web.Models
{
public class OwnConsole
{
public DateTime Acquired;
public bool Boxed;
public Console Console;
public int Id;
public bool Manuals;
public StatusType Status;
public bool Trade;
public static OwnConsole[] GetAllItems()
{
List<Cicm.Database.Schemas.OwnConsole> dbItems = null;
bool? result = Program.Database?.Operations.GetOwnConsoles(out dbItems);
if(result == null || result.Value == false || dbItems == null) return null;
return dbItems.OrderByDescending(i => i.Id).Select(TransformItem) as OwnConsole[];
}
public static OwnConsole GetItem(int id)
{
Cicm.Database.Schemas.OwnConsole dbItem = Program.Database?.Operations.GetOwnConsole(id);
return dbItem == null ? null : TransformItem(dbItem);
}
static OwnConsole TransformItem(Cicm.Database.Schemas.OwnConsole dbItem)
{
Console console = Console.GetItem(dbItem.ConsoleId);
return console == null
? null
: new OwnConsole
{
Acquired =
DateTime.ParseExact(dbItem.Acquired, "yyyy/MM/dd HH:mm:ss",
CultureInfo.InvariantCulture),
Boxed = dbItem.Boxed,
Console = console,
Id = dbItem.Id,
Manuals = dbItem.Manuals,
Status = dbItem.Status,
Trade = dbItem.Trade
};
}
}
}

View File

@@ -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.36</Version> <Version>3.0.99.38</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>