diff --git a/cicm_web/Models/Company.cs b/cicm_web/Models/Company.cs new file mode 100644 index 00000000..3840f551 --- /dev/null +++ b/cicm_web/Models/Company.cs @@ -0,0 +1,60 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Company.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 dbItems = null; + bool? result = Program.Database?.Operations.GetCompanies(out dbItems); + if(result == null || result.Value == false || dbItems == null) return null; + + List items = new List(); + + foreach(Cicm.Database.Schemas.Company dbItem in dbItems) + items.Add(new Company {Id = dbItem.Id, Name = dbItem.Name}); + + return items.ToArray(); + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/Computer.cs b/cicm_web/Models/Computer.cs new file mode 100644 index 00000000..a21d41ae --- /dev/null +++ b/cicm_web/Models/Computer.cs @@ -0,0 +1,150 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Computer.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 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 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; + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/Console.cs b/cicm_web/Models/Console.cs new file mode 100644 index 00000000..816a2b05 --- /dev/null +++ b/cicm_web/Models/Console.cs @@ -0,0 +1,138 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Console.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 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 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; + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/ConsoleCompany.cs b/cicm_web/Models/ConsoleCompany.cs new file mode 100644 index 00000000..0c31ffc8 --- /dev/null +++ b/cicm_web/Models/ConsoleCompany.cs @@ -0,0 +1,61 @@ +/****************************************************************************** +// 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.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 dbItems = null; + bool? result = + Program.Database?.Operations.GetConsoleCompanies(out dbItems); + if(result == null || result.Value == false || dbItems == null) return null; + + List items = new List(); + + foreach(Cicm.Database.Schemas.ConsoleCompany dbItem in dbItems) + items.Add(new ConsoleCompany {Id = dbItem.Id, Name = dbItem.Name}); + + return items.ToArray(); + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/Cpu.cs b/cicm_web/Models/Cpu.cs new file mode 100644 index 00000000..40339776 --- /dev/null +++ b/cicm_web/Models/Cpu.cs @@ -0,0 +1,60 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Cpu.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 dbItems = null; + bool? result = Program.Database?.Operations.GetCpus(out dbItems); + if(result == null || result.Value == false || dbItems == null) return null; + + List items = new List(); + + foreach(Cicm.Database.Schemas.Cpu dbItem in dbItems) + items.Add(new Cpu {Id = dbItem.Id, Name = dbItem.Name}); + + return items.ToArray(); + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/DiskFormat.cs b/cicm_web/Models/DiskFormat.cs new file mode 100644 index 00000000..c185a393 --- /dev/null +++ b/cicm_web/Models/DiskFormat.cs @@ -0,0 +1,60 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : DiskFormat.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 dbItems = null; + bool? result = Program.Database?.Operations.GetDiskFormats(out dbItems); + if(result == null || result.Value == false || dbItems == null) return null; + + List items = new List(); + + foreach(Cicm.Database.Schemas.DiskFormat dbItem in dbItems) + items.Add(new DiskFormat {Id = dbItem.Id, Description = dbItem.Description}); + + return items.ToArray(); + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/Dsp.cs b/cicm_web/Models/Dsp.cs new file mode 100644 index 00000000..465ee1ca --- /dev/null +++ b/cicm_web/Models/Dsp.cs @@ -0,0 +1,60 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Dsp.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 dbItems = null; + bool? result = Program.Database?.Operations.GetDsps(out dbItems); + if(result == null || result.Value == false || dbItems == null) return null; + + List items = new List(); + + foreach(Cicm.Database.Schemas.Dsp dbItem in dbItems) + items.Add(new Dsp {Id = dbItem.Id, Name = dbItem.Name}); + + return items.ToArray(); + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/Gpu.cs b/cicm_web/Models/Gpu.cs new file mode 100644 index 00000000..473cd98e --- /dev/null +++ b/cicm_web/Models/Gpu.cs @@ -0,0 +1,60 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Gpu.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 dbItems = null; + bool? result = Program.Database?.Operations.GetGpus(out dbItems); + if(result == null || result.Value == false || dbItems == null) return null; + + List items = new List(); + + foreach(Cicm.Database.Schemas.Gpu dbItem in dbItems) + items.Add(new Gpu {Id = dbItem.Id, Name = dbItem.Name}); + + return items.ToArray(); + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/Mpu.cs b/cicm_web/Models/Mpu.cs new file mode 100644 index 00000000..e01a4122 --- /dev/null +++ b/cicm_web/Models/Mpu.cs @@ -0,0 +1,60 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : Mpu.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 dbItems = null; + bool? result = Program.Database?.Operations.GetMpus(out dbItems); + if(result == null || result.Value == false || dbItems == null) return null; + + List items = new List(); + + foreach(Cicm.Database.Schemas.Mpu dbItem in dbItems) + items.Add(new Mpu {Id = dbItem.Id, Name = dbItem.Name}); + + return items.ToArray(); + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/News.cs b/cicm_web/Models/News.cs index 4d965119..453931c1 100644 --- a/cicm_web/Models/News.cs +++ b/cicm_web/Models/News.cs @@ -1,4 +1,34 @@ -using System; +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : News.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; diff --git a/cicm_web/Models/OwnComputer.cs b/cicm_web/Models/OwnComputer.cs new file mode 100644 index 00000000..0f058376 --- /dev/null +++ b/cicm_web/Models/OwnComputer.cs @@ -0,0 +1,120 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : OwnComputer.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 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; + } + } +} \ No newline at end of file diff --git a/cicm_web/Models/OwnConsole.cs b/cicm_web/Models/OwnConsole.cs new file mode 100644 index 00000000..c476dc27 --- /dev/null +++ b/cicm_web/Models/OwnConsole.cs @@ -0,0 +1,84 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : OwnConsole.cs +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// 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 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 + }; + } + } +} \ No newline at end of file diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index 219b039a..bce9d749 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - 3.0.99.36 + 3.0.99.38 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website