diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 298ad158..c67dc7a2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,27 +1,34 @@ # Contributing ## Commit signature + For security reason we require all commits to be cryptographically signed. This section explains how to setup the development environment for that purpose. ### Visual Studio and Visual Studio Code for Windows -You need to install Git for Windows. It is available as a component of Visual Studio, or separately in https://gitforwindows.org. + +You need to install Git for Windows. It is available as a component of Visual Studio, or separately +in https://gitforwindows.org. You also need to install Gpg4win from https://www.gpg4win.org. Ensure to select the Kleopatra component. -Once you have them installed, open Kleopatra and generate a new key pair, of OpenPGP type, following the instructions [here](https://www.gpg4win.org/doc/en/gpg4win-compendium_12.html). +Once you have them installed, open Kleopatra and generate a new key pair, of OpenPGP type, following the +instructions [here](https://www.gpg4win.org/doc/en/gpg4win-compendium_12.html). Save aside the fingerprint, you'll need it later. Now go to environment variables (in the properties of your computer) and add this to the path: `C:\Program Files\Git\usr\bin` Finally, open Git Bash, and write the following commands if you want all git commits to be signed: + ```bash git config --global commit.gpgsign true git config --global user.signingkey git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe" ``` + or if you want the options to apply only for this project + ```bash cd /DRIVE/PATH_TO_PROJECT git config commit.gpgsign true @@ -29,8 +36,11 @@ git config user.signingkey FINGERPRINT git config gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe" ``` -replacing `FINGERPRINT` with the fingerprint you saved from the key generation, `DRIVE` with the drive letter and `PATH_TO_PROJECT` using `/` as path separator. +replacing `FINGERPRINT` with the fingerprint you saved from the key generation, `DRIVE` with the drive letter and +`PATH_TO_PROJECT` using `/` as path separator. -Once this is done, every time you commit in VS / VSCode, a message box titled `pinentry-qt` will ask for the passphrase you set up earlier and sign the commit with your key. +Once this is done, every time you commit in VS / VSCode, a message box titled `pinentry-qt` will ask for the passphrase +you set up earlier and sign the commit with your key. -For GitHub to recognize your signature you need to follow the steps [here](https://help.github.com/en/github/authenticating-to-github/adding-a-new-gpg-key-to-your-github-account). \ No newline at end of file +For GitHub to recognize your signature you need to follow the +steps [here](https://help.github.com/en/github/authenticating-to-github/adding-a-new-gpg-key-to-your-github-account). \ No newline at end of file diff --git a/Marechai.Database/Enums.cs b/Marechai.Database/Enums.cs index e02f2ee6..a3d06a48 100644 --- a/Marechai.Database/Enums.cs +++ b/Marechai.Database/Enums.cs @@ -29,514 +29,730 @@ using System.ComponentModel.DataAnnotations; // ReSharper disable UnusedMember.Global // ReSharper disable InconsistentNaming -namespace Marechai.Database +namespace Marechai.Database; + +public enum NewsType { - public enum NewsType - { - NewComputerInDb = 1, NewConsoleInDb = 2, NewComputerInCollection = 3, - NewConsoleInCollection = 4, UpdatedComputerInDb = 5, UpdatedConsoleInDb = 6, - UpdatedComputerInCollection = 7, UpdatedConsoleInCollection = 8, NewMoneyDonation = 9 - } + NewComputerInDb = 1, + NewConsoleInDb = 2, + NewComputerInCollection = 3, + NewConsoleInCollection = 4, + UpdatedComputerInDb = 5, + UpdatedConsoleInDb = 6, + UpdatedComputerInCollection = 7, + UpdatedConsoleInCollection = 8, + NewMoneyDonation = 9 +} - public enum StatusType - { - [Display(Name = "Unknown")] - Unknown = 0, [Display(Name = "Tested good")] - TestedGood = 1, [Display(Name = "Not tested")] - NotTested = 2, [Display(Name = "Tested bad")] - TestedBad = 3 - } +public enum StatusType +{ + [Display(Name = "Unknown")] + Unknown = 0, + [Display(Name = "Tested good")] + TestedGood = 1, + [Display(Name = "Not tested")] + NotTested = 2, + [Display(Name = "Tested bad")] + TestedBad = 3 +} - public enum CompanyStatus - { - /// Status is unknown or not set - Unknown = 0, - /// Company is still existing - Active = 1, - /// Company was sold, totally or partially - Sold = 2, - /// Company merged with another company to make yet another company - Merged = 3, - /// Company filled for bankruptcy - Bankrupt = 4, - /// Company ceased operations for reasons different to bankruptcy - Defunct = 5, - /// Company renamed possibly with a change of intentions - Renamed = 6 - } +public enum CompanyStatus +{ + /// Status is unknown or not set + Unknown = 0, + /// Company is still existing + Active = 1, + /// Company was sold, totally or partially + Sold = 2, + /// Company merged with another company to make yet another company + Merged = 3, + /// Company filled for bankruptcy + Bankrupt = 4, + /// Company ceased operations for reasons different to bankruptcy + Defunct = 5, + /// Company renamed possibly with a change of intentions + Renamed = 6 +} - public enum MachineType - { - /// Unknown machine type, should not happen - Unknown = 0, - /// Computer - Computer = 1, - /// Videogame console - Console = 2 - } +public enum MachineType +{ + /// Unknown machine type, should not happen + Unknown = 0, + /// Computer + Computer = 1, + /// Videogame console + Console = 2 +} - public enum MemoryType - { - /// Unknown memory type - Unknown = 0, - /// Dynamic RAM - DRAM = 1, - /// Fast page mode DRAM - FPM = 2, - /// Extended data out DRAM - EDO = 3, - /// Dual-ported video DRAM - VRAM = 4, - /// Synchronous DRAM - SDRAM = 5, - /// Double data rate SDRAM - DDR = 6, - /// Double data rate SDRAM v2 - DDR2 = 7, - /// Double data rate SDRAM v3 - DDR3 = 8, - /// Double data rate SDRAM v4 - DDR4 = 9, - /// Rambus DRAM - RDRAM = 10, - /// Synchronous graphics RAM - SGRAM = 11, - /// Pseudostatic RAM - PSRAM = 12, - /// Static RAM - SRAM = 13, - /// Read-only memory - ROM = 14, - /// Programmable ROM - PROM = 15, - /// Erasable programmable ROM - EPROM = 16, - /// Electronically-erasable programmable ROM - EEPROM = 17, - /// NAND flash - NAND = 18, - /// NOR flash - NOR = 19, - /// Resistive RAM - ReRAM = 20, - /// Conductive-bridging RAM - CBRAM = 21, - /// Domain-wall memory - DWM = 22, - /// Nano-RAM - NanoRAM = 23, - /// Millipede memory - Millipede = 24, - /// Floating Junction Gate RAM - FJG = 25, - /// Punched paper - PunchedPaper = 26, - /// Drum memory - DrumMemory = 27, - /// Magnetic-core - MagneticCore = 28, - /// Plated wire memory - PlatedWire = 29, - /// Core rope memory - CoreRope = 30, - /// Thin-film memory - ThinFilm = 31, - /// Twistor memory - Twistor = 32, - /// Bubble memory - Bubble = 33 - } +public enum MemoryType +{ + /// Unknown memory type + Unknown = 0, + /// Dynamic RAM + DRAM = 1, + /// Fast page mode DRAM + FPM = 2, + /// Extended data out DRAM + EDO = 3, + /// Dual-ported video DRAM + VRAM = 4, + /// Synchronous DRAM + SDRAM = 5, + /// Double data rate SDRAM + DDR = 6, + /// Double data rate SDRAM v2 + DDR2 = 7, + /// Double data rate SDRAM v3 + DDR3 = 8, + /// Double data rate SDRAM v4 + DDR4 = 9, + /// Rambus DRAM + RDRAM = 10, + /// Synchronous graphics RAM + SGRAM = 11, + /// Pseudostatic RAM + PSRAM = 12, + /// Static RAM + SRAM = 13, + /// Read-only memory + ROM = 14, + /// Programmable ROM + PROM = 15, + /// Erasable programmable ROM + EPROM = 16, + /// Electronically-erasable programmable ROM + EEPROM = 17, + /// NAND flash + NAND = 18, + /// NOR flash + NOR = 19, + /// Resistive RAM + ReRAM = 20, + /// Conductive-bridging RAM + CBRAM = 21, + /// Domain-wall memory + DWM = 22, + /// Nano-RAM + NanoRAM = 23, + /// Millipede memory + Millipede = 24, + /// Floating Junction Gate RAM + FJG = 25, + /// Punched paper + PunchedPaper = 26, + /// Drum memory + DrumMemory = 27, + /// Magnetic-core + MagneticCore = 28, + /// Plated wire memory + PlatedWire = 29, + /// Core rope memory + CoreRope = 30, + /// Thin-film memory + ThinFilm = 31, + /// Twistor memory + Twistor = 32, + /// Bubble memory + Bubble = 33 +} - public enum MemoryUsage - { - /// Unknown usage - Unknown = 0, - /// - /// Contains a boot loader (usually read-only) whose only function is to load the next memory (firmware or - /// cartridge) - /// - Bootloader = 1, - /// - /// Contains hardware initializing, some (or many) low level calls and code to load software from secondary - /// storage - /// - Firmware = 2, - /// Memory used by software running on the machine - Work = 3, - /// Memory used by the graphics processing units - Video = 4, - /// Memory used by the sound synthesizers - Sound = 5, - /// Memory used to store wave tables - Wavetable = 6, - /// Memory used as a buffer from secondary storage - StorageBuffer = 7, - /// Memory used to save arbitrary data and possible also configuration - Save = 8, - /// Memory used to save only configuration - Configuration = 9, - /// - /// Memory accessible directly to any of the processors in the machine, including graphics processors and sound - /// synthesizers - /// - Unified = 10 - } +public enum MemoryUsage +{ + /// Unknown usage + Unknown = 0, + /// + /// Contains a boot loader (usually read-only) whose only function is to load the next memory (firmware or + /// cartridge) + /// + Bootloader = 1, + /// + /// Contains hardware initializing, some (or many) low level calls and code to load software from secondary + /// storage + /// + Firmware = 2, + /// Memory used by software running on the machine + Work = 3, + /// Memory used by the graphics processing units + Video = 4, + /// Memory used by the sound synthesizers + Sound = 5, + /// Memory used to store wave tables + Wavetable = 6, + /// Memory used as a buffer from secondary storage + StorageBuffer = 7, + /// Memory used to save arbitrary data and possible also configuration + Save = 8, + /// Memory used to save only configuration + Configuration = 9, + /// + /// Memory accessible directly to any of the processors in the machine, including graphics processors and sound + /// synthesizers + /// + Unified = 10 +} - public enum StorageType - { - /// Contains an empty interface for user connection - Empty = -1, - /// Unknown - Unknown = 0, - /// Unknown magneto-optical - MagnetoOptical = 1, - /// Generic hard disk - HardDisk = 2, - /// Microdrive type hard disk - Microdrive = 3, - /// Zoned hard disk - ZonedHardDisk = 4, - /// USB flash drives - FlashDrive = 5, - /// CompactDisc - CompactDisc = 6, - /// Double-Density CompactDisc (Purple Book) - DDCD = 7, - /// 120mm, Phase-Change, 1298496 sectors, 512 bytes/sector, PD650, ECMA-240, ISO 15485 - PD650 = 8, - /// DVD - Dvd = 9, - /// DVD-RAM (cartridge only) - DVDRAM = 10, - /// HD DVD - HDDVDROM = 11, - /// Blu-ray Disc - Bluray = 12, - /// Enhanced Versatile Disc - EVD = 13, - /// Forward Versatile Disc - FVD = 14, - /// Holographic Versatile Disc - HVD = 15, - /// China Blue High Definition - CBHD = 16, - /// High Definition Versatile Multilayer Disc - HDVMD = 17, - /// Versatile Compact Disc High Density - VCDHD = 18, - /// Stacked Volumetric Optical Disc - SVOD = 19, - /// Five Dimensional disc - FDDVD = 20, - /// Pioneer LaserDisc - LD = 21, - /// Pioneer LaserDisc data - LDROM = 22, LDROM2 = 23, LVROM = 24, MegaLD = 254, - /// Sony Hi-MD - HiMD = 26, - /// Sony MiniDisc - MD = 27, MDData = 28, MDData2 = 29, - /// 5.25", Phase-Change, 1834348 sectors, 8192 bytes/sector, Ultra Density Optical, ECMA-350, ISO 17345 - UDO = 30, - /// 5.25", Phase-Change, 3669724 sectors, 8192 bytes/sector, Ultra Density Optical 2, ECMA-380, ISO 11976 - UDO2 = 31, PlayStationMemoryCard = 32, PlayStationMemoryCard2 = 33, - /// Sony PlayStation game CD - PS1CD = 34, - /// Sony PlayStation 2 game CD - PS2CD = 35, - /// Sony PlayStation 2 game DVD - PS2DVD = 36, - /// Sony PlayStation 3 game DVD - PS3DVD = 37, - /// Sony PlayStation 3 game Blu-ray - PS3BD = 38, - /// Sony PlayStation 4 game Blu-ray - PS4BD = 39, - /// Sony PlayStation Portable Universal Media Disc (ECMA-365) - UMD = 40, - /// Microsoft X-box Game Disc - XGD = 41, - /// Microsoft X-box 360 Game Disc - XGD2 = 42, - /// Microsoft X-box 360 Game Disc - XGD3 = 43, - /// Microsoft X-box One Game Disc - XGD4 = 44, - /// Sega MegaCD - MEGACD = 45, - /// Sega Saturn disc - SATURNCD = 46, - /// Sega/Yamaha Gigabyte Disc - GDROM = 47, SegaCard = 48, - /// PC-Engine / TurboGrafx cartridge - HuCard = 49, - /// PC-Engine / TurboGrafx CD - SuperCDROM2 = 50, - /// Atari Jaguar CD - JaguarCD = 51, - /// 3DO CD - ThreeDO = 52, - /// NEC PC-FX - PCFX = 53, - /// NEO-GEO CD - NeoGeoCD = 54, - /// 8" floppy - Floppy = 55, - /// 5.25" floppy - Minifloppy = 56, - /// 3.5" floppy - Microfloppy = 57, - /// 5.25", DS, ?D, ?? tracks, ?? spt, 512 bytes/sector, GCR, opposite side heads, aka Twiggy - AppleFileWare = 58, Bernoulli = 59, Bernoulli2 = 60, Ditto = 61, - DittoMax = 62, Jaz = 63, Jaz2 = 64, - PocketZip = 65, REV120 = 66, REV35 = 67, - REV70 = 68, ZIP100 = 69, ZIP250 = 70, - ZIP750 = 71, CompactCassette = 72, Data8 = 73, - MiniDV = 74, CFast = 75, CompactFlash = 76, - CompactFlashType2 = 77, EZ135 = 78, EZ230 = 79, - Quest = 80, SparQ = 81, SQ100 = 82, - SQ200 = 83, SQ300 = 84, SQ310 = 85, - SQ327 = 86, SQ400 = 87, SQ800 = 88, - SQ1500 = 89, SQ2000 = 90, SyJet = 91, - FamicomGamePak = 92, GameBoyAdvanceGamePak = 93, GameBoyGamePak = 94, - GOD = 95, N64DD = 96, N64GamePak = 97, - NESGamePak = 98, Nintendo3DSGameCard = 99, NintendoDiskCard = 100, - NintendoDSGameCard = 101, NintendoDSiGameCard = 102, SNESGamePak = 103, - SNESGamePakUS = 104, WOD = 105, WUOD = 106, - SwitchGameCard = 107, MemoryStick = 108, MemoryStickDuo = 109, - MemoryStickMicro = 110, MemoryStickPro = 111, MemoryStickProDuo = 112, - microSD = 113, miniSD = 114, SecureDigital = 115, - MMC = 116, MMCmicro = 117, RSMMC = 118, - MMCplus = 118, MMCmobile = 119, eMMC = 120, - MO120 = 121, MO90 = 122, MO300 = 123, - MO356 = 124, CompactFloppy = 125, DemiDiskette = 126, - /// 3.5", 652 tracks, 2 sides, 512 bytes/sector, Floptical, ECMA-207, ISO 14169 - Floptical = 127, HiFD = 128, QuickDisk = 129, UHD144 = 130, - VideoFloppy = 131, Wafer = 132, ZXMicrodrive = 133, - BeeCard = 134, Borsu = 135, DataStore = 136, - MiniCard = 137, Orb = 138, Orb5 = 139, - SmartMedia = 140, xD = 141, XQD = 142, - DataPlay = 143, LS120 = 144, LS240 = 145, - FD32MB = 146, RDX = 147, PunchedCard = 148 - } +public enum StorageType +{ + /// Contains an empty interface for user connection + Empty = -1, + /// Unknown + Unknown = 0, + /// Unknown magneto-optical + MagnetoOptical = 1, + /// Generic hard disk + HardDisk = 2, + /// Microdrive type hard disk + Microdrive = 3, + /// Zoned hard disk + ZonedHardDisk = 4, + /// USB flash drives + FlashDrive = 5, + /// CompactDisc + CompactDisc = 6, + /// Double-Density CompactDisc (Purple Book) + DDCD = 7, + /// 120mm, Phase-Change, 1298496 sectors, 512 bytes/sector, PD650, ECMA-240, ISO 15485 + PD650 = 8, + /// DVD + Dvd = 9, + /// DVD-RAM (cartridge only) + DVDRAM = 10, + /// HD DVD + HDDVDROM = 11, + /// Blu-ray Disc + Bluray = 12, + /// Enhanced Versatile Disc + EVD = 13, + /// Forward Versatile Disc + FVD = 14, + /// Holographic Versatile Disc + HVD = 15, + /// China Blue High Definition + CBHD = 16, + /// High Definition Versatile Multilayer Disc + HDVMD = 17, + /// Versatile Compact Disc High Density + VCDHD = 18, + /// Stacked Volumetric Optical Disc + SVOD = 19, + /// Five Dimensional disc + FDDVD = 20, + /// Pioneer LaserDisc + LD = 21, + /// Pioneer LaserDisc data + LDROM = 22, + LDROM2 = 23, + LVROM = 24, + MegaLD = 254, + /// Sony Hi-MD + HiMD = 26, + /// Sony MiniDisc + MD = 27, + MDData = 28, + MDData2 = 29, + /// 5.25", Phase-Change, 1834348 sectors, 8192 bytes/sector, Ultra Density Optical, ECMA-350, ISO 17345 + UDO = 30, + /// 5.25", Phase-Change, 3669724 sectors, 8192 bytes/sector, Ultra Density Optical 2, ECMA-380, ISO 11976 + UDO2 = 31, + PlayStationMemoryCard = 32, + PlayStationMemoryCard2 = 33, + /// Sony PlayStation game CD + PS1CD = 34, + /// Sony PlayStation 2 game CD + PS2CD = 35, + /// Sony PlayStation 2 game DVD + PS2DVD = 36, + /// Sony PlayStation 3 game DVD + PS3DVD = 37, + /// Sony PlayStation 3 game Blu-ray + PS3BD = 38, + /// Sony PlayStation 4 game Blu-ray + PS4BD = 39, + /// Sony PlayStation Portable Universal Media Disc (ECMA-365) + UMD = 40, + /// Microsoft X-box Game Disc + XGD = 41, + /// Microsoft X-box 360 Game Disc + XGD2 = 42, + /// Microsoft X-box 360 Game Disc + XGD3 = 43, + /// Microsoft X-box One Game Disc + XGD4 = 44, + /// Sega MegaCD + MEGACD = 45, + /// Sega Saturn disc + SATURNCD = 46, + /// Sega/Yamaha Gigabyte Disc + GDROM = 47, + SegaCard = 48, + /// PC-Engine / TurboGrafx cartridge + HuCard = 49, + /// PC-Engine / TurboGrafx CD + SuperCDROM2 = 50, + /// Atari Jaguar CD + JaguarCD = 51, + /// 3DO CD + ThreeDO = 52, + /// NEC PC-FX + PCFX = 53, + /// NEO-GEO CD + NeoGeoCD = 54, + /// 8" floppy + Floppy = 55, + /// 5.25" floppy + Minifloppy = 56, + /// 3.5" floppy + Microfloppy = 57, + /// 5.25", DS, ?D, ?? tracks, ?? spt, 512 bytes/sector, GCR, opposite side heads, aka Twiggy + AppleFileWare = 58, + Bernoulli = 59, + Bernoulli2 = 60, + Ditto = 61, + DittoMax = 62, + Jaz = 63, + Jaz2 = 64, + PocketZip = 65, + REV120 = 66, + REV35 = 67, + REV70 = 68, + ZIP100 = 69, + ZIP250 = 70, + ZIP750 = 71, + CompactCassette = 72, + Data8 = 73, + MiniDV = 74, + CFast = 75, + CompactFlash = 76, + CompactFlashType2 = 77, + EZ135 = 78, + EZ230 = 79, + Quest = 80, + SparQ = 81, + SQ100 = 82, + SQ200 = 83, + SQ300 = 84, + SQ310 = 85, + SQ327 = 86, + SQ400 = 87, + SQ800 = 88, + SQ1500 = 89, + SQ2000 = 90, + SyJet = 91, + FamicomGamePak = 92, + GameBoyAdvanceGamePak = 93, + GameBoyGamePak = 94, + GOD = 95, + N64DD = 96, + N64GamePak = 97, + NESGamePak = 98, + Nintendo3DSGameCard = 99, + NintendoDiskCard = 100, + NintendoDSGameCard = 101, + NintendoDSiGameCard = 102, + SNESGamePak = 103, + SNESGamePakUS = 104, + WOD = 105, + WUOD = 106, + SwitchGameCard = 107, + MemoryStick = 108, + MemoryStickDuo = 109, + MemoryStickMicro = 110, + MemoryStickPro = 111, + MemoryStickProDuo = 112, + microSD = 113, + miniSD = 114, + SecureDigital = 115, + MMC = 116, + MMCmicro = 117, + RSMMC = 118, + MMCplus = 118, + MMCmobile = 119, + eMMC = 120, + MO120 = 121, + MO90 = 122, + MO300 = 123, + MO356 = 124, + CompactFloppy = 125, + DemiDiskette = 126, + /// 3.5", 652 tracks, 2 sides, 512 bytes/sector, Floptical, ECMA-207, ISO 14169 + Floptical = 127, + HiFD = 128, + QuickDisk = 129, + UHD144 = 130, + VideoFloppy = 131, + Wafer = 132, + ZXMicrodrive = 133, + BeeCard = 134, + Borsu = 135, + DataStore = 136, + MiniCard = 137, + Orb = 138, + Orb5 = 139, + SmartMedia = 140, + xD = 141, + XQD = 142, + DataPlay = 143, + LS120 = 144, + LS240 = 145, + FD32MB = 146, + RDX = 147, + PunchedCard = 148 +} - public enum StorageInterface - { - Unknown = 0, ACSI = 1, ATA = 2, - XTA = 3, ESDI = 4, SCSI = 5, - USB = 6, FireWire = 7, SASI = 8, - ST506 = 9, IPI = 10, SMD = 11, - SATA = 12, SSA = 13, DSSI = 14, - HIPPI = 15, SAS = 16, FC = 17, - PCIe = 18, M2 = 19, SataExpress = 20 - } +public enum StorageInterface +{ + Unknown = 0, + ACSI = 1, + ATA = 2, + XTA = 3, + ESDI = 4, + SCSI = 5, + USB = 6, + FireWire = 7, + SASI = 8, + ST506 = 9, + IPI = 10, + SMD = 11, + SATA = 12, + SSA = 13, + DSSI = 14, + HIPPI = 15, + SAS = 16, + FC = 17, + PCIe = 18, + M2 = 19, + SataExpress = 20 +} - public enum ColorSpace : ushort - { - [Display(Name = "sRGB")] - Srgb = 1, [Display(Name = "Adobe RGB")] - AdobeRgb = 2, [Display(Name = "Wide Gamut RGB")] - WideGamutRgb = 4093, [Display(Name = "ICC Profile")] - IccProfile = 65534, [Display(Name = "Uncalibrated")] - Uncalibrated = 65535 - } +public enum ColorSpace : ushort +{ + [Display(Name = "sRGB")] + Srgb = 1, + [Display(Name = "Adobe RGB")] + AdobeRgb = 2, + [Display(Name = "Wide Gamut RGB")] + WideGamutRgb = 4093, + [Display(Name = "ICC Profile")] + IccProfile = 65534, + [Display(Name = "Uncalibrated")] + Uncalibrated = 65535 +} - public enum Contrast : ushort - { - Normal = 0, Low = 1, High = 2 - } +public enum Contrast : ushort +{ + Normal = 0, + Low = 1, + High = 2 +} - public enum ExposureMode : ushort - { - Auto = 0, Manual = 1, [Display(Name = "Auto bracket")] - AutoBracket = 2 - } +public enum ExposureMode : ushort +{ + Auto = 0, + Manual = 1, + [Display(Name = "Auto bracket")] + AutoBracket = 2 +} - public enum ExposureProgram : ushort - { - [Display(Name = "Not Defined")] - Undefined = 0, [Display(Name = "Manual")] - Manual = 1, [Display(Name = "Program AE")] - ProgramAe = 2, [Display(Name = "Aperture-priority AE")] - ApAe = 3, [Display(Name = "Shutter speed priority AE")] - ShutterAe = 4, [Display(Name = "Creative (Slow speed)")] - Creative = 5, [Display(Name = "Action (High speed)")] - Action = 6, [Display(Name = "Portrait")] - Portrait = 7, [Display(Name = "Landscape")] - Landscape = 8, [Display(Name = "Bulb")] - Bulb = 9 - } +public enum ExposureProgram : ushort +{ + [Display(Name = "Not Defined")] + Undefined = 0, + [Display(Name = "Manual")] + Manual = 1, + [Display(Name = "Program AE")] + ProgramAe = 2, + [Display(Name = "Aperture-priority AE")] + ApAe = 3, + [Display(Name = "Shutter speed priority AE")] + ShutterAe = 4, + [Display(Name = "Creative (Slow speed)")] + Creative = 5, + [Display(Name = "Action (High speed)")] + Action = 6, + [Display(Name = "Portrait")] + Portrait = 7, + [Display(Name = "Landscape")] + Landscape = 8, + [Display(Name = "Bulb")] + Bulb = 9 +} - public enum Flash : ushort - { - [Display(Name = "No Flash")] - None = 0, [Display(Name = "Fired")] - Fired = 1, [Display(Name = "Fired, Return not detected")] - FiredNoReturn = 5, [Display(Name = "Fired, Return detected")] - FiredReturn = 7, [Display(Name = "On, Did not fire")] - OnDidNotFire = 8, [Display(Name = "On, Fired")] - OnFired = 9, [Display(Name = "On, Return not detected")] - OnNoReturn = 13, [Display(Name = "On, Return detected")] - OnReturn = 15, [Display(Name = "Off, Did not fire")] - OffDidNotFire = 16, [Display(Name = "Off, Did not fire, Return not detected")] - OffDidNotFireNoReturn = 20, [Display(Name = "Auto, Did not fire")] - AutoDidNotFire = 24, [Display(Name = "Auto, Fired")] - AutoFired = 25, [Display(Name = "Auto, Fired, Return not detected")] - AutoFiredNoReturn = 29, [Display(Name = "Auto, Fired, Return detected")] - AutoFiredReturn = 31, [Display(Name = "No flash function")] - NoFlash = 32, [Display(Name = "Off, No flash function")] - OffNoFlash = 48, [Display(Name = "Fired, Red-eye reduction")] - FiredRedEye = 65, [Display(Name = "Fired, Red-eye reduction, Return not detected")] - FiredRedEyeNoReturn = 69, [Display(Name = "Fired, Red-eye reduction, Return detected")] - FiredRedEyeReturn = 71, [Display(Name = "On, Red-eye reduction")] - OnRedEye = 73, [Display(Name = "On, Red-eye reduction, Return not detected")] - OnRedEyeNoReturn = 77, [Display(Name = "On, Red-eye reduction, Return detected")] - OnRedEyeReturn = 79, [Display(Name = "Off, Red-eye reduction")] - OffRedEye = 80, [Display(Name = "Auto, Did not fire, Red-eye reduction")] - AutoNotFireRedEye = 88, [Display(Name = "Auto, Fired, Red-eye reduction")] - AutoFiredRedEye = 89, [Display(Name = "Auto, Fired, Red-eye reduction, Return not detected")] - AutoFiredRedEyeNoReturn = 93, [Display(Name = "Auto, Fired, Red-eye reduction, Return detected")] - AutoFiredRedEyeReturn = 95 - } +public enum Flash : ushort +{ + [Display(Name = "No Flash")] + None = 0, + [Display(Name = "Fired")] + Fired = 1, + [Display(Name = "Fired, Return not detected")] + FiredNoReturn = 5, + [Display(Name = "Fired, Return detected")] + FiredReturn = 7, + [Display(Name = "On, Did not fire")] + OnDidNotFire = 8, + [Display(Name = "On, Fired")] + OnFired = 9, + [Display(Name = "On, Return not detected")] + OnNoReturn = 13, + [Display(Name = "On, Return detected")] + OnReturn = 15, + [Display(Name = "Off, Did not fire")] + OffDidNotFire = 16, + [Display(Name = "Off, Did not fire, Return not detected")] + OffDidNotFireNoReturn = 20, + [Display(Name = "Auto, Did not fire")] + AutoDidNotFire = 24, + [Display(Name = "Auto, Fired")] + AutoFired = 25, + [Display(Name = "Auto, Fired, Return not detected")] + AutoFiredNoReturn = 29, + [Display(Name = "Auto, Fired, Return detected")] + AutoFiredReturn = 31, + [Display(Name = "No flash function")] + NoFlash = 32, + [Display(Name = "Off, No flash function")] + OffNoFlash = 48, + [Display(Name = "Fired, Red-eye reduction")] + FiredRedEye = 65, + [Display(Name = "Fired, Red-eye reduction, Return not detected")] + FiredRedEyeNoReturn = 69, + [Display(Name = "Fired, Red-eye reduction, Return detected")] + FiredRedEyeReturn = 71, + [Display(Name = "On, Red-eye reduction")] + OnRedEye = 73, + [Display(Name = "On, Red-eye reduction, Return not detected")] + OnRedEyeNoReturn = 77, + [Display(Name = "On, Red-eye reduction, Return detected")] + OnRedEyeReturn = 79, + [Display(Name = "Off, Red-eye reduction")] + OffRedEye = 80, + [Display(Name = "Auto, Did not fire, Red-eye reduction")] + AutoNotFireRedEye = 88, + [Display(Name = "Auto, Fired, Red-eye reduction")] + AutoFiredRedEye = 89, + [Display(Name = "Auto, Fired, Red-eye reduction, Return not detected")] + AutoFiredRedEyeNoReturn = 93, + [Display(Name = "Auto, Fired, Red-eye reduction, Return detected")] + AutoFiredRedEyeReturn = 95 +} - public enum LightSource : ushort - { - [Display(Name = "Unknown")] - Unknown = 0, [Display(Name = "Daylight")] - Daylight = 1, [Display(Name = "Fluorescent")] - Fluorescent = 2, [Display(Name = "Tungsten (Incandescent)")] - Incandescent = 3, [Display(Name = "Flash")] - Flash = 4, [Display(Name = "Fine Weather")] - FineWeather = 9, [Display(Name = "Cloudy")] - Cloudy = 10, [Display(Name = "Shade")] - Shade = 11, [Display(Name = "Daylight Fluorescent")] - DaylightFluorescent = 12, [Display(Name = "Day White Fluorescent")] - DayWhiteFluorescent = 13, [Display(Name = "Cool White Fluorescent")] - CoolWhiteFluorescent = 14, [Display(Name = "White Fluorescent")] - WhiteFluorescent = 15, [Display(Name = "Warm White Fluorescent")] - WarmWhiteFluorescent = 16, [Display(Name = "Standard Light A")] - StandardLightA = 17, [Display(Name = "Standard Light B")] - StandardLightB = 18, [Display(Name = "Standard Light C")] - StandardLightC = 19, [Display(Name = "D55")] - D55 = 20, [Display(Name = "D65")] - D65 = 21, [Display(Name = "D75")] - D75 = 22, [Display(Name = "D50")] - D50 = 23, [Display(Name = "ISO Studio Tungsten")] - ISOStudioTungsten = 24, [Display(Name = "Other")] - Other = 255 - } +public enum LightSource : ushort +{ + [Display(Name = "Unknown")] + Unknown = 0, + [Display(Name = "Daylight")] + Daylight = 1, + [Display(Name = "Fluorescent")] + Fluorescent = 2, + [Display(Name = "Tungsten (Incandescent)")] + Incandescent = 3, + [Display(Name = "Flash")] + Flash = 4, + [Display(Name = "Fine Weather")] + FineWeather = 9, + [Display(Name = "Cloudy")] + Cloudy = 10, + [Display(Name = "Shade")] + Shade = 11, + [Display(Name = "Daylight Fluorescent")] + DaylightFluorescent = 12, + [Display(Name = "Day White Fluorescent")] + DayWhiteFluorescent = 13, + [Display(Name = "Cool White Fluorescent")] + CoolWhiteFluorescent = 14, + [Display(Name = "White Fluorescent")] + WhiteFluorescent = 15, + [Display(Name = "Warm White Fluorescent")] + WarmWhiteFluorescent = 16, + [Display(Name = "Standard Light A")] + StandardLightA = 17, + [Display(Name = "Standard Light B")] + StandardLightB = 18, + [Display(Name = "Standard Light C")] + StandardLightC = 19, + [Display(Name = "D55")] + D55 = 20, + [Display(Name = "D65")] + D65 = 21, + [Display(Name = "D75")] + D75 = 22, + [Display(Name = "D50")] + D50 = 23, + [Display(Name = "ISO Studio Tungsten")] + ISOStudioTungsten = 24, + [Display(Name = "Other")] + Other = 255 +} - public enum MeteringMode : ushort - { - [Display(Name = "Unknown")] - Unknown = 0, [Display(Name = "Average")] - Average = 1, [Display(Name = "Center-weighted average")] - CenterWeightedAverage = 2, [Display(Name = "Spot")] - Spot = 3, [Display(Name = "Multi-spot")] - MultiSpot = 4, [Display(Name = "Multi-segment")] - MultiSegment = 5, [Display(Name = "Partial")] - Partial = 6, [Display(Name = "Other")] - Other = 255 - } +public enum MeteringMode : ushort +{ + [Display(Name = "Unknown")] + Unknown = 0, + [Display(Name = "Average")] + Average = 1, + [Display(Name = "Center-weighted average")] + CenterWeightedAverage = 2, + [Display(Name = "Spot")] + Spot = 3, + [Display(Name = "Multi-spot")] + MultiSpot = 4, + [Display(Name = "Multi-segment")] + MultiSegment = 5, + [Display(Name = "Partial")] + Partial = 6, + [Display(Name = "Other")] + Other = 255 +} - public enum Orientation : ushort - { - [Display(Name = "Horizontal (normal)")] - Horizontal = 1, [Display(Name = "Mirror horizontal")] - MirrorHorizontal = 2, [Display(Name = "Rotate 180")] - Rotate180 = 3, [Display(Name = "Mirror vertical")] - MirrorVertical = 4, [Display(Name = "Mirror horizontal and rotate 270 CW")] - MirrorHorizontalAndRotate270CW = 5, [Display(Name = "Rotate 90 CW")] - Rotate90CW = 6, [Display(Name = "Mirror horizontal and rotate 90 CW")] - MirrorHorizontalAndRotate90CW = 7, [Display(Name = "Rotate 270 CW")] - Rotate270CW = 8 - } +public enum Orientation : ushort +{ + [Display(Name = "Horizontal (normal)")] + Horizontal = 1, + [Display(Name = "Mirror horizontal")] + MirrorHorizontal = 2, + [Display(Name = "Rotate 180")] + Rotate180 = 3, + [Display(Name = "Mirror vertical")] + MirrorVertical = 4, + [Display(Name = "Mirror horizontal and rotate 270 CW")] + MirrorHorizontalAndRotate270CW = 5, + [Display(Name = "Rotate 90 CW")] + Rotate90CW = 6, + [Display(Name = "Mirror horizontal and rotate 90 CW")] + MirrorHorizontalAndRotate90CW = 7, + [Display(Name = "Rotate 270 CW")] + Rotate270CW = 8 +} - public enum ResolutionUnit : ushort - { - None = 1, Inches = 2, Centimeters = 3 - } +public enum ResolutionUnit : ushort +{ + None = 1, + Inches = 2, + Centimeters = 3 +} - public enum Saturation : ushort - { - Normal = 0, Low = 1, High = 2 - } +public enum Saturation : ushort +{ + Normal = 0, + Low = 1, + High = 2 +} - public enum SceneCaptureType : ushort - { - Standard = 0, Landscape = 1, Portrait = 2, - Night = 3 - } +public enum SceneCaptureType : ushort +{ + Standard = 0, + Landscape = 1, + Portrait = 2, + Night = 3 +} - public enum SensingMethod : ushort - { - [Display(Name = "Not defined")] - Undefined = 1, [Display(Name = "One-chip color area")] - OneChipColorArea = 2, [Display(Name = "Two-chip color area")] - TwoChipColorArea = 3, [Display(Name = "Three-chip color area")] - ThreeChipColorArea = 4, [Display(Name = "Color sequential area")] - ColorSequentialArea = 5, [Display(Name = "Trilinear")] - Trilinear = 7, [Display(Name = "Color sequential linear")] - ColorSequentialLinear = 8 - } +public enum SensingMethod : ushort +{ + [Display(Name = "Not defined")] + Undefined = 1, + [Display(Name = "One-chip color area")] + OneChipColorArea = 2, + [Display(Name = "Two-chip color area")] + TwoChipColorArea = 3, + [Display(Name = "Three-chip color area")] + ThreeChipColorArea = 4, + [Display(Name = "Color sequential area")] + ColorSequentialArea = 5, + [Display(Name = "Trilinear")] + Trilinear = 7, + [Display(Name = "Color sequential linear")] + ColorSequentialLinear = 8 +} - public enum SubjectDistanceRange : ushort - { - Unknown = 0, Macro = 1, Close = 2, - Distant = 3 - } +public enum SubjectDistanceRange : ushort +{ + Unknown = 0, + Macro = 1, + Close = 2, + Distant = 3 +} - public enum WhiteBalance : ushort - { - Auto = 0, Manual = 1 - } +public enum WhiteBalance : ushort +{ + Auto = 0, + Manual = 1 +} - public enum Sharpness : ushort - { - Normal = 0, Low = 1, High = 2 - } +public enum Sharpness : ushort +{ + Normal = 0, + Low = 1, + High = 2 +} - public enum AuditType : byte - { - None = 0, Created = 1, Updated = 2, - Deleted = 3 - } +public enum AuditType : byte +{ + None = 0, + Created = 1, + Updated = 2, + Deleted = 3 +} - [Flags] - public enum DumpStatus : ulong - { - Unknown = 0, Cracked = 1 << 0, Fixed = 1 << 1, - Hacked = 1 << 2, Modified = 1 << 3, Pirated = 1 << 4, - Trained = 1 << 5, Translated = 1 << 6, Overdumped = 1 << 7, - Underdumped = 1 << 8, Infected = 1 << 9, Damaged = 1 << 10, - Verified = 1 << 11, MissingData = 1 << 12, MissingNonRequiredData = 1 << 13, - MissingEssentialData = 1 << 14, DamagedSubchannel = 1 << 15 - } +[Flags] +public enum DumpStatus : ulong +{ + Unknown = 0, + Cracked = 1 << 0, + Fixed = 1 << 1, + Hacked = 1 << 2, + Modified = 1 << 3, + Pirated = 1 << 4, + Trained = 1 << 5, + Translated = 1 << 6, + Overdumped = 1 << 7, + Underdumped = 1 << 8, + Infected = 1 << 9, + Damaged = 1 << 10, + Verified = 1 << 11, + MissingData = 1 << 12, + MissingNonRequiredData = 1 << 13, + MissingEssentialData = 1 << 14, + DamagedSubchannel = 1 << 15 +} - [Flags] - public enum SubchannelStatus : byte - { - None = 0, P = 1 << 0, Q = 1 << 1, - R = 1 << 2, S = 1 << 3, T = 1 << 4, - U = 1 << 5, V = 1 << 6, W = 1 << 7 - } +[Flags] +public enum SubchannelStatus : byte +{ + None = 0, + P = 1 << 0, + Q = 1 << 1, + R = 1 << 2, + S = 1 << 3, + T = 1 << 4, + U = 1 << 5, + V = 1 << 6, + W = 1 << 7 +} - public enum DistributionMode : uint - { - Unknown = 0, Retail = 1, Bundle = 2, - Oem = 3 - } +public enum DistributionMode : uint +{ + Unknown = 0, + Retail = 1, + Bundle = 2, + Oem = 3 +} - public enum MasteringTextType : byte - { - Unknown = 0, LotNumber = 1, MasteringSid = 2, - MouldSid = 3, MasteringCode = 4, Barcode = 5, - Toolstamp = 6 - } +public enum MasteringTextType : byte +{ + Unknown = 0, + LotNumber = 1, + MasteringSid = 2, + MouldSid = 3, + MasteringCode = 4, + Barcode = 5, + Toolstamp = 6 +} - public enum DocumentScanType : uint - { - Page = 0, Cover = 1, BackCover = 2, - TableOfContents = 3, Index = 4, CopyrightPage = 5 - } +public enum DocumentScanType : uint +{ + Page = 0, + Cover = 1, + BackCover = 2, + TableOfContents = 3, + Index = 4, + CopyrightPage = 5 } \ No newline at end of file diff --git a/Marechai.Database/IDbCore.cs b/Marechai.Database/IDbCore.cs index 20f7129e..d4e0da48 100644 --- a/Marechai.Database/IDbCore.cs +++ b/Marechai.Database/IDbCore.cs @@ -25,33 +25,32 @@ using System.Data; -namespace Marechai.Database +namespace Marechai.Database; + +/// Interface to database +public interface IDbCore { - /// Interface to database - public interface IDbCore - { - /// Database operations - Operations Operations { get; } + /// Database operations + Operations Operations { get; } - /// Last inserted row's ID - long LastInsertRowId { get; } + /// Last inserted row's ID + long LastInsertRowId { get; } - /// Opens an existing database - /// Server - /// User - /// Database name - /// Password - /// Port - /// true if database opened correctly, false otherwise - bool OpenDb(string server, string user, string database, string password, ushort port); + /// Opens an existing database + /// Server + /// User + /// Database name + /// Password + /// Port + /// true if database opened correctly, false otherwise + bool OpenDb(string server, string user, string database, string password, ushort port); - /// Closes the database - void CloseDb(); + /// Closes the database + void CloseDb(); - /// Gets a data adapter for the opened database - /// Data adapter - IDbDataAdapter GetNewDataAdapter(); + /// Gets a data adapter for the opened database + /// Data adapter + IDbDataAdapter GetNewDataAdapter(); - bool TableExists(string tableName); - } + bool TableExists(string tableName); } \ No newline at end of file diff --git a/Marechai.Database/Marechai.Database.csproj b/Marechai.Database/Marechai.Database.csproj index 117b4375..abf7b84c 100644 --- a/Marechai.Database/Marechai.Database.csproj +++ b/Marechai.Database/Marechai.Database.csproj @@ -4,15 +4,15 @@ Marechai.Database - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + \ No newline at end of file diff --git a/Marechai.Database/Migrations/20180805214952_InitialMigration.cs b/Marechai.Database/Migrations/20180805214952_InitialMigration.cs index 6e052480..9fff7d1d 100644 --- a/Marechai.Database/Migrations/20180805214952_InitialMigration.cs +++ b/Marechai.Database/Migrations/20180805214952_InitialMigration.cs @@ -24,6 +24,7 @@ *******************************************************************************/ using System; +using System.Diagnostics.CodeAnalysis; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -31,6 +32,7 @@ namespace Marechai.Database.Migrations { public partial class InitialMigration : Migration { + [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments", Justification = "The method is called just once")] protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable("admins", table => new diff --git a/Marechai.Database/Migrations/20190527160705_Licenses.cs b/Marechai.Database/Migrations/20190527160705_Licenses.cs index 8d32f605..53fa6f2b 100644 --- a/Marechai.Database/Migrations/20190527160705_Licenses.cs +++ b/Marechai.Database/Migrations/20190527160705_Licenses.cs @@ -1,10 +1,12 @@ -using Microsoft.EntityFrameworkCore.Metadata; +using System.Diagnostics.CodeAnalysis; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; namespace Marechai.Database.Migrations { public partial class Licenses : Migration { + [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments", Justification = "The method is called just once.")] protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable("Licenses", table => new diff --git a/Marechai.Database/Migrations/20190616211045_AddDocumentRoles.cs b/Marechai.Database/Migrations/20190616211045_AddDocumentRoles.cs index 0cd9a09d..8d3a41c1 100644 --- a/Marechai.Database/Migrations/20190616211045_AddDocumentRoles.cs +++ b/Marechai.Database/Migrations/20190616211045_AddDocumentRoles.cs @@ -1,9 +1,11 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using System.Diagnostics.CodeAnalysis; +using Microsoft.EntityFrameworkCore.Migrations; namespace Marechai.Database.Migrations { public partial class AddDocumentRoles : Migration { + [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments", Justification = "The method is called just once.")] protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable("DocumentRoles", table => new diff --git a/Marechai.Database/Migrations/20200523172033_MoveSeedOutOfBuilder.cs b/Marechai.Database/Migrations/20200523172033_MoveSeedOutOfBuilder.cs index 1de0db62..9217e02b 100644 --- a/Marechai.Database/Migrations/20200523172033_MoveSeedOutOfBuilder.cs +++ b/Marechai.Database/Migrations/20200523172033_MoveSeedOutOfBuilder.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using System.Diagnostics.CodeAnalysis; +using Microsoft.EntityFrameworkCore.Migrations; namespace Marechai.Database.Migrations { @@ -1275,6 +1276,7 @@ namespace Marechai.Database.Migrations migrationBuilder.DeleteData("Licenses", "Id", 363); } + [SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments", Justification = "The method is called just once.")] protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.InsertData("DocumentRoles", new[] diff --git a/Marechai.Database/Models/ApplicationRole.cs b/Marechai.Database/Models/ApplicationRole.cs index 475c0387..c9f43645 100644 --- a/Marechai.Database/Models/ApplicationRole.cs +++ b/Marechai.Database/Models/ApplicationRole.cs @@ -26,38 +26,37 @@ using System; using Microsoft.AspNetCore.Identity; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class ApplicationRole : IdentityRole { - public class ApplicationRole : IdentityRole + public const string RoleUberAdmin = "UberAdmin"; + public const string RoleWriter = "Writer"; + public const string RoleProofreader = "Proofreader"; + public const string RoleTranslator = "Translator"; + public const string RoleSuperTranslator = "SuperTranslator"; + public const string RoleCollaborator = "Collaborator"; + public const string RoleCurator = "Curator"; + public const string RolePhysicalCurator = "PhysicalCurator"; + public const string RoleTechnician = "Technician"; + public const string RoleSuperTechnician = "SuperTechnician"; + public const string RoleAdmin = "Administrator"; + public const string RoleNone = "NormalUser"; + + public ApplicationRole() => Created = DateTime.UtcNow; + + public ApplicationRole(string name) : base(name) { - public const string ROLE_UBERADMIN = "UberAdmin"; - public const string ROLE_WRITER = "Writer"; - public const string ROLE_PROOFREADER = "Proofreader"; - public const string ROLE_TRANSLATOR = "Translator"; - public const string ROLE_SUPERTRANSLATOR = "SuperTranslator"; - public const string ROLE_COLLABORATOR = "Collaborator"; - public const string ROLE_CURATOR = "Curator"; - public const string ROLE_PHYSICALCURATOR = "PhysicalCurator"; - public const string ROLE_TECHNICIAN = "Technician"; - public const string ROLE_SUPERTECHNICIAN = "SuperTechnician"; - public const string ROLE_ADMIN = "Administrator"; - public const string ROLE_NONE = "NormalUser"; - - public ApplicationRole() => Created = DateTime.UtcNow; - - public ApplicationRole(string name) : base(name) - { - Description = name; - Created = DateTime.UtcNow; - } - - public ApplicationRole(string name, string description) : base(name) - { - Description = description; - Created = DateTime.UtcNow; - } - - public string Description { get; set; } - public DateTime Created { get; set; } + Description = name; + Created = DateTime.UtcNow; } + + public ApplicationRole(string name, string description) : base(name) + { + Description = description; + Created = DateTime.UtcNow; + } + + public string Description { get; set; } + public DateTime Created { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/ApplicationUser.cs b/Marechai.Database/Models/ApplicationUser.cs index 89dd3003..502e360a 100644 --- a/Marechai.Database/Models/ApplicationUser.cs +++ b/Marechai.Database/Models/ApplicationUser.cs @@ -26,16 +26,15 @@ using System.Collections.Generic; using Microsoft.AspNetCore.Identity; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class ApplicationUser : IdentityUser { - public class ApplicationUser : IdentityUser - { - public virtual ICollection Photos { get; set; } - public virtual ICollection OwnedMachinePhotos { get; set; } - public virtual ICollection OwnedMachines { get; set; } - public virtual ICollection Dumps { get; set; } - public virtual ICollection BookScans { get; set; } - public virtual ICollection DocumentScans { get; set; } - public virtual ICollection MagazineScans { get; set; } - } + public virtual ICollection Photos { get; set; } + public virtual ICollection OwnedMachinePhotos { get; set; } + public virtual ICollection OwnedMachines { get; set; } + public virtual ICollection Dumps { get; set; } + public virtual ICollection BookScans { get; set; } + public virtual ICollection DocumentScans { get; set; } + public virtual ICollection MagazineScans { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Audit.cs b/Marechai.Database/Models/Audit.cs index eec22642..f7049bc8 100644 --- a/Marechai.Database/Models/Audit.cs +++ b/Marechai.Database/Models/Audit.cs @@ -2,24 +2,23 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class Audit : BaseModel - { - public AuditType Type { get; set; } - [Required] - public string UserId { get; set; } - public string Table { get; set; } - [Column(TypeName = "json")] - public Dictionary Keys { get; set; } - [Column(TypeName = "json")] - public Dictionary OldValues { get; set; } - [Column(TypeName = "json")] - public Dictionary NewValues { get; set; } - [Column(TypeName = "json")] - public List AffectedColumns { get; set; } +namespace Marechai.Database.Models; - [Required] - public virtual ApplicationUser User { get; set; } - } +public class Audit : BaseModel +{ + public AuditType Type { get; set; } + [Required] + public string UserId { get; set; } + public string Table { get; set; } + [Column(TypeName = "json")] + public Dictionary Keys { get; set; } + [Column(TypeName = "json")] + public Dictionary OldValues { get; set; } + [Column(TypeName = "json")] + public Dictionary NewValues { get; set; } + [Column(TypeName = "json")] + public List AffectedColumns { get; set; } + + [Required] + public virtual ApplicationUser User { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/BaseFile.cs b/Marechai.Database/Models/BaseFile.cs index 97dd7180..389f8598 100644 --- a/Marechai.Database/Models/BaseFile.cs +++ b/Marechai.Database/Models/BaseFile.cs @@ -28,28 +28,30 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Aaru.CommonTypes.Structs; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public abstract class BaseFile : BaseModel { - public abstract class BaseFile : BaseModel - { - [StringLength(8192), Required] - public string Path { get; set; } - [StringLength(255), Required] - public string Name { get; set; } - [Required, DefaultValue('/')] - public char PathSeparator { get; set; } - public bool IsDirectory { get; set; } - public DateTime? CreationDate { get; set; } - public DateTime? AccessDate { get; set; } - public DateTime? StatusChangeDate { get; set; } - public DateTime? BackupDate { get; set; } - public DateTime? LastWriteDate { get; set; } - public FileAttributes Attributes { get; set; } - public ushort? PosixMode { get; set; } - public uint? DeviceNumber { get; set; } - public ulong? GroupId { get; set; } - public ulong? UserId { get; set; } - public ulong? Inode { get; set; } - public ulong? Links { get; set; } - } + [StringLength(8192)] + [Required] + public string Path { get; set; } + [StringLength(255)] + [Required] + public string Name { get; set; } + [Required] + [DefaultValue('/')] + public char PathSeparator { get; set; } + public bool IsDirectory { get; set; } + public DateTime? CreationDate { get; set; } + public DateTime? AccessDate { get; set; } + public DateTime? StatusChangeDate { get; set; } + public DateTime? BackupDate { get; set; } + public DateTime? LastWriteDate { get; set; } + public FileAttributes Attributes { get; set; } + public ushort? PosixMode { get; set; } + public uint? DeviceNumber { get; set; } + public ulong? GroupId { get; set; } + public ulong? UserId { get; set; } + public ulong? Inode { get; set; } + public ulong? Links { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/BaseModel.cs b/Marechai.Database/Models/BaseModel.cs index 22adebbd..fb620cfe 100644 --- a/Marechai.Database/Models/BaseModel.cs +++ b/Marechai.Database/Models/BaseModel.cs @@ -26,15 +26,14 @@ using System; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public abstract class BaseModel - { - public TKey Id { get; set; } +namespace Marechai.Database.Models; - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public DateTime CreatedOn { get; set; } - [DatabaseGenerated(DatabaseGeneratedOption.Computed)] - public DateTime UpdatedOn { get; set; } - } +public abstract class BaseModel +{ + public TKey Id { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public DateTime CreatedOn { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Computed)] + public DateTime UpdatedOn { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/BasePhoto.cs b/Marechai.Database/Models/BasePhoto.cs index bf42c484..d207b665 100644 --- a/Marechai.Database/Models/BasePhoto.cs +++ b/Marechai.Database/Models/BasePhoto.cs @@ -27,76 +27,75 @@ using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public abstract class BasePhoto : BaseModel { - public abstract class BasePhoto : BaseModel - { - public double? Aperture { get; set; } - public string Author { get; set; } - [DisplayName("Camera manufacturer")] - public string CameraManufacturer { get; set; } - [DisplayName("Camera model")] - public string CameraModel { get; set; } - [DisplayName("Color space")] - public ColorSpace? ColorSpace { get; set; } - [DisplayName("User comments")] - public string Comments { get; set; } - public Contrast? Contrast { get; set; } - [DisplayName("Date and time of digitizing")] - public DateTime? CreationDate { get; set; } - [DisplayName("Digital zoom ratio")] - public double? DigitalZoomRatio { get; set; } - [DisplayName("Exif version")] - public string ExifVersion { get; set; } - [DisplayName("Exposure time")] - public double? ExposureTime { get; set; } - [DisplayName("Exposure mode")] - public ExposureMode? ExposureMethod { get; set; } - [DisplayName("Exposure Program")] - public ExposureProgram? ExposureProgram { get; set; } - public Flash? Flash { get; set; } - [DisplayName("F-number")] - public double? Focal { get; set; } - [DisplayName("Lens focal length")] - public double? FocalLength { get; set; } - [DisplayName("Focal length in 35 mm film")] - public double? FocalLengthEquivalent { get; set; } - [DisplayName("Horizontal resolution")] - public double? HorizontalResolution { get; set; } - [DisplayName("ISO speed rating")] - public ushort? IsoRating { get; set; } - [DisplayName("Lens used")] - public string Lens { get; set; } - [DisplayName("Light source")] - public LightSource? LightSource { get; set; } - [DisplayName("Metering mode")] - public MeteringMode? MeteringMode { get; set; } - [DisplayName("Resolution unit")] - public ResolutionUnit? ResolutionUnit { get; set; } - public Orientation? Orientation { get; set; } - public Saturation? Saturation { get; set; } - [DisplayName("Scene capture type")] - public SceneCaptureType? SceneCaptureType { get; set; } - [DisplayName("Sensing method")] - public SensingMethod? SensingMethod { get; set; } - public Sharpness? Sharpness { get; set; } - [DisplayName("Software used")] - public string SoftwareUsed { get; set; } - [DisplayName("Subject distance range")] - public SubjectDistanceRange? SubjectDistanceRange { get; set; } - [Timestamp] - public DateTime UploadDate { get; set; } - [DisplayName("Vertical resolution")] - public double? VerticalResolution { get; set; } - [DisplayName("White balance")] - public WhiteBalance? WhiteBalance { get; set; } - public string OriginalExtension { get; set; } + public double? Aperture { get; set; } + public string Author { get; set; } + [DisplayName("Camera manufacturer")] + public string CameraManufacturer { get; set; } + [DisplayName("Camera model")] + public string CameraModel { get; set; } + [DisplayName("Color space")] + public ColorSpace? ColorSpace { get; set; } + [DisplayName("User comments")] + public string Comments { get; set; } + public Contrast? Contrast { get; set; } + [DisplayName("Date and time of digitizing")] + public DateTime? CreationDate { get; set; } + [DisplayName("Digital zoom ratio")] + public double? DigitalZoomRatio { get; set; } + [DisplayName("Exif version")] + public string ExifVersion { get; set; } + [DisplayName("Exposure time")] + public double? ExposureTime { get; set; } + [DisplayName("Exposure mode")] + public ExposureMode? ExposureMethod { get; set; } + [DisplayName("Exposure Program")] + public ExposureProgram? ExposureProgram { get; set; } + public Flash? Flash { get; set; } + [DisplayName("F-number")] + public double? Focal { get; set; } + [DisplayName("Lens focal length")] + public double? FocalLength { get; set; } + [DisplayName("Focal length in 35 mm film")] + public double? FocalLengthEquivalent { get; set; } + [DisplayName("Horizontal resolution")] + public double? HorizontalResolution { get; set; } + [DisplayName("ISO speed rating")] + public ushort? IsoRating { get; set; } + [DisplayName("Lens used")] + public string Lens { get; set; } + [DisplayName("Light source")] + public LightSource? LightSource { get; set; } + [DisplayName("Metering mode")] + public MeteringMode? MeteringMode { get; set; } + [DisplayName("Resolution unit")] + public ResolutionUnit? ResolutionUnit { get; set; } + public Orientation? Orientation { get; set; } + public Saturation? Saturation { get; set; } + [DisplayName("Scene capture type")] + public SceneCaptureType? SceneCaptureType { get; set; } + [DisplayName("Sensing method")] + public SensingMethod? SensingMethod { get; set; } + public Sharpness? Sharpness { get; set; } + [DisplayName("Software used")] + public string SoftwareUsed { get; set; } + [DisplayName("Subject distance range")] + public SubjectDistanceRange? SubjectDistanceRange { get; set; } + [Timestamp] + public DateTime UploadDate { get; set; } + [DisplayName("Vertical resolution")] + public double? VerticalResolution { get; set; } + [DisplayName("White balance")] + public WhiteBalance? WhiteBalance { get; set; } + public string OriginalExtension { get; set; } - public virtual ApplicationUser User { get; set; } - [Required] - public virtual License License { get; set; } + public virtual ApplicationUser User { get; set; } + [Required] + public virtual License License { get; set; } - public int LicenseId { get; set; } - public string UserId { get; set; } - } + public int LicenseId { get; set; } + public string UserId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/BaseScan.cs b/Marechai.Database/Models/BaseScan.cs index c7d8627f..10e6db85 100644 --- a/Marechai.Database/Models/BaseScan.cs +++ b/Marechai.Database/Models/BaseScan.cs @@ -27,37 +27,36 @@ using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public abstract class BaseScan : BaseModel { - public abstract class BaseScan : BaseModel - { - public string Author { get; set; } - [DisplayName("Color space")] - public ColorSpace? ColorSpace { get; set; } - [DisplayName("User comments")] - public string Comments { get; set; } - [DisplayName("Date and time of digitizing")] - public DateTime? CreationDate { get; set; } - [DisplayName("Exif version")] - public string ExifVersion { get; set; } - [DisplayName("Horizontal resolution")] - public double? HorizontalResolution { get; set; } - [DisplayName("Resolution unit")] - public ResolutionUnit? ResolutionUnit { get; set; } - [DisplayName("Scanner manufacturer")] - public string ScannerManufacturer { get; set; } - [DisplayName("Scanner model")] - public string ScannerModel { get; set; } - [DisplayName("Software used")] - public string SoftwareUsed { get; set; } - [Timestamp] - public DateTime UploadDate { get; set; } - [DisplayName("Vertical resolution")] - public double? VerticalResolution { get; set; } - public string OriginalExtension { get; set; } + public string Author { get; set; } + [DisplayName("Color space")] + public ColorSpace? ColorSpace { get; set; } + [DisplayName("User comments")] + public string Comments { get; set; } + [DisplayName("Date and time of digitizing")] + public DateTime? CreationDate { get; set; } + [DisplayName("Exif version")] + public string ExifVersion { get; set; } + [DisplayName("Horizontal resolution")] + public double? HorizontalResolution { get; set; } + [DisplayName("Resolution unit")] + public ResolutionUnit? ResolutionUnit { get; set; } + [DisplayName("Scanner manufacturer")] + public string ScannerManufacturer { get; set; } + [DisplayName("Scanner model")] + public string ScannerModel { get; set; } + [DisplayName("Software used")] + public string SoftwareUsed { get; set; } + [Timestamp] + public DateTime UploadDate { get; set; } + [DisplayName("Vertical resolution")] + public double? VerticalResolution { get; set; } + public string OriginalExtension { get; set; } - public virtual ApplicationUser User { get; set; } + public virtual ApplicationUser User { get; set; } - public string UserId { get; set; } - } + public string UserId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Book.cs b/Marechai.Database/Models/Book.cs index ff961789..d8e46d6d 100644 --- a/Marechai.Database/Models/Book.cs +++ b/Marechai.Database/Models/Book.cs @@ -26,26 +26,25 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class Book : DocumentBase - { - [StringLength(13, MinimumLength = 10)] - public string Isbn { get; set; } - public short? Pages { get; set; } - public int? Edition { get; set; } - public long? PreviousId { get; set; } - public long? SourceId { get; set; } +namespace Marechai.Database.Models; - public virtual Book Previous { get; set; } - public virtual Book Source { get; set; } - public virtual Book Next { get; set; } - public virtual Iso31661Numeric Country { get; set; } - public virtual ICollection Derivates { get; set; } - public virtual ICollection Companies { get; set; } - public virtual ICollection People { get; set; } - public virtual ICollection Machines { get; set; } - public virtual ICollection MachineFamilies { get; set; } - public virtual ICollection Scans { get; set; } - } +public class Book : DocumentBase +{ + [StringLength(13, MinimumLength = 10)] + public string Isbn { get; set; } + public short? Pages { get; set; } + public int? Edition { get; set; } + public long? PreviousId { get; set; } + public long? SourceId { get; set; } + + public virtual Book Previous { get; set; } + public virtual Book Source { get; set; } + public virtual Book Next { get; set; } + public virtual Iso31661Numeric Country { get; set; } + public virtual ICollection Derivates { get; set; } + public virtual ICollection Companies { get; set; } + public virtual ICollection People { get; set; } + public virtual ICollection Machines { get; set; } + public virtual ICollection MachineFamilies { get; set; } + public virtual ICollection Scans { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/BookScan.cs b/Marechai.Database/Models/BookScan.cs index 5d98f8ab..bca09132 100644 --- a/Marechai.Database/Models/BookScan.cs +++ b/Marechai.Database/Models/BookScan.cs @@ -25,12 +25,11 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class BookScan : DocumentScanBase { - public class BookScan : DocumentScanBase - { - [Required] - public virtual Book Book { get; set; } - public long BookId { get; set; } - } + [Required] + public virtual Book Book { get; set; } + public long BookId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/BooksByMachine.cs b/Marechai.Database/Models/BooksByMachine.cs index 1c4de2c3..e0efaa63 100644 --- a/Marechai.Database/Models/BooksByMachine.cs +++ b/Marechai.Database/Models/BooksByMachine.cs @@ -23,14 +23,13 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models -{ - public class BooksByMachine : BaseModel - { - public long BookId { get; set; } - public int MachineId { get; set; } +namespace Marechai.Database.Models; - public virtual Book Book { get; set; } - public virtual Machine Machine { get; set; } - } +public class BooksByMachine : BaseModel +{ + public long BookId { get; set; } + public int MachineId { get; set; } + + public virtual Book Book { get; set; } + public virtual Machine Machine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/BooksByMachineFamily.cs b/Marechai.Database/Models/BooksByMachineFamily.cs index 919da3d3..69344306 100644 --- a/Marechai.Database/Models/BooksByMachineFamily.cs +++ b/Marechai.Database/Models/BooksByMachineFamily.cs @@ -23,14 +23,13 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models -{ - public class BooksByMachineFamily : BaseModel - { - public long BookId { get; set; } - public int MachineFamilyId { get; set; } +namespace Marechai.Database.Models; - public virtual Book Book { get; set; } - public virtual MachineFamily MachineFamily { get; set; } - } +public class BooksByMachineFamily : BaseModel +{ + public long BookId { get; set; } + public int MachineFamilyId { get; set; } + + public virtual Book Book { get; set; } + public virtual MachineFamily MachineFamily { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/BrowserTest.cs b/Marechai.Database/Models/BrowserTest.cs index 351c146b..8e5f6bb0 100644 --- a/Marechai.Database/Models/BrowserTest.cs +++ b/Marechai.Database/Models/BrowserTest.cs @@ -26,41 +26,54 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class BrowserTest : BaseModel { - public class BrowserTest : BaseModel - { - [DisplayName("User agent"), Required, StringLength(128)] - public string UserAgent { get; set; } - [Required, StringLength(64)] - public string Browser { get; set; } - [Required, StringLength(16)] - public string Version { get; set; } - [DisplayName("Operating system"), Required, StringLength(32)] - public string Os { get; set; } - [Required, StringLength(8)] - public string Platform { get; set; } - [DisplayName("GIF87"), DefaultValue(false)] - public bool Gif87 { get; set; } - [DisplayName("GIF89"), DefaultValue(false)] - public bool Gif89 { get; set; } - [DisplayName("JPEG"), DefaultValue(false)] - public bool Jpeg { get; set; } - [DisplayName("PNG"), DefaultValue(false)] - public bool Png { get; set; } - [DisplayName("Transparent PNG"), DefaultValue(false)] - public bool Pngt { get; set; } - [DisplayName("Animated GIF"), DefaultValue(false)] - public bool Agif { get; set; } - [DefaultValue(false)] - public bool Table { get; set; } - [DefaultValue(false)] - public bool Colors { get; set; } - [DisplayName("JavaScript"), DefaultValue(false)] - public bool Js { get; set; } - [DefaultValue(false)] - public bool Frames { get; set; } - [DefaultValue(false)] - public bool Flash { get; set; } - } + [DisplayName("User agent")] + [Required] + [StringLength(128)] + public string UserAgent { get; set; } + [Required] + [StringLength(64)] + public string Browser { get; set; } + [Required] + [StringLength(16)] + public string Version { get; set; } + [DisplayName("Operating system")] + [Required] + [StringLength(32)] + public string Os { get; set; } + [Required] + [StringLength(8)] + public string Platform { get; set; } + [DisplayName("GIF87")] + [DefaultValue(false)] + public bool Gif87 { get; set; } + [DisplayName("GIF89")] + [DefaultValue(false)] + public bool Gif89 { get; set; } + [DisplayName("JPEG")] + [DefaultValue(false)] + public bool Jpeg { get; set; } + [DisplayName("PNG")] + [DefaultValue(false)] + public bool Png { get; set; } + [DisplayName("Transparent PNG")] + [DefaultValue(false)] + public bool Pngt { get; set; } + [DisplayName("Animated GIF")] + [DefaultValue(false)] + public bool Agif { get; set; } + [DefaultValue(false)] + public bool Table { get; set; } + [DefaultValue(false)] + public bool Colors { get; set; } + [DisplayName("JavaScript")] + [DefaultValue(false)] + public bool Js { get; set; } + [DefaultValue(false)] + public bool Frames { get; set; } + [DefaultValue(false)] + public bool Flash { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CompaniesByBook.cs b/Marechai.Database/Models/CompaniesByBook.cs index 05aa8475..fa3c2f62 100644 --- a/Marechai.Database/Models/CompaniesByBook.cs +++ b/Marechai.Database/Models/CompaniesByBook.cs @@ -26,17 +26,17 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class CompaniesByBook : BaseModel - { - public int CompanyId { get; set; } - public long BookId { get; set; } - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } +namespace Marechai.Database.Models; - public virtual DocumentCompany Company { get; set; } - public virtual Book Book { get; set; } - public virtual DocumentRole Role { get; set; } - } +public class CompaniesByBook : BaseModel +{ + public int CompanyId { get; set; } + public long BookId { get; set; } + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } + + public virtual DocumentCompany Company { get; set; } + public virtual Book Book { get; set; } + public virtual DocumentRole Role { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CompaniesByDocument.cs b/Marechai.Database/Models/CompaniesByDocument.cs index 484c7297..06a2aa72 100644 --- a/Marechai.Database/Models/CompaniesByDocument.cs +++ b/Marechai.Database/Models/CompaniesByDocument.cs @@ -26,17 +26,17 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class CompaniesByDocument : BaseModel - { - public int CompanyId { get; set; } - public long DocumentId { get; set; } - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } +namespace Marechai.Database.Models; - public virtual DocumentCompany Company { get; set; } - public virtual Document Document { get; set; } - public virtual DocumentRole Role { get; set; } - } +public class CompaniesByDocument : BaseModel +{ + public int CompanyId { get; set; } + public long DocumentId { get; set; } + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } + + public virtual DocumentCompany Company { get; set; } + public virtual Document Document { get; set; } + public virtual DocumentRole Role { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CompaniesByMagazine.cs b/Marechai.Database/Models/CompaniesByMagazine.cs index 4948921e..4f807531 100644 --- a/Marechai.Database/Models/CompaniesByMagazine.cs +++ b/Marechai.Database/Models/CompaniesByMagazine.cs @@ -26,17 +26,17 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class CompaniesByMagazine : BaseModel - { - public int CompanyId { get; set; } - public long MagazineId { get; set; } - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } +namespace Marechai.Database.Models; - public virtual DocumentCompany Company { get; set; } - public virtual Magazine Magazine { get; set; } - public virtual DocumentRole Role { get; set; } - } +public class CompaniesByMagazine : BaseModel +{ + public int CompanyId { get; set; } + public long MagazineId { get; set; } + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } + + public virtual DocumentCompany Company { get; set; } + public virtual Magazine Magazine { get; set; } + public virtual DocumentRole Role { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CompaniesBySoftwareFamily.cs b/Marechai.Database/Models/CompaniesBySoftwareFamily.cs index 0618d53b..cfd68ab8 100644 --- a/Marechai.Database/Models/CompaniesBySoftwareFamily.cs +++ b/Marechai.Database/Models/CompaniesBySoftwareFamily.cs @@ -25,19 +25,18 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class CompaniesBySoftwareFamily : BaseModel - { - [Required] - public virtual DocumentRole Role { get; set; } - [Required] - public virtual Company Company { get; set; } - [Required] - public virtual SoftwareFamily SoftwareFamily { get; set; } +namespace Marechai.Database.Models; - public string RoleId { get; set; } - public int CompanyId { get; set; } - public ulong SoftwareFamilyId { get; set; } - } +public class CompaniesBySoftwareFamily : BaseModel +{ + [Required] + public virtual DocumentRole Role { get; set; } + [Required] + public virtual Company Company { get; set; } + [Required] + public virtual SoftwareFamily SoftwareFamily { get; set; } + + public string RoleId { get; set; } + public int CompanyId { get; set; } + public ulong SoftwareFamilyId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CompaniesBySoftwareVariant.cs b/Marechai.Database/Models/CompaniesBySoftwareVariant.cs index d5657191..39767476 100644 --- a/Marechai.Database/Models/CompaniesBySoftwareVariant.cs +++ b/Marechai.Database/Models/CompaniesBySoftwareVariant.cs @@ -25,19 +25,18 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class CompaniesBySoftwareVariant : BaseModel - { - [Required] - public virtual Company Company { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - [Required] - public virtual DocumentRole Role { get; set; } +namespace Marechai.Database.Models; - public string RoleId { get; set; } - public int CompanyId { get; set; } - public ulong SoftwareVariantId { get; set; } - } +public class CompaniesBySoftwareVariant : BaseModel +{ + [Required] + public virtual Company Company { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } + [Required] + public virtual DocumentRole Role { get; set; } + + public string RoleId { get; set; } + public int CompanyId { get; set; } + public ulong SoftwareVariantId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CompaniesBySoftwareVersion.cs b/Marechai.Database/Models/CompaniesBySoftwareVersion.cs index cc5ae2c6..ebc6dfc5 100644 --- a/Marechai.Database/Models/CompaniesBySoftwareVersion.cs +++ b/Marechai.Database/Models/CompaniesBySoftwareVersion.cs @@ -25,19 +25,18 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class CompaniesBySoftwareVersion : BaseModel - { - [Required] - public virtual Company Company { get; set; } - [Required] - public virtual SoftwareVersion SoftwareVersion { get; set; } - [Required] - public virtual DocumentRole Role { get; set; } +namespace Marechai.Database.Models; - public string RoleId { get; set; } - public int CompanyId { get; set; } - public ulong SoftwareVersionId { get; set; } - } +public class CompaniesBySoftwareVersion : BaseModel +{ + [Required] + public virtual Company Company { get; set; } + [Required] + public virtual SoftwareVersion SoftwareVersion { get; set; } + [Required] + public virtual DocumentRole Role { get; set; } + + public string RoleId { get; set; } + public int CompanyId { get; set; } + public ulong SoftwareVersionId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Company.cs b/Marechai.Database/Models/Company.cs index ef9779a2..8b7246d1 100644 --- a/Marechai.Database/Models/Company.cs +++ b/Marechai.Database/Models/Company.cs @@ -29,72 +29,75 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class Company : BaseModel { - public class Company : BaseModel + public Company() { - public Company() - { - Logos = new HashSet(); - Gpus = new HashSet(); - InverseSoldToNavigation = new HashSet(); - MachineFamilies = new HashSet(); - Machines = new HashSet(); - Processors = new HashSet(); - SoundSynths = new HashSet(); - } - - [Required] - public string Name { get; set; } - [DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true), DataType(DataType.Date)] - public DateTime? Founded { get; set; } - [Url, StringLength(255)] - public string Website { get; set; } - [StringLength(45)] - public string Twitter { get; set; } - [StringLength(45)] - public string Facebook { get; set; } - [DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)] - public DateTime? Sold { get; set; } - public int? SoldToId { get; set; } - [StringLength(80)] - public string Address { get; set; } - [StringLength(80)] - public string City { get; set; } - [StringLength(80)] - public string Province { get; set; } - [StringLength(25), DisplayName("Postal code")] - public string PostalCode { get; set; } - public short? CountryId { get; set; } - [Required] - public CompanyStatus Status { get; set; } - public int? DocumentCompanyId { get; set; } - [DefaultValue(false)] - public bool FoundedMonthIsUnknown { get; set; } - [DefaultValue(false)] - public bool FoundedDayIsUnknown { get; set; } - [DefaultValue(false)] - public bool SoldMonthIsUnknown { get; set; } - [DefaultValue(false)] - public bool SoldDayIsUnknown { get; set; } - public string LegalName { get; set; } - - public virtual Iso31661Numeric Country { get; set; } - [DisplayName("Sold to")] - public virtual Company SoldTo { get; set; } - public virtual ICollection Descriptions { get; set; } - public virtual ICollection Logos { get; set; } - public virtual ICollection Gpus { get; set; } - public virtual ICollection InverseSoldToNavigation { get; set; } - public virtual ICollection MachineFamilies { get; set; } - public virtual ICollection Machines { get; set; } - public virtual ICollection Processors { get; set; } - public virtual ICollection SoundSynths { get; set; } - public virtual ICollection People { get; set; } - public virtual CompanyLogo LastLogo => Logos?.OrderByDescending(l => l.Year).FirstOrDefault(); - public virtual DocumentCompany DocumentCompany { get; set; } - public virtual ICollection SoftwareFamilies { get; set; } - public virtual ICollection SoftwareVersions { get; set; } - public virtual ICollection SoftwareVariants { get; set; } + Logos = new HashSet(); + Gpus = new HashSet(); + InverseSoldToNavigation = new HashSet(); + MachineFamilies = new HashSet(); + Machines = new HashSet(); + Processors = new HashSet(); + SoundSynths = new HashSet(); } + + [Required] + public string Name { get; set; } + [DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)] + [DataType(DataType.Date)] + public DateTime? Founded { get; set; } + [Url] + [StringLength(255)] + public string Website { get; set; } + [StringLength(45)] + public string Twitter { get; set; } + [StringLength(45)] + public string Facebook { get; set; } + [DisplayFormat(DataFormatString = "{0:d}")] + [DataType(DataType.Date)] + public DateTime? Sold { get; set; } + public int? SoldToId { get; set; } + [StringLength(80)] + public string Address { get; set; } + [StringLength(80)] + public string City { get; set; } + [StringLength(80)] + public string Province { get; set; } + [StringLength(25)] + [DisplayName("Postal code")] + public string PostalCode { get; set; } + public short? CountryId { get; set; } + [Required] + public CompanyStatus Status { get; set; } + public int? DocumentCompanyId { get; set; } + [DefaultValue(false)] + public bool FoundedMonthIsUnknown { get; set; } + [DefaultValue(false)] + public bool FoundedDayIsUnknown { get; set; } + [DefaultValue(false)] + public bool SoldMonthIsUnknown { get; set; } + [DefaultValue(false)] + public bool SoldDayIsUnknown { get; set; } + public string LegalName { get; set; } + + public virtual Iso31661Numeric Country { get; set; } + [DisplayName("Sold to")] + public virtual Company SoldTo { get; set; } + public virtual ICollection Descriptions { get; set; } + public virtual ICollection Logos { get; set; } + public virtual ICollection Gpus { get; set; } + public virtual ICollection InverseSoldToNavigation { get; set; } + public virtual ICollection MachineFamilies { get; set; } + public virtual ICollection Machines { get; set; } + public virtual ICollection Processors { get; set; } + public virtual ICollection SoundSynths { get; set; } + public virtual ICollection People { get; set; } + public virtual CompanyLogo LastLogo => Logos?.OrderByDescending(l => l.Year).FirstOrDefault(); + public virtual DocumentCompany DocumentCompany { get; set; } + public virtual ICollection SoftwareFamilies { get; set; } + public virtual ICollection SoftwareVersions { get; set; } + public virtual ICollection SoftwareVariants { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CompanyDescription.cs b/Marechai.Database/Models/CompanyDescription.cs index 97e20cf4..9ce6260a 100644 --- a/Marechai.Database/Models/CompanyDescription.cs +++ b/Marechai.Database/Models/CompanyDescription.cs @@ -26,16 +26,17 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class CompanyDescription : BaseModel - { - public int CompanyId { get; set; } - [MaxLength(262144, ErrorMessage = "Description is too long"), Required] - public string Text { get; set; } - [MaxLength(262144, ErrorMessage = "Description is too long"), DisplayName("HTML")] - public string Html { get; set; } +namespace Marechai.Database.Models; - public virtual Company Company { get; set; } - } +public class CompanyDescription : BaseModel +{ + public int CompanyId { get; set; } + [MaxLength(262144, ErrorMessage = "Description is too long")] + [Required] + public string Text { get; set; } + [MaxLength(262144, ErrorMessage = "Description is too long")] + [DisplayName("HTML")] + public string Html { get; set; } + + public virtual Company Company { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CompanyLogo.cs b/Marechai.Database/Models/CompanyLogo.cs index 3db8656a..156ef672 100644 --- a/Marechai.Database/Models/CompanyLogo.cs +++ b/Marechai.Database/Models/CompanyLogo.cs @@ -26,15 +26,14 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class CompanyLogo : BaseModel - { - public int CompanyId { get; set; } - [Range(1000, 3000)] - public int? Year { get; set; } - public Guid Guid { get; set; } +namespace Marechai.Database.Models; - public virtual Company Company { get; set; } - } +public class CompanyLogo : BaseModel +{ + public int CompanyId { get; set; } + [Range(1000, 3000)] + public int? Year { get; set; } + public Guid Guid { get; set; } + + public virtual Company Company { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CurrencyInflation.cs b/Marechai.Database/Models/CurrencyInflation.cs index 035687b6..c60bfe35 100644 --- a/Marechai.Database/Models/CurrencyInflation.cs +++ b/Marechai.Database/Models/CurrencyInflation.cs @@ -25,14 +25,13 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class CurrencyInflation : BaseModel { - public class CurrencyInflation : BaseModel - { - [Required] - public virtual Iso4217 Currency { get; set; } - public uint Year { get; set; } - public float Inflation { get; set; } - public string CurrencyCode { get; set; } - } + [Required] + public virtual Iso4217 Currency { get; set; } + public uint Year { get; set; } + public float Inflation { get; set; } + public string CurrencyCode { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/CurrencyPegging.cs b/Marechai.Database/Models/CurrencyPegging.cs index 2f26ebe6..bbfc92d4 100644 --- a/Marechai.Database/Models/CurrencyPegging.cs +++ b/Marechai.Database/Models/CurrencyPegging.cs @@ -26,21 +26,20 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class CurrencyPegging : BaseModel - { - [Required] - public virtual Iso4217 Source { get; set; } - [Required] - public virtual Iso4217 Destination { get; set; } - public float Ratio { get; set; } - [DataType(DataType.Date)] - public DateTime Start { get; set; } - [DataType(DataType.Date)] - public DateTime? End { get; set; } +namespace Marechai.Database.Models; - public string SourceCode { get; set; } - public string DestinationCode { get; set; } - } +public class CurrencyPegging : BaseModel +{ + [Required] + public virtual Iso4217 Source { get; set; } + [Required] + public virtual Iso4217 Destination { get; set; } + public float Ratio { get; set; } + [DataType(DataType.Date)] + public DateTime Start { get; set; } + [DataType(DataType.Date)] + public DateTime? End { get; set; } + + public string SourceCode { get; set; } + public string DestinationCode { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Document.cs b/Marechai.Database/Models/Document.cs index e2c218be..a0ca98f6 100644 --- a/Marechai.Database/Models/Document.cs +++ b/Marechai.Database/Models/Document.cs @@ -25,16 +25,15 @@ using System.Collections.Generic; -namespace Marechai.Database.Models -{ - public class Document : DocumentBase - { - public virtual Iso31661Numeric Country { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection People { get; set; } - public virtual ICollection Companies { get; set; } - public virtual ICollection Machines { get; set; } - public virtual ICollection MachineFamilies { get; set; } - public virtual ICollection Scans { get; set; } - } +public class Document : DocumentBase +{ + public virtual Iso31661Numeric Country { get; set; } + + public virtual ICollection People { get; set; } + public virtual ICollection Companies { get; set; } + public virtual ICollection Machines { get; set; } + public virtual ICollection MachineFamilies { get; set; } + public virtual ICollection Scans { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DocumentBase.cs b/Marechai.Database/Models/DocumentBase.cs index 9fe983d6..1bc3dd27 100644 --- a/Marechai.Database/Models/DocumentBase.cs +++ b/Marechai.Database/Models/DocumentBase.cs @@ -26,17 +26,17 @@ using System; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public abstract class DocumentBase : BaseModel { - public abstract class DocumentBase : BaseModel - { - [Required] - public string Title { get; set; } - public string NativeTitle { get; set; } - [DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)] - public DateTime? Published { get; set; } - public short? CountryId { get; set; } - [MaxLength(262144, ErrorMessage = "Synopsis is too long")] - public string Synopsis { get; set; } - } + [Required] + public string Title { get; set; } + public string NativeTitle { get; set; } + [DisplayFormat(DataFormatString = "{0:d}")] + [DataType(DataType.Date)] + public DateTime? Published { get; set; } + public short? CountryId { get; set; } + [MaxLength(262144, ErrorMessage = "Synopsis is too long")] + public string Synopsis { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DocumentCompany.cs b/Marechai.Database/Models/DocumentCompany.cs index 03008036..b6d9d9bf 100644 --- a/Marechai.Database/Models/DocumentCompany.cs +++ b/Marechai.Database/Models/DocumentCompany.cs @@ -27,18 +27,17 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class DocumentCompany : BaseModel - { - [Required] - public string Name { get; set; } - public int? CompanyId { get; set; } +namespace Marechai.Database.Models; - [DisplayName("Linked company")] - public virtual Company Company { get; set; } - public virtual ICollection Documents { get; set; } - public virtual ICollection Books { get; set; } - public virtual ICollection Magazines { get; set; } - } +public class DocumentCompany : BaseModel +{ + [Required] + public string Name { get; set; } + public int? CompanyId { get; set; } + + [DisplayName("Linked company")] + public virtual Company Company { get; set; } + public virtual ICollection Documents { get; set; } + public virtual ICollection Books { get; set; } + public virtual ICollection Magazines { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DocumentPerson.cs b/Marechai.Database/Models/DocumentPerson.cs index 3cc8621e..82b0bce1 100644 --- a/Marechai.Database/Models/DocumentPerson.cs +++ b/Marechai.Database/Models/DocumentPerson.cs @@ -28,26 +28,26 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class DocumentPerson : BaseModel { - public class DocumentPerson : BaseModel - { - [Required] - public string Name { get; set; } - [Required] - public string Surname { get; set; } - public int? PersonId { get; set; } - public string Alias { get; set; } - [DisplayName("Name to be displayed")] - public string DisplayName { get; set; } + [Required] + public string Name { get; set; } + [Required] + public string Surname { get; set; } + public int? PersonId { get; set; } + public string Alias { get; set; } + [DisplayName("Name to be displayed")] + public string DisplayName { get; set; } - [NotMapped, DisplayName("Name")] - public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}"; + [NotMapped] + [DisplayName("Name")] + public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}"; - [DisplayName("Linked person")] - public virtual Person Person { get; set; } - public virtual ICollection Documents { get; set; } - public virtual ICollection Books { get; set; } - public virtual ICollection Magazines { get; set; } - } + [DisplayName("Linked person")] + public virtual Person Person { get; set; } + public virtual ICollection Documents { get; set; } + public virtual ICollection Books { get; set; } + public virtual ICollection Magazines { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DocumentRole.cs b/Marechai.Database/Models/DocumentRole.cs index b1477f3b..89320ec4 100644 --- a/Marechai.Database/Models/DocumentRole.cs +++ b/Marechai.Database/Models/DocumentRole.cs @@ -27,14 +27,15 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class DocumentRole { - public class DocumentRole - { - [Column(TypeName = "char(3)"), Key, Required] - public string Id { get; set; } - public string Name { get; set; } - [DefaultValue(false)] - public bool Enabled { get; set; } - } + [Column(TypeName = "char(3)")] + [Key] + [Required] + public string Id { get; set; } + public string Name { get; set; } + [DefaultValue(false)] + public bool Enabled { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DocumentScan.cs b/Marechai.Database/Models/DocumentScan.cs index 4bc2a300..5f6671c3 100644 --- a/Marechai.Database/Models/DocumentScan.cs +++ b/Marechai.Database/Models/DocumentScan.cs @@ -25,12 +25,11 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class DocumentScan : DocumentScanBase { - public class DocumentScan : DocumentScanBase - { - [Required] - public virtual Document Document { get; set; } - public long DocumentId { get; set; } - } + [Required] + public virtual Document Document { get; set; } + public long DocumentId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DocumentScanBase.cs b/Marechai.Database/Models/DocumentScanBase.cs index 24543864..d9391b61 100644 --- a/Marechai.Database/Models/DocumentScanBase.cs +++ b/Marechai.Database/Models/DocumentScanBase.cs @@ -23,11 +23,10 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public abstract class DocumentScanBase : BaseScan { - public abstract class DocumentScanBase : BaseScan - { - public DocumentScanType Type { get; set; } - public uint? Page { get; set; } - } + public DocumentScanType Type { get; set; } + public uint? Page { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DocumentsByMachine.cs b/Marechai.Database/Models/DocumentsByMachine.cs index b89b90c0..cd4549e6 100644 --- a/Marechai.Database/Models/DocumentsByMachine.cs +++ b/Marechai.Database/Models/DocumentsByMachine.cs @@ -23,14 +23,13 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models -{ - public class DocumentsByMachine : BaseModel - { - public long DocumentId { get; set; } - public int MachineId { get; set; } +namespace Marechai.Database.Models; - public virtual Document Document { get; set; } - public virtual Machine Machine { get; set; } - } +public class DocumentsByMachine : BaseModel +{ + public long DocumentId { get; set; } + public int MachineId { get; set; } + + public virtual Document Document { get; set; } + public virtual Machine Machine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DocumentsByMachineFamily.cs b/Marechai.Database/Models/DocumentsByMachineFamily.cs index ae98c88d..a87d781f 100644 --- a/Marechai.Database/Models/DocumentsByMachineFamily.cs +++ b/Marechai.Database/Models/DocumentsByMachineFamily.cs @@ -23,14 +23,13 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models -{ - public class DocumentsByMachineFamily : BaseModel - { - public long DocumentId { get; set; } - public int MachineFamilyId { get; set; } +namespace Marechai.Database.Models; - public virtual Document Document { get; set; } - public virtual MachineFamily MachineFamily { get; set; } - } +public class DocumentsByMachineFamily : BaseModel +{ + public long DocumentId { get; set; } + public int MachineFamilyId { get; set; } + + public virtual Document Document { get; set; } + public virtual MachineFamily MachineFamily { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Dump.cs b/Marechai.Database/Models/Dump.cs index d1979340..cc9b3198 100644 --- a/Marechai.Database/Models/Dump.cs +++ b/Marechai.Database/Models/Dump.cs @@ -27,23 +27,22 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class Dump : BaseModel - { - [Required] - public string Dumper { get; set; } - public string UserId { get; set; } - public string DumpingGroup { get; set; } - public DateTime? DumpDate { get; set; } - [Required] - public virtual Media Media { get; set; } - [Required] - public virtual MediaDump MediaDump { get; set; } +namespace Marechai.Database.Models; - public virtual ApplicationUser User { get; set; } - public virtual ICollection DumpHardware { get; set; } - public ulong MediaId { get; set; } - public ulong MediaDumpId { get; set; } - } +public class Dump : BaseModel +{ + [Required] + public string Dumper { get; set; } + public string UserId { get; set; } + public string DumpingGroup { get; set; } + public DateTime? DumpDate { get; set; } + [Required] + public virtual Media Media { get; set; } + [Required] + public virtual MediaDump MediaDump { get; set; } + + public virtual ApplicationUser User { get; set; } + public virtual ICollection DumpHardware { get; set; } + public ulong MediaId { get; set; } + public ulong MediaDumpId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/DumpHardware.cs b/Marechai.Database/Models/DumpHardware.cs index d1f2b5b2..00fdf1a4 100644 --- a/Marechai.Database/Models/DumpHardware.cs +++ b/Marechai.Database/Models/DumpHardware.cs @@ -26,29 +26,31 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class DumpHardware : BaseModel { - public class DumpHardware : BaseModel - { - [StringLength(48)] - public string Manufacturer { get; set; } - [StringLength(48), Required] - public string Model { get; set; } - [StringLength(48)] - public string Revision { get; set; } - [StringLength(32)] - public string Firmware { get; set; } - [StringLength(64)] - public string Serial { get; set; } - [StringLength(64), Required] - public string SoftwareName { get; set; } - [StringLength(32)] - public string SoftwareVersion { get; set; } - [StringLength(64)] - public string SoftwareOperatingSystem { get; set; } - [Required, Column(TypeName = "json")] - public Extent[] Extents { get; set; } - [Required] - public virtual Dump Dump { get; set; } - } + [StringLength(48)] + public string Manufacturer { get; set; } + [StringLength(48)] + [Required] + public string Model { get; set; } + [StringLength(48)] + public string Revision { get; set; } + [StringLength(32)] + public string Firmware { get; set; } + [StringLength(64)] + public string Serial { get; set; } + [StringLength(64)] + [Required] + public string SoftwareName { get; set; } + [StringLength(32)] + public string SoftwareVersion { get; set; } + [StringLength(64)] + public string SoftwareOperatingSystem { get; set; } + [Required] + [Column(TypeName = "json")] + public Extent[] Extents { get; set; } + [Required] + public virtual Dump Dump { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Extent.cs b/Marechai.Database/Models/Extent.cs index 2cbefa0d..0431afd3 100644 --- a/Marechai.Database/Models/Extent.cs +++ b/Marechai.Database/Models/Extent.cs @@ -23,13 +23,12 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +// Not for table +public class Extent { - // Not for table - public class Extent - { - public long Start { get; set; } - public long End { get; set; } - public bool Error { get; set; } - } + public long Start { get; set; } + public long End { get; set; } + public bool Error { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/File.cs b/Marechai.Database/Models/File.cs index b8a4b450..7dca461e 100644 --- a/Marechai.Database/Models/File.cs +++ b/Marechai.Database/Models/File.cs @@ -27,29 +27,28 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class DbFile : BaseModel { - public class DbFile : BaseModel - { - [Required] - public ulong Size { get; set; } - [Column(TypeName = "binary(16)")] - public string Md5 { get; set; } - [Column(TypeName = "binary(20)")] - public string Sha1 { get; set; } - [Column(TypeName = "binary(32)")] - public string Sha256 { get; set; } - [Column(TypeName = "binary(64)")] - public string Sha3 { get; set; } - public string Spamsum { get; set; } - public string Mime { get; set; } - public string Magic { get; set; } - public string AccoustId { get; set; } - [DefaultValue(false)] - public bool Infected { get; set; } - public string Malware { get; set; } - [DefaultValue(false)] - public bool Hack { get; set; } - public string HackGroup { get; set; } - } + [Required] + public ulong Size { get; set; } + [Column(TypeName = "binary(16)")] + public string Md5 { get; set; } + [Column(TypeName = "binary(20)")] + public string Sha1 { get; set; } + [Column(TypeName = "binary(32)")] + public string Sha256 { get; set; } + [Column(TypeName = "binary(64)")] + public string Sha3 { get; set; } + public string Spamsum { get; set; } + public string Mime { get; set; } + public string Magic { get; set; } + public string AccoustId { get; set; } + [DefaultValue(false)] + public bool Infected { get; set; } + public string Malware { get; set; } + [DefaultValue(false)] + public bool Hack { get; set; } + public string HackGroup { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/FileDataStream.cs b/Marechai.Database/Models/FileDataStream.cs index a9853cc3..bdff0924 100644 --- a/Marechai.Database/Models/FileDataStream.cs +++ b/Marechai.Database/Models/FileDataStream.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class FileDataStream : BaseModel - { - [StringLength(255)] - public string Name { get; set; } - public ulong Size { get; set; } - [Required] - public virtual DbFile File { get; set; } +namespace Marechai.Database.Models; - public ulong FileId { get; set; } - } +public class FileDataStream : BaseModel +{ + [StringLength(255)] + public string Name { get; set; } + public ulong Size { get; set; } + [Required] + public virtual DbFile File { get; set; } + + public ulong FileId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/FileDataStreamsByMediaFile.cs b/Marechai.Database/Models/FileDataStreamsByMediaFile.cs index 1db4a338..82a45e74 100644 --- a/Marechai.Database/Models/FileDataStreamsByMediaFile.cs +++ b/Marechai.Database/Models/FileDataStreamsByMediaFile.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class FileDataStreamsByMediaFile : BaseModel - { - [Required] - public virtual FileDataStream FileDataStream { get; set; } - [Required] - public virtual MediaFile MediaFile { get; set; } +namespace Marechai.Database.Models; - public ulong FileDataStreamId { get; set; } - public ulong MediaFileId { get; set; } - } +public class FileDataStreamsByMediaFile : BaseModel +{ + [Required] + public virtual FileDataStream FileDataStream { get; set; } + [Required] + public virtual MediaFile MediaFile { get; set; } + + public ulong FileDataStreamId { get; set; } + public ulong MediaFileId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/FileDataStreamsByStandaloneFile.cs b/Marechai.Database/Models/FileDataStreamsByStandaloneFile.cs index 4aaffb4f..6e24fccd 100644 --- a/Marechai.Database/Models/FileDataStreamsByStandaloneFile.cs +++ b/Marechai.Database/Models/FileDataStreamsByStandaloneFile.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class FileDataStreamsByStandaloneFile : BaseModel - { - [Required] - public virtual FileDataStream FileDataStream { get; set; } - [Required] - public virtual StandaloneFile StandaloneFile { get; set; } +namespace Marechai.Database.Models; - public ulong FileDataStreamId { get; set; } - public ulong StandaloneFileId { get; set; } - } +public class FileDataStreamsByStandaloneFile : BaseModel +{ + [Required] + public virtual FileDataStream FileDataStream { get; set; } + [Required] + public virtual StandaloneFile StandaloneFile { get; set; } + + public ulong FileDataStreamId { get; set; } + public ulong StandaloneFileId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/FilesByFilesystem.cs b/Marechai.Database/Models/FilesByFilesystem.cs index d6bb3c69..34481611 100644 --- a/Marechai.Database/Models/FilesByFilesystem.cs +++ b/Marechai.Database/Models/FilesByFilesystem.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class FilesByFilesystem : BaseModel - { - [Required] - public virtual Filesystem Filesystem { get; set; } - [Required] - public virtual MediaFile File { get; set; } +namespace Marechai.Database.Models; - public ulong FilesystemId { get; set; } - public ulong FileId { get; set; } - } +public class FilesByFilesystem : BaseModel +{ + [Required] + public virtual Filesystem Filesystem { get; set; } + [Required] + public virtual MediaFile File { get; set; } + + public ulong FilesystemId { get; set; } + public ulong FileId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Filesystem.cs b/Marechai.Database/Models/Filesystem.cs index 92bc45cc..7645af2a 100644 --- a/Marechai.Database/Models/Filesystem.cs +++ b/Marechai.Database/Models/Filesystem.cs @@ -27,32 +27,31 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class Filesystem : BaseModel - { - [Required] - public string Type { get; set; } - public DateTime? CreationDate { get; set; } - public DateTime? ModificationDate { get; set; } - public DateTime? BackupDate { get; set; } - public int ClusterSize { get; set; } - public ulong Clusters { get; set; } - public ulong? FilesCount { get; set; } - public bool Bootable { get; set; } - public string Serial { get; set; } - public string Label { get; set; } - public ulong? FreeClusters { get; set; } - public DateTime? ExpirationDate { get; set; } - public DateTime? EffectiveDate { get; set; } - public string SystemIdentifier { get; set; } - public string VolumeSetIdentifier { get; set; } - public string PublisherIdentifier { get; set; } - public string DataPreparerIdentifier { get; set; } - public string ApplicationIdentifier { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection Partitions { get; set; } - public virtual ICollection MediaDumpFileImages { get; set; } - public virtual ICollection Files { get; set; } - } +public class Filesystem : BaseModel +{ + [Required] + public string Type { get; set; } + public DateTime? CreationDate { get; set; } + public DateTime? ModificationDate { get; set; } + public DateTime? BackupDate { get; set; } + public int ClusterSize { get; set; } + public ulong Clusters { get; set; } + public ulong? FilesCount { get; set; } + public bool Bootable { get; set; } + public string Serial { get; set; } + public string Label { get; set; } + public ulong? FreeClusters { get; set; } + public DateTime? ExpirationDate { get; set; } + public DateTime? EffectiveDate { get; set; } + public string SystemIdentifier { get; set; } + public string VolumeSetIdentifier { get; set; } + public string PublisherIdentifier { get; set; } + public string DataPreparerIdentifier { get; set; } + public string ApplicationIdentifier { get; set; } + + public virtual ICollection Partitions { get; set; } + public virtual ICollection MediaDumpFileImages { get; set; } + public virtual ICollection Files { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/FilesystemsByLogicalPartition.cs b/Marechai.Database/Models/FilesystemsByLogicalPartition.cs index 2d4cb732..a29a2e03 100644 --- a/Marechai.Database/Models/FilesystemsByLogicalPartition.cs +++ b/Marechai.Database/Models/FilesystemsByLogicalPartition.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class FilesystemsByLogicalPartition : BaseModel { - public class FilesystemsByLogicalPartition : BaseModel - { - [Required] - public virtual Filesystem Filesystem { get; set; } - [Required] - public virtual LogicalPartition Partition { get; set; } - } + [Required] + public virtual Filesystem Filesystem { get; set; } + [Required] + public virtual LogicalPartition Partition { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/FilesystemsByMediaDumpFile.cs b/Marechai.Database/Models/FilesystemsByMediaDumpFile.cs index f04cde36..b8b601de 100644 --- a/Marechai.Database/Models/FilesystemsByMediaDumpFile.cs +++ b/Marechai.Database/Models/FilesystemsByMediaDumpFile.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class FilesystemsByMediaDumpFile : BaseModel { - public class FilesystemsByMediaDumpFile : BaseModel - { - [Required] - public virtual Filesystem Filesystem { get; set; } - [Required] - public virtual MediaDumpFileImage MediaDumpFileImage { get; set; } - } + [Required] + public virtual Filesystem Filesystem { get; set; } + [Required] + public virtual MediaDumpFileImage MediaDumpFileImage { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Forbidden.cs b/Marechai.Database/Models/Forbidden.cs index 0fcb5ed1..4d41a5c0 100644 --- a/Marechai.Database/Models/Forbidden.cs +++ b/Marechai.Database/Models/Forbidden.cs @@ -23,13 +23,12 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class Forbidden : BaseModel { - public class Forbidden : BaseModel - { - public string Browser { get; set; } - public string Date { get; set; } - public string Ip { get; set; } - public string Referer { get; set; } - } + public string Browser { get; set; } + public string Date { get; set; } + public string Ip { get; set; } + public string Referer { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Gpu.cs b/Marechai.Database/Models/Gpu.cs index a19a9efe..6cd769d7 100644 --- a/Marechai.Database/Models/Gpu.cs +++ b/Marechai.Database/Models/Gpu.cs @@ -28,37 +28,39 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class Gpu : BaseModel { - public class Gpu : BaseModel + public Gpu() { - public Gpu() - { - GpusByMachine = new HashSet(); - ResolutionsByGpu = new HashSet(); - } - - [Required, StringLength(128)] - public string Name { get; set; } - public int? CompanyId { get; set; } - [DisplayName("Model code"), StringLength(45)] - public string ModelCode { get; set; } - [DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)] - public DateTime? Introduced { get; set; } - [StringLength(45)] - public string Package { get; set; } - [StringLength(45)] - public string Process { get; set; } - [DisplayName("Process (nm)")] - public float? ProcessNm { get; set; } - [DisplayName("Die size (mm²)")] - public float? DieSize { get; set; } - [Range(1, long.MaxValue)] - public long? Transistors { get; set; } - - public virtual Company Company { get; set; } - public virtual ICollection GpusByMachine { get; set; } - public virtual ICollection ResolutionsByGpu { get; set; } - public virtual ICollection Software { get; set; } + GpusByMachine = new HashSet(); + ResolutionsByGpu = new HashSet(); } + + [Required] + [StringLength(128)] + public string Name { get; set; } + public int? CompanyId { get; set; } + [DisplayName("Model code")] + [StringLength(45)] + public string ModelCode { get; set; } + [DisplayFormat(DataFormatString = "{0:d}")] + [DataType(DataType.Date)] + public DateTime? Introduced { get; set; } + [StringLength(45)] + public string Package { get; set; } + [StringLength(45)] + public string Process { get; set; } + [DisplayName("Process (nm)")] + public float? ProcessNm { get; set; } + [DisplayName("Die size (mm²)")] + public float? DieSize { get; set; } + [Range(1, long.MaxValue)] + public long? Transistors { get; set; } + + public virtual Company Company { get; set; } + public virtual ICollection GpusByMachine { get; set; } + public virtual ICollection ResolutionsByGpu { get; set; } + public virtual ICollection Software { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/GpusByMachine.cs b/Marechai.Database/Models/GpusByMachine.cs index db4b1d25..1a360de6 100644 --- a/Marechai.Database/Models/GpusByMachine.cs +++ b/Marechai.Database/Models/GpusByMachine.cs @@ -25,15 +25,14 @@ using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class GpusByMachine : BaseModel - { - public int GpuId { get; set; } - public int MachineId { get; set; } +namespace Marechai.Database.Models; - [DisplayName("GPU")] - public virtual Gpu Gpu { get; set; } - public virtual Machine Machine { get; set; } - } +public class GpusByMachine : BaseModel +{ + public int GpuId { get; set; } + public int MachineId { get; set; } + + [DisplayName("GPU")] + public virtual Gpu Gpu { get; set; } + public virtual Machine Machine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/GpusByOwnedMachine.cs b/Marechai.Database/Models/GpusByOwnedMachine.cs index d824c097..e27516c3 100644 --- a/Marechai.Database/Models/GpusByOwnedMachine.cs +++ b/Marechai.Database/Models/GpusByOwnedMachine.cs @@ -25,15 +25,14 @@ using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class GpusByOwnedMachine : BaseModel - { - public int GpuId { get; set; } - public long OwnedMachineId { get; set; } +namespace Marechai.Database.Models; - [DisplayName("GPU")] - public virtual Gpu Gpu { get; set; } - public virtual OwnedMachine OwnedMachine { get; set; } - } +public class GpusByOwnedMachine : BaseModel +{ + public int GpuId { get; set; } + public long OwnedMachineId { get; set; } + + [DisplayName("GPU")] + public virtual Gpu Gpu { get; set; } + public virtual OwnedMachine OwnedMachine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/GpusBySoftwareVariant.cs b/Marechai.Database/Models/GpusBySoftwareVariant.cs index 46966fad..6ab3d8d8 100644 --- a/Marechai.Database/Models/GpusBySoftwareVariant.cs +++ b/Marechai.Database/Models/GpusBySoftwareVariant.cs @@ -25,15 +25,14 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class GpusBySoftwareVariant : BaseModel { - public class GpusBySoftwareVariant : BaseModel - { - [Required] - public virtual Gpu Gpu { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - public bool? Minimum { get; set; } - public bool? Recommended { get; set; } - } + [Required] + public virtual Gpu Gpu { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } + public bool? Minimum { get; set; } + public bool? Recommended { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/InstructionSet.cs b/Marechai.Database/Models/InstructionSet.cs index 5864873b..58b60a36 100644 --- a/Marechai.Database/Models/InstructionSet.cs +++ b/Marechai.Database/Models/InstructionSet.cs @@ -27,16 +27,17 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Mvc; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class InstructionSet : BaseModel { - public class InstructionSet : BaseModel - { - public InstructionSet() => Processors = new HashSet(); + public InstructionSet() => Processors = new HashSet(); - [Required, StringLength(45), Remote("VerifyUnique", "InstructionSets", "Admin")] - public string Name { get; set; } + [Required] + [StringLength(45)] + [Remote("VerifyUnique", "InstructionSets", "Admin")] + public string Name { get; set; } - public virtual ICollection Processors { get; set; } - public virtual ICollection Software { get; set; } - } + public virtual ICollection Processors { get; set; } + public virtual ICollection Software { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/InstructionSetExtension.cs b/Marechai.Database/Models/InstructionSetExtension.cs index b8380cbc..1eb8eadb 100644 --- a/Marechai.Database/Models/InstructionSetExtension.cs +++ b/Marechai.Database/Models/InstructionSetExtension.cs @@ -28,20 +28,18 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Mvc; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class InstructionSetExtension : BaseModel { - public class InstructionSetExtension : BaseModel - { - public InstructionSetExtension() => - InstructionSetExtensionsByProcessor = new HashSet(); + public InstructionSetExtension() => + InstructionSetExtensionsByProcessor = new HashSet(); - [DisplayName("Name"), Required, StringLength(45), Remote("VerifyUnique", "InstructionSetExtensions", "Admin")] - public string Extension { get; set; } + [DisplayName("Name")] + [Required] + [StringLength(45)] + [Remote("VerifyUnique", "InstructionSetExtensions", "Admin")] + public string Extension { get; set; } - public virtual ICollection InstructionSetExtensionsByProcessor - { - get; - set; - } - } + public virtual ICollection InstructionSetExtensionsByProcessor { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/InstructionSetExtensionsByProcessor.cs b/Marechai.Database/Models/InstructionSetExtensionsByProcessor.cs index d2221c38..2cce9dee 100644 --- a/Marechai.Database/Models/InstructionSetExtensionsByProcessor.cs +++ b/Marechai.Database/Models/InstructionSetExtensionsByProcessor.cs @@ -25,16 +25,15 @@ using Microsoft.AspNetCore.Mvc; -namespace Marechai.Database.Models -{ - public class InstructionSetExtensionsByProcessor : BaseModel - { - [Remote("VerifyUnique", "InstructionSetExtensionsByProcessor", "Admin", AdditionalFields = nameof(ExtensionId))] - public int ProcessorId { get; set; } - [Remote("VerifyUnique", "InstructionSetExtensionsByProcessor", "Admin", AdditionalFields = nameof(ProcessorId))] - public int ExtensionId { get; set; } +namespace Marechai.Database.Models; - public virtual InstructionSetExtension Extension { get; set; } - public virtual Processor Processor { get; set; } - } +public class InstructionSetExtensionsByProcessor : BaseModel +{ + [Remote("VerifyUnique", "InstructionSetExtensionsByProcessor", "Admin", AdditionalFields = nameof(ExtensionId))] + public int ProcessorId { get; set; } + [Remote("VerifyUnique", "InstructionSetExtensionsByProcessor", "Admin", AdditionalFields = nameof(ProcessorId))] + public int ExtensionId { get; set; } + + public virtual InstructionSetExtension Extension { get; set; } + public virtual Processor Processor { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/InstructionSetsBySoftwareVariant.cs b/Marechai.Database/Models/InstructionSetsBySoftwareVariant.cs index 8690c04e..dccc0a47 100644 --- a/Marechai.Database/Models/InstructionSetsBySoftwareVariant.cs +++ b/Marechai.Database/Models/InstructionSetsBySoftwareVariant.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class InstructionSetsBySoftwareVariant : BaseModel { - public class InstructionSetsBySoftwareVariant : BaseModel - { - [Required] - public virtual InstructionSet InstructionSet { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - } + [Required] + public virtual InstructionSet InstructionSet { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Iso31661Numeric.cs b/Marechai.Database/Models/Iso31661Numeric.cs index 183b79d0..72689323 100644 --- a/Marechai.Database/Models/Iso31661Numeric.cs +++ b/Marechai.Database/Models/Iso31661Numeric.cs @@ -28,26 +28,26 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class Iso31661Numeric { - public class Iso31661Numeric - { - public Iso31661Numeric() => Companies = new HashSet(); + public Iso31661Numeric() => Companies = new HashSet(); - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public DateTime CreatedOn { get; set; } - [DatabaseGenerated(DatabaseGeneratedOption.Computed)] - public DateTime UpdatedOn { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public DateTime CreatedOn { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Computed)] + public DateTime UpdatedOn { get; set; } - [Required] - public short Id { get; set; } - [Required, StringLength(64)] - public string Name { get; set; } + [Required] + public short Id { get; set; } + [Required] + [StringLength(64)] + public string Name { get; set; } - public virtual ICollection Companies { get; set; } - public virtual ICollection People { get; set; } - public virtual ICollection Documents { get; set; } - public virtual ICollection Books { get; set; } - public virtual ICollection Magazines { get; set; } - } + public virtual ICollection Companies { get; set; } + public virtual ICollection People { get; set; } + public virtual ICollection Documents { get; set; } + public virtual ICollection Books { get; set; } + public virtual ICollection Magazines { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Iso4217.cs b/Marechai.Database/Models/Iso4217.cs index f4c5a0c5..31552c05 100644 --- a/Marechai.Database/Models/Iso4217.cs +++ b/Marechai.Database/Models/Iso4217.cs @@ -27,23 +27,26 @@ using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class Iso4217 - { - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public DateTime CreatedOn { get; set; } - [DatabaseGenerated(DatabaseGeneratedOption.Computed)] - public DateTime UpdatedOn { get; set; } +namespace Marechai.Database.Models; - [StringLength(3), Required, Key] - public string Code { get; set; } - [Column(TypeName = "smallint(3)"), Required] - public short Numeric { get; set; } - public byte? MinorUnits { get; set; } - [StringLength(150), Required] - public string Name { get; set; } - [DataType(DataType.Date)] - public DateTime? Withdrawn { get; set; } - } +public class Iso4217 +{ + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public DateTime CreatedOn { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Computed)] + public DateTime UpdatedOn { get; set; } + + [StringLength(3)] + [Required] + [Key] + public string Code { get; set; } + [Column(TypeName = "smallint(3)")] + [Required] + public short Numeric { get; set; } + public byte? MinorUnits { get; set; } + [StringLength(150)] + [Required] + public string Name { get; set; } + [DataType(DataType.Date)] + public DateTime? Withdrawn { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Iso639.cs b/Marechai.Database/Models/Iso639.cs index 528395f1..1e857806 100644 --- a/Marechai.Database/Models/Iso639.cs +++ b/Marechai.Database/Models/Iso639.cs @@ -28,33 +28,37 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +/// ISO-639 codes +public class Iso639 { - /// ISO-639 codes - public class Iso639 - { - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public DateTime CreatedOn { get; set; } - [DatabaseGenerated(DatabaseGeneratedOption.Computed)] - public DateTime UpdatedOn { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public DateTime CreatedOn { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Computed)] + public DateTime UpdatedOn { get; set; } - [Column(TypeName = "char(3)"), Key, Required] - public string Id { get; set; } - [Column(TypeName = "char(3)")] - public string Part2B { get; set; } - [Column(TypeName = "char(3)")] - public string Part2T { get; set; } - [Column(TypeName = "char(2)")] - public string Part1 { get; set; } - [Column(TypeName = "char(1)"), Required] - public string Scope { get; set; } - [Column(TypeName = "char(1)"), Required] - public string Type { get; set; } - [Column(TypeName = "varchar(150)"), Required] - public string ReferenceName { get; set; } - [Column(TypeName = "varchar(150)")] - public string Comment { get; set; } + [Column(TypeName = "char(3)")] + [Key] + [Required] + public string Id { get; set; } + [Column(TypeName = "char(3)")] + public string Part2B { get; set; } + [Column(TypeName = "char(3)")] + public string Part2T { get; set; } + [Column(TypeName = "char(2)")] + public string Part1 { get; set; } + [Column(TypeName = "char(1)")] + [Required] + public string Scope { get; set; } + [Column(TypeName = "char(1)")] + [Required] + public string Type { get; set; } + [Column(TypeName = "varchar(150)")] + [Required] + public string ReferenceName { get; set; } + [Column(TypeName = "varchar(150)")] + public string Comment { get; set; } - public virtual ICollection Software { get; set; } - } + public virtual ICollection Software { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/LanguagesBySoftwareVariant.cs b/Marechai.Database/Models/LanguagesBySoftwareVariant.cs index c1a5b981..051037b0 100644 --- a/Marechai.Database/Models/LanguagesBySoftwareVariant.cs +++ b/Marechai.Database/Models/LanguagesBySoftwareVariant.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class LanguagesBySoftwareVariant : BaseModel { - public class LanguagesBySoftwareVariant : BaseModel - { - [Required] - public virtual Iso639 Language { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - } + [Required] + public virtual Iso639 Language { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/License.cs b/Marechai.Database/Models/License.cs index 0b9ecd7a..ec2fd484 100644 --- a/Marechai.Database/Models/License.cs +++ b/Marechai.Database/Models/License.cs @@ -28,24 +28,31 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class License : BaseModel { - public class License : BaseModel - { - [Required] - public string Name { get; set; } - [DisplayName("SPDX identifier")] - public string SPDX { get; set; } - [DisplayName("FSF approved"), Required, DefaultValue(false)] - public bool FsfApproved { get; set; } - [DisplayName("OSI approved"), Required, DefaultValue(false)] - public bool OsiApproved { get; set; } - [DisplayName("License text link"), StringLength(512), Url] - public string Link { get; set; } - [DisplayName("License text"), Column(TypeName = "longtext"), StringLength(131072), - DataType(DataType.MultilineText)] - public string Text { get; set; } - public virtual ICollection Photos { get; set; } - public virtual ICollection OwnedMachinePhotos { get; set; } - } + [Required] + public string Name { get; set; } + [DisplayName("SPDX identifier")] + public string SPDX { get; set; } + [DisplayName("FSF approved")] + [Required] + [DefaultValue(false)] + public bool FsfApproved { get; set; } + [DisplayName("OSI approved")] + [Required] + [DefaultValue(false)] + public bool OsiApproved { get; set; } + [DisplayName("License text link")] + [StringLength(512)] + [Url] + public string Link { get; set; } + [DisplayName("License text")] + [Column(TypeName = "longtext")] + [StringLength(131072)] + [DataType(DataType.MultilineText)] + public string Text { get; set; } + public virtual ICollection Photos { get; set; } + public virtual ICollection OwnedMachinePhotos { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Log.cs b/Marechai.Database/Models/Log.cs index e0623d67..1c8b984e 100644 --- a/Marechai.Database/Models/Log.cs +++ b/Marechai.Database/Models/Log.cs @@ -23,13 +23,12 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class Log : BaseModel { - public class Log : BaseModel - { - public string Browser { get; set; } - public string Ip { get; set; } - public string Date { get; set; } - public string Referer { get; set; } - } + public string Browser { get; set; } + public string Ip { get; set; } + public string Date { get; set; } + public string Referer { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/LogicalPartition.cs b/Marechai.Database/Models/LogicalPartition.cs index 25eb8e7a..cac5c4f7 100644 --- a/Marechai.Database/Models/LogicalPartition.cs +++ b/Marechai.Database/Models/LogicalPartition.cs @@ -26,21 +26,20 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class LogicalPartition : BaseModel - { - public uint Sequence { get; set; } - public string Name { get; set; } - [Required] - public string Type { get; set; } - public ulong FirstSector { get; set; } - public ulong LastSector { get; set; } - public ulong Size { get; set; } - public string Description { get; set; } - public string Scheme { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection Filesystems { get; set; } - public virtual ICollection Media { get; set; } - } +public class LogicalPartition : BaseModel +{ + public uint Sequence { get; set; } + public string Name { get; set; } + [Required] + public string Type { get; set; } + public ulong FirstSector { get; set; } + public ulong LastSector { get; set; } + public ulong Size { get; set; } + public string Description { get; set; } + public string Scheme { get; set; } + + public virtual ICollection Filesystems { get; set; } + public virtual ICollection Media { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/LogicalPartitionsByMedia.cs b/Marechai.Database/Models/LogicalPartitionsByMedia.cs index 86d61818..010ba349 100644 --- a/Marechai.Database/Models/LogicalPartitionsByMedia.cs +++ b/Marechai.Database/Models/LogicalPartitionsByMedia.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class LogicalPartitionsByMedia : BaseModel { - public class LogicalPartitionsByMedia : BaseModel - { - [Required] - public virtual Media Media { get; set; } - [Required] - public virtual LogicalPartition Partition { get; set; } - } + [Required] + public virtual Media Media { get; set; } + [Required] + public virtual LogicalPartition Partition { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Machine.cs b/Marechai.Database/Models/Machine.cs index d697d3e3..b9515c3b 100644 --- a/Marechai.Database/Models/Machine.cs +++ b/Marechai.Database/Models/Machine.cs @@ -27,43 +27,44 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class Machine : BaseModel { - public class Machine : BaseModel + public Machine() { - public Machine() - { - Gpus = new HashSet(); - Memory = new HashSet(); - Processors = new HashSet(); - Sound = new HashSet(); - Storage = new HashSet(); - } - - [Required] - public int CompanyId { get; set; } - [Required, StringLength(255)] - public string Name { get; set; } - [Required] - public MachineType Type { get; set; } - [DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)] - public DateTime? Introduced { get; set; } - public int? FamilyId { get; set; } - [StringLength(50)] - public string Model { get; set; } - - public virtual Company Company { get; set; } - public virtual MachineFamily Family { get; set; } - public virtual ICollection Gpus { get; set; } - public virtual ICollection Memory { get; set; } - public virtual ICollection Processors { get; set; } - public virtual ICollection Sound { get; set; } - public virtual ICollection Storage { get; set; } - public virtual ICollection Photos { get; set; } - public virtual ICollection Screens { get; set; } - public virtual ICollection Documents { get; set; } - public virtual ICollection Books { get; set; } - public virtual ICollection Magazines { get; set; } - public virtual ICollection Software { get; set; } + Gpus = new HashSet(); + Memory = new HashSet(); + Processors = new HashSet(); + Sound = new HashSet(); + Storage = new HashSet(); } + + [Required] + public int CompanyId { get; set; } + [Required] + [StringLength(255)] + public string Name { get; set; } + [Required] + public MachineType Type { get; set; } + [DisplayFormat(DataFormatString = "{0:d}")] + [DataType(DataType.Date)] + public DateTime? Introduced { get; set; } + public int? FamilyId { get; set; } + [StringLength(50)] + public string Model { get; set; } + + public virtual Company Company { get; set; } + public virtual MachineFamily Family { get; set; } + public virtual ICollection Gpus { get; set; } + public virtual ICollection Memory { get; set; } + public virtual ICollection Processors { get; set; } + public virtual ICollection Sound { get; set; } + public virtual ICollection Storage { get; set; } + public virtual ICollection Photos { get; set; } + public virtual ICollection Screens { get; set; } + public virtual ICollection Documents { get; set; } + public virtual ICollection Books { get; set; } + public virtual ICollection Magazines { get; set; } + public virtual ICollection Software { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MachineFamiliesBySoftwareVariant.cs b/Marechai.Database/Models/MachineFamiliesBySoftwareVariant.cs index e6d69825..5b4b159f 100644 --- a/Marechai.Database/Models/MachineFamiliesBySoftwareVariant.cs +++ b/Marechai.Database/Models/MachineFamiliesBySoftwareVariant.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MachineFamiliesBySoftwareVariant : BaseModel { - public class MachineFamiliesBySoftwareVariant : BaseModel - { - [Required] - public virtual MachineFamily MachineFamily { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - } + [Required] + public virtual MachineFamily MachineFamily { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MachineFamily.cs b/Marechai.Database/Models/MachineFamily.cs index 7ef98785..ee1cc729 100644 --- a/Marechai.Database/Models/MachineFamily.cs +++ b/Marechai.Database/Models/MachineFamily.cs @@ -26,21 +26,21 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MachineFamily : BaseModel { - public class MachineFamily : BaseModel - { - public MachineFamily() => Machines = new HashSet(); + public MachineFamily() => Machines = new HashSet(); - public int CompanyId { get; set; } - [Required, StringLength(255)] - public string Name { get; set; } + public int CompanyId { get; set; } + [Required] + [StringLength(255)] + public string Name { get; set; } - public virtual Company Company { get; set; } - public virtual ICollection Machines { get; set; } - public virtual ICollection Documents { get; set; } - public virtual ICollection Books { get; set; } - public virtual ICollection Magazines { get; set; } - public virtual ICollection Software { get; set; } - } + public virtual Company Company { get; set; } + public virtual ICollection Machines { get; set; } + public virtual ICollection Documents { get; set; } + public virtual ICollection Books { get; set; } + public virtual ICollection Magazines { get; set; } + public virtual ICollection Software { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MachinePhoto.cs b/Marechai.Database/Models/MachinePhoto.cs index 1a787590..6fe03282 100644 --- a/Marechai.Database/Models/MachinePhoto.cs +++ b/Marechai.Database/Models/MachinePhoto.cs @@ -25,15 +25,14 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MachinePhoto : BasePhoto { - public class MachinePhoto : BasePhoto - { - [Url] - public string Source { get; set; } + [Url] + public string Source { get; set; } - public virtual Machine Machine { get; set; } + public virtual Machine Machine { get; set; } - public int MachineId { get; set; } - } + public int MachineId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MachinesBySoftwareVariant.cs b/Marechai.Database/Models/MachinesBySoftwareVariant.cs index f3454636..defd2346 100644 --- a/Marechai.Database/Models/MachinesBySoftwareVariant.cs +++ b/Marechai.Database/Models/MachinesBySoftwareVariant.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MachinesBySoftwareVariant : BaseModel { - public class MachinesBySoftwareVariant : BaseModel - { - [Required] - public virtual Machine Machine { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - } + [Required] + public virtual Machine Machine { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Magazine.cs b/Marechai.Database/Models/Magazine.cs index e3fc34d2..f9cf897a 100644 --- a/Marechai.Database/Models/Magazine.cs +++ b/Marechai.Database/Models/Magazine.cs @@ -27,17 +27,17 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class Magazine : DocumentBase - { - [StringLength(8, MinimumLength = 8)] - public string Issn { get; set; } - [DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)] - public DateTime? FirstPublication { get; set; } +namespace Marechai.Database.Models; - public virtual Iso31661Numeric Country { get; set; } - public virtual ICollection Issues { get; set; } - public virtual ICollection Companies { get; set; } - } +public class Magazine : DocumentBase +{ + [StringLength(8, MinimumLength = 8)] + public string Issn { get; set; } + [DisplayFormat(DataFormatString = "{0:d}")] + [DataType(DataType.Date)] + public DateTime? FirstPublication { get; set; } + + public virtual Iso31661Numeric Country { get; set; } + public virtual ICollection Issues { get; set; } + public virtual ICollection Companies { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MagazineIssue.cs b/Marechai.Database/Models/MagazineIssue.cs index 9c156ec4..1e122bc3 100644 --- a/Marechai.Database/Models/MagazineIssue.cs +++ b/Marechai.Database/Models/MagazineIssue.cs @@ -27,27 +27,27 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class MagazineIssue : BaseModel - { - [Required] - public long MagazineId { get; set; } - [Required] - public string Caption { get; set; } - public string NativeCaption { get; set; } - [DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)] - public DateTime? Published { get; set; } - [StringLength(18)] - public string ProductCode { get; set; } - public short? Pages { get; set; } - public uint? IssueNumber { get; set; } +namespace Marechai.Database.Models; - public virtual Magazine Magazine { get; set; } - public virtual ICollection People { get; set; } - public virtual ICollection Machines { get; set; } - public virtual ICollection MachineFamilies { get; set; } - public virtual ICollection Coverdiscs { get; set; } - public virtual ICollection Scans { get; set; } - } +public class MagazineIssue : BaseModel +{ + [Required] + public long MagazineId { get; set; } + [Required] + public string Caption { get; set; } + public string NativeCaption { get; set; } + [DisplayFormat(DataFormatString = "{0:d}")] + [DataType(DataType.Date)] + public DateTime? Published { get; set; } + [StringLength(18)] + public string ProductCode { get; set; } + public short? Pages { get; set; } + public uint? IssueNumber { get; set; } + + public virtual Magazine Magazine { get; set; } + public virtual ICollection People { get; set; } + public virtual ICollection Machines { get; set; } + public virtual ICollection MachineFamilies { get; set; } + public virtual ICollection Coverdiscs { get; set; } + public virtual ICollection Scans { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MagazineScan.cs b/Marechai.Database/Models/MagazineScan.cs index d882661b..5cedabbe 100644 --- a/Marechai.Database/Models/MagazineScan.cs +++ b/Marechai.Database/Models/MagazineScan.cs @@ -25,12 +25,11 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MagazineScan : DocumentScanBase { - public class MagazineScan : DocumentScanBase - { - [Required] - public virtual MagazineIssue Magazine { get; set; } - public long MagazineId { get; set; } - } + [Required] + public virtual MagazineIssue Magazine { get; set; } + public long MagazineId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MagazinesByMachine.cs b/Marechai.Database/Models/MagazinesByMachine.cs index 20486275..7b8c2137 100644 --- a/Marechai.Database/Models/MagazinesByMachine.cs +++ b/Marechai.Database/Models/MagazinesByMachine.cs @@ -23,14 +23,13 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models -{ - public class MagazinesByMachine : BaseModel - { - public long MagazineId { get; set; } - public int MachineId { get; set; } +namespace Marechai.Database.Models; - public virtual MagazineIssue Magazine { get; set; } - public virtual Machine Machine { get; set; } - } +public class MagazinesByMachine : BaseModel +{ + public long MagazineId { get; set; } + public int MachineId { get; set; } + + public virtual MagazineIssue Magazine { get; set; } + public virtual Machine Machine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MagazinesByMachineFamily.cs b/Marechai.Database/Models/MagazinesByMachineFamily.cs index 8b5028f1..d46c42e7 100644 --- a/Marechai.Database/Models/MagazinesByMachineFamily.cs +++ b/Marechai.Database/Models/MagazinesByMachineFamily.cs @@ -23,14 +23,13 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models -{ - public class MagazinesByMachineFamily : BaseModel - { - public long MagazineId { get; set; } - public int MachineFamilyId { get; set; } +namespace Marechai.Database.Models; - public virtual MagazineIssue Magazine { get; set; } - public virtual MachineFamily MachineFamily { get; set; } - } +public class MagazinesByMachineFamily : BaseModel +{ + public long MagazineId { get; set; } + public int MachineFamilyId { get; set; } + + public virtual MagazineIssue Magazine { get; set; } + public virtual MachineFamily MachineFamily { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MarechaiContext.cs b/Marechai.Database/Models/MarechaiContext.cs index ed900f43..336fbf87 100644 --- a/Marechai.Database/Models/MarechaiContext.cs +++ b/Marechai.Database/Models/MarechaiContext.cs @@ -33,2107 +33,2220 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.Extensions.Configuration; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MarechaiContext : IdentityDbContext { - public class MarechaiContext : IdentityDbContext + readonly ValueConverter _hexToBytesConverter = + new(v => HexStringToBytesConverter.StringToHex(v), v => HexStringToBytesConverter.HexToString(v)); + + public MarechaiContext() {} + + public MarechaiContext(DbContextOptions options) : base(options) {} + + public virtual DbSet Audit { get; set; } + public virtual DbSet Books { get; set; } + public virtual DbSet BooksByMachines { get; set; } + public virtual DbSet BooksByMachineFamilies { get; set; } + public virtual DbSet BookScans { get; set; } + public virtual DbSet BrowserTests { get; set; } + public virtual DbSet CompaniesByBooks { get; set; } + public virtual DbSet CompaniesByDocuments { get; set; } + public virtual DbSet CompaniesByMagazines { get; set; } + public virtual DbSet CompaniesBySoftwareFamilies { get; set; } + public virtual DbSet CompaniesBySoftwareVariants { get; set; } + public virtual DbSet CompaniesBySoftwareVersions { get; set; } + public virtual DbSet Companies { get; set; } + public virtual DbSet CompanyDescriptions { get; set; } + public virtual DbSet CompanyLogos { get; set; } + public virtual DbSet CurrenciesInflation { get; set; } + public virtual DbSet CurrenciesPegging { get; set; } + public virtual DbSet Files { get; set; } + public virtual DbSet Documents { get; set; } + public virtual DbSet DocumentCompanies { get; set; } + public virtual DbSet DocumentPeople { get; set; } + public virtual DbSet DocumentRoles { get; set; } + public virtual DbSet DocumentsByMachines { get; set; } + public virtual DbSet DocumentsByMachineFamilies { get; set; } + public virtual DbSet DocumentScans { get; set; } + public virtual DbSet Dumps { get; set; } + public virtual DbSet DumpHardwares { get; set; } + public virtual DbSet FileDataStreams { get; set; } + public virtual DbSet Filesystems { get; set; } + public virtual DbSet FilesystemsByLogicalPartition { get; set; } + public virtual DbSet Forbidden { get; set; } + public virtual DbSet Gpus { get; set; } + public virtual DbSet GpusByMachine { get; set; } + public virtual DbSet GpusByOwnedMachine { get; set; } + public virtual DbSet InstructionSets { get; set; } + public virtual DbSet InstructionSetExtensions { get; set; } + public virtual DbSet InstructionSetExtensionsByProcessor { get; set; } + public virtual DbSet Iso31661Numeric { get; set; } + public virtual DbSet Iso4217 { get; set; } + public virtual DbSet Iso639 { get; set; } + public virtual DbSet Licenses { get; set; } + public virtual DbSet Log { get; set; } + public virtual DbSet LogicalPartitions { get; set; } + public virtual DbSet Machines { get; set; } + public virtual DbSet MachineFamilies { get; set; } + public virtual DbSet MachinePhotos { get; set; } + public virtual DbSet Magazines { get; set; } + public virtual DbSet MagazineIssues { get; set; } + public virtual DbSet MagazinesByMachines { get; set; } + public virtual DbSet MagazinesByMachinesFamilies { get; set; } + public virtual DbSet MagazineScans { get; set; } + public virtual DbSet MarechaiDb { get; set; } + public virtual DbSet MasteringTexts { get; set; } + public virtual DbSet Media { get; set; } + public virtual DbSet MediaDumps { get; set; } + public virtual DbSet MediaDumpFileImages { get; set; } + public virtual DbSet MediaDumpImages { get; set; } + public virtual DbSet MediaDumpSubchannelImages { get; set; } + public virtual DbSet MediaDumpTrackImages { get; set; } + public virtual DbSet MediaFiles { get; set; } + public virtual DbSet MediaTagDumps { get; set; } + public virtual DbSet MemoryByMachine { get; set; } + public virtual DbSet MemoryByOwnedMachine { get; set; } + public virtual DbSet MoneyDonations { get; set; } + public virtual DbSet News { get; set; } + public virtual DbSet OwnedMachines { get; set; } + public virtual DbSet OwnedMachinePhotos { get; set; } + public virtual DbSet PeopleByBooks { get; set; } + public virtual DbSet PeopleByDocuments { get; set; } + public virtual DbSet PeopleByMagazines { get; set; } + public virtual DbSet People { get; set; } + public virtual DbSet Processors { get; set; } + public virtual DbSet ProcessorsByMachine { get; set; } + public virtual DbSet ProcessorsByOwnedMachine { get; set; } + public virtual DbSet Resolutions { get; set; } + public virtual DbSet ResolutionsByGpu { get; set; } + public virtual DbSet ResolutionsByScreen { get; set; } + public virtual DbSet Screens { get; set; } + public virtual DbSet ScreensByMachine { get; set; } + public virtual DbSet SoftwareFamilies { get; set; } + public virtual DbSet SoftwareVariants { get; set; } + public virtual DbSet SoftwareVariantByCompilationMedia { get; set; } + public virtual DbSet SoftwareVersions { get; set; } + public virtual DbSet SoundByMachine { get; set; } + public virtual DbSet SoundByOwnedMachine { get; set; } + public virtual DbSet SoundSynths { get; set; } + public virtual DbSet StandaloneFiles { get; set; } + public virtual DbSet StorageByMachine { get; set; } + public virtual DbSet StorageByOwnedMachine { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - readonly ValueConverter hexToBytesConverter = - new(v => HexStringToBytesConverter.StringToHex(v), v => HexStringToBytesConverter.HexToString(v)); + if(optionsBuilder.IsConfigured) return; - public MarechaiContext() {} + IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json"); + IConfigurationRoot configuration = builder.Build(); - public MarechaiContext(DbContextOptions options) : base(options) {} + optionsBuilder + .UseMySql(configuration.GetConnectionString("DefaultConnection"), + new MariaDbServerVersion(new Version(10, 5, 0)), + b => b.UseMicrosoftJson()) + .UseLazyLoadingProxies(); + } - public virtual DbSet Audit { get; set; } - public virtual DbSet Books { get; set; } - public virtual DbSet BooksByMachines { get; set; } - public virtual DbSet BooksByMachineFamilies { get; set; } - public virtual DbSet BookScans { get; set; } - public virtual DbSet BrowserTests { get; set; } - public virtual DbSet CompaniesByBooks { get; set; } - public virtual DbSet CompaniesByDocuments { get; set; } - public virtual DbSet CompaniesByMagazines { get; set; } - public virtual DbSet CompaniesBySoftwareFamilies { get; set; } - public virtual DbSet CompaniesBySoftwareVariants { get; set; } - public virtual DbSet CompaniesBySoftwareVersions { get; set; } - public virtual DbSet Companies { get; set; } - public virtual DbSet CompanyDescriptions { get; set; } - public virtual DbSet CompanyLogos { get; set; } - public virtual DbSet CurrenciesInflation { get; set; } - public virtual DbSet CurrenciesPegging { get; set; } - public virtual DbSet Files { get; set; } - public virtual DbSet Documents { get; set; } - public virtual DbSet DocumentCompanies { get; set; } - public virtual DbSet DocumentPeople { get; set; } - public virtual DbSet DocumentRoles { get; set; } - public virtual DbSet DocumentsByMachines { get; set; } - public virtual DbSet DocumentsByMachineFamilies { get; set; } - public virtual DbSet DocumentScans { get; set; } - public virtual DbSet Dumps { get; set; } - public virtual DbSet DumpHardwares { get; set; } - public virtual DbSet FileDataStreams { get; set; } - public virtual DbSet Filesystems { get; set; } - public virtual DbSet FilesystemsByLogicalPartition { get; set; } - public virtual DbSet Forbidden { get; set; } - public virtual DbSet Gpus { get; set; } - public virtual DbSet GpusByMachine { get; set; } - public virtual DbSet GpusByOwnedMachine { get; set; } - public virtual DbSet InstructionSets { get; set; } - public virtual DbSet InstructionSetExtensions { get; set; } - public virtual DbSet InstructionSetExtensionsByProcessor { get; set; } - public virtual DbSet Iso31661Numeric { get; set; } - public virtual DbSet Iso4217 { get; set; } - public virtual DbSet Iso639 { get; set; } - public virtual DbSet Licenses { get; set; } - public virtual DbSet Log { get; set; } - public virtual DbSet LogicalPartitions { get; set; } - public virtual DbSet Machines { get; set; } - public virtual DbSet MachineFamilies { get; set; } - public virtual DbSet MachinePhotos { get; set; } - public virtual DbSet Magazines { get; set; } - public virtual DbSet MagazineIssues { get; set; } - public virtual DbSet MagazinesByMachines { get; set; } - public virtual DbSet MagazinesByMachinesFamilies { get; set; } - public virtual DbSet MagazineScans { get; set; } - public virtual DbSet MarechaiDb { get; set; } - public virtual DbSet MasteringTexts { get; set; } - public virtual DbSet Media { get; set; } - public virtual DbSet MediaDumps { get; set; } - public virtual DbSet MediaDumpFileImages { get; set; } - public virtual DbSet MediaDumpImages { get; set; } - public virtual DbSet MediaDumpSubchannelImages { get; set; } - public virtual DbSet MediaDumpTrackImages { get; set; } - public virtual DbSet MediaFiles { get; set; } - public virtual DbSet MediaTagDumps { get; set; } - public virtual DbSet MemoryByMachine { get; set; } - public virtual DbSet MemoryByOwnedMachine { get; set; } - public virtual DbSet MoneyDonations { get; set; } - public virtual DbSet News { get; set; } - public virtual DbSet OwnedMachines { get; set; } - public virtual DbSet OwnedMachinePhotos { get; set; } - public virtual DbSet PeopleByBooks { get; set; } - public virtual DbSet PeopleByDocuments { get; set; } - public virtual DbSet PeopleByMagazines { get; set; } - public virtual DbSet People { get; set; } - public virtual DbSet Processors { get; set; } - public virtual DbSet ProcessorsByMachine { get; set; } - public virtual DbSet ProcessorsByOwnedMachine { get; set; } - public virtual DbSet Resolutions { get; set; } - public virtual DbSet ResolutionsByGpu { get; set; } - public virtual DbSet ResolutionsByScreen { get; set; } - public virtual DbSet Screens { get; set; } - public virtual DbSet ScreensByMachine { get; set; } - public virtual DbSet SoftwareFamilies { get; set; } - public virtual DbSet SoftwareVariants { get; set; } - public virtual DbSet SoftwareVariantByCompilationMedia { get; set; } - public virtual DbSet SoftwareVersions { get; set; } - public virtual DbSet SoundByMachine { get; set; } - public virtual DbSet SoundByOwnedMachine { get; set; } - public virtual DbSet SoundSynths { get; set; } - public virtual DbSet StandaloneFiles { get; set; } - public virtual DbSet StorageByMachine { get; set; } - public virtual DbSet StorageByOwnedMachine { get; set; } + public async Task SaveChangesWithUserAsync(string userId) + { + ChangeTracker.DetectChanges(); + List audits = []; - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + foreach(EntityEntry entry in ChangeTracker.Entries()) { - if(optionsBuilder.IsConfigured) - return; + if(entry.Entity is Audit || entry.State == EntityState.Detached || entry.State == EntityState.Unchanged) + continue; - IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json"); - IConfigurationRoot configuration = builder.Build(); + var audit = new Audit(); + audit.UserId = userId; + audit.Table = entry.Metadata.GetTableName(); - optionsBuilder. - UseMySql(configuration.GetConnectionString("DefaultConnection"), - new MariaDbServerVersion(new Version(10, 5, 0)), b => b.UseMicrosoftJson()). - UseLazyLoadingProxies(); - } + Dictionary keys = new(); + Dictionary olds = new(); + Dictionary news = new(); + List columns = []; - public async Task SaveChangesWithUserAsync(string userId) - { - ChangeTracker.DetectChanges(); - List audits = new(); - - foreach(EntityEntry entry in ChangeTracker.Entries()) + foreach(PropertyEntry property in entry.Properties) { - if(entry.Entity is Audit || - entry.State == EntityState.Detached || - entry.State == EntityState.Unchanged) - continue; + string propertyName = property.Metadata.Name; + string columnName = property.Metadata.GetColumnName(); - var audit = new Audit(); - audit.UserId = userId; - audit.Table = entry.Metadata.GetTableName(); - - Dictionary keys = new(); - Dictionary olds = new(); - Dictionary news = new(); - List columns = new(); - - foreach(PropertyEntry property in entry.Properties) + if(property.Metadata.IsPrimaryKey()) { - string propertyName = property.Metadata.Name; - string columnName = property.Metadata.GetColumnName(); + keys[propertyName] = property.CurrentValue; - if(property.Metadata.IsPrimaryKey()) - { - keys[propertyName] = property.CurrentValue; - - continue; - } - - switch(entry.State) - { - case EntityState.Deleted: - audit.Type = AuditType.Deleted; - olds[propertyName] = property.CurrentValue; - - break; - case EntityState.Modified: - if(property.IsModified) - { - audit.Type = AuditType.Updated; - news[propertyName] = property.CurrentValue; - olds[propertyName] = property.OriginalValue; - columns.Add(columnName); - } - - break; - - case EntityState.Added: - audit.Type = AuditType.Created; - news[propertyName] = property.CurrentValue; - - break; - } + continue; } - if(keys.Count > 0) - audit.Keys = keys; + switch(entry.State) + { + case EntityState.Deleted: + audit.Type = AuditType.Deleted; + olds[propertyName] = property.CurrentValue; - if(olds.Count > 0) - audit.OldValues = olds; + break; + case EntityState.Modified: + if(property.IsModified) + { + audit.Type = AuditType.Updated; + news[propertyName] = property.CurrentValue; + olds[propertyName] = property.OriginalValue; + columns.Add(columnName); + } - if(news.Count > 0) - audit.NewValues = news; + break; - if(columns.Count > 0) - audit.AffectedColumns = columns; + case EntityState.Added: + audit.Type = AuditType.Created; + news[propertyName] = property.CurrentValue; - audits.Add(audit); + break; + } } - await Audit.AddRangeAsync(audits); + if(keys.Count > 0) audit.Keys = keys; - return await SaveChangesAsync(); + if(olds.Count > 0) audit.OldValues = olds; + + if(news.Count > 0) audit.NewValues = news; + + if(columns.Count > 0) audit.AffectedColumns = columns; + + audits.Add(audit); } - protected override void OnModelCreating(ModelBuilder modelBuilder) + await Audit.AddRangeAsync(audits); + + return await SaveChangesAsync(); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity(entity => { - base.OnModelCreating(modelBuilder); + entity.HasIndex(e => e.Title); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Title); + entity.HasIndex(e => e.NativeTitle); - entity.HasIndex(e => e.NativeTitle); + entity.HasIndex(e => e.Published); - entity.HasIndex(e => e.Published); + entity.HasIndex(e => e.CountryId); - entity.HasIndex(e => e.CountryId); + entity.HasIndex(e => e.Synopsis).IsFullText(); - entity.HasIndex(e => e.Synopsis).IsFullText(); + entity.HasIndex(e => e.Isbn); - entity.HasIndex(e => e.Isbn); + entity.HasIndex(e => e.Pages); - entity.HasIndex(e => e.Pages); + entity.HasIndex(e => e.Edition); - entity.HasIndex(e => e.Edition); + entity.HasOne(d => d.Previous) + .WithOne(d => d.Next) + .HasForeignKey(d => d.PreviousId) + .OnDelete(DeleteBehavior.ClientSetNull); - entity.HasOne(d => d.Previous).WithOne(d => d.Next).HasForeignKey(d => d.PreviousId). - OnDelete(DeleteBehavior.ClientSetNull); + entity.HasOne(d => d.Source) + .WithMany(d => d.Derivates) + .HasForeignKey(d => d.SourceId) + .OnDelete(DeleteBehavior.ClientSetNull); - entity.HasOne(d => d.Source).WithMany(d => d.Derivates).HasForeignKey(d => d.SourceId). - OnDelete(DeleteBehavior.ClientSetNull); + entity.HasOne(d => d.Country).WithMany(p => p.Books).HasForeignKey(d => d.CountryId); + }); - entity.HasOne(d => d.Country).WithMany(p => p.Books).HasForeignKey(d => d.CountryId); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.BookId); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.BookId); + entity.HasIndex(e => e.MachineId); - entity.HasIndex(e => e.MachineId); + entity.HasOne(d => d.Book).WithMany(p => p.Machines).HasForeignKey(d => d.BookId); - entity.HasOne(d => d.Book).WithMany(p => p.Machines).HasForeignKey(d => d.BookId); + entity.HasOne(d => d.Machine).WithMany(p => p.Books).HasForeignKey(d => d.MachineId); + }); - entity.HasOne(d => d.Machine).WithMany(p => p.Books).HasForeignKey(d => d.MachineId); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.BookId); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.BookId); + entity.HasIndex(e => e.MachineFamilyId); - entity.HasIndex(e => e.MachineFamilyId); + entity.HasOne(d => d.Book).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.BookId); - entity.HasOne(d => d.Book).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.BookId); + entity.HasOne(d => d.MachineFamily).WithMany(p => p.Books).HasForeignKey(d => d.MachineFamilyId); + }); - entity.HasOne(d => d.MachineFamily).WithMany(p => p.Books).HasForeignKey(d => d.MachineFamilyId); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("browser_tests"); - modelBuilder.Entity(entity => - { - entity.ToTable("browser_tests"); + entity.HasIndex(e => e.Browser).HasDatabaseName("idx_browser_tests_browser"); - entity.HasIndex(e => e.Browser).HasDatabaseName("idx_browser_tests_browser"); + entity.HasIndex(e => e.Os).HasDatabaseName("idx_browser_tests_os"); - entity.HasIndex(e => e.Os).HasDatabaseName("idx_browser_tests_os"); + entity.HasIndex(e => e.Platform).HasDatabaseName("idx_browser_tests_platform"); - entity.HasIndex(e => e.Platform).HasDatabaseName("idx_browser_tests_platform"); + entity.HasIndex(e => e.UserAgent).HasDatabaseName("idx_browser_tests_user_agent"); - entity.HasIndex(e => e.UserAgent).HasDatabaseName("idx_browser_tests_user_agent"); + entity.HasIndex(e => e.Version).HasDatabaseName("idx_browser_tests_version"); - entity.HasIndex(e => e.Version).HasDatabaseName("idx_browser_tests_version"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.Property(e => e.Agif).HasColumnName("agif").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Agif).HasColumnName("agif").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Browser) + .IsRequired() + .HasColumnName("browser") + .HasColumnType("varchar(64)") + .HasDefaultValueSql("''"); - entity.Property(e => e.Browser).IsRequired().HasColumnName("browser").HasColumnType("varchar(64)"). - HasDefaultValueSql("''"); + entity.Property(e => e.Colors) + .HasColumnName("colors") + .HasColumnType("tinyint(1)") + .HasDefaultValueSql("'0'"); - entity.Property(e => e.Colors).HasColumnName("colors").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Flash).HasColumnName("flash").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Flash).HasColumnName("flash").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Frames) + .HasColumnName("frames") + .HasColumnType("tinyint(1)") + .HasDefaultValueSql("'0'"); - entity.Property(e => e.Frames).HasColumnName("frames").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Gif87).HasColumnName("gif87").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Gif87).HasColumnName("gif87").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Gif89).HasColumnName("gif89").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Gif89).HasColumnName("gif89").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Jpeg).HasColumnName("jpeg").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Jpeg).HasColumnName("jpeg").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Js).HasColumnName("js").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Js).HasColumnName("js").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); + entity.Property(e => e.Os) + .IsRequired() + .HasColumnName("os") + .HasColumnType("varchar(32)") + .HasDefaultValueSql("''"); - entity.Property(e => e.Os).IsRequired().HasColumnName("os").HasColumnType("varchar(32)"). - HasDefaultValueSql("''"); + entity.Property(e => e.Platform) + .IsRequired() + .HasColumnName("platform") + .HasColumnType("varchar(8)") + .HasDefaultValueSql("''"); - entity.Property(e => e.Platform).IsRequired().HasColumnName("platform").HasColumnType("varchar(8)"). - HasDefaultValueSql("''"); + entity.Property(e => e.Png).HasColumnName("png").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Png).HasColumnName("png").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); + entity.Property(e => e.Pngt).HasColumnName("pngt").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Pngt).HasColumnName("pngt").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Table).HasColumnName("table").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Table).HasColumnName("table").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.UserAgent) + .IsRequired() + .HasColumnName("user_agent") + .HasColumnType("varchar(128)") + .HasDefaultValueSql("''"); - entity.Property(e => e.UserAgent).IsRequired().HasColumnName("user_agent"). - HasColumnType("varchar(128)").HasDefaultValueSql("''"); + entity.Property(e => e.Version) + .IsRequired() + .HasColumnName("version") + .HasColumnType("varchar(16)") + .HasDefaultValueSql("''"); + }); - entity.Property(e => e.Version).IsRequired().HasColumnName("version").HasColumnType("varchar(16)"). - HasDefaultValueSql("''"); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("marechai_db"); - modelBuilder.Entity(entity => - { - entity.ToTable("marechai_db"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.Property(e => e.Updated) + .HasColumnName("updated") + .HasColumnType("datetime") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); - entity.Property(e => e.Updated).HasColumnName("updated").HasColumnType("datetime"). - HasDefaultValueSql("CURRENT_TIMESTAMP"); + entity.Property(e => e.Version).HasColumnName("version").HasColumnType("int(11)"); + }); - entity.Property(e => e.Version).HasColumnName("version").HasColumnType("int(11)"); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.BookId); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.BookId); + entity.HasIndex(e => e.CompanyId); - entity.HasIndex(e => e.CompanyId); + entity.HasIndex(e => e.RoleId); - entity.HasIndex(e => e.RoleId); + entity.HasOne(d => d.Book).WithMany(p => p.Companies).HasForeignKey(d => d.BookId); - entity.HasOne(d => d.Book).WithMany(p => p.Companies).HasForeignKey(d => d.BookId); + entity.HasOne(d => d.Company).WithMany(p => p.Books).HasForeignKey(d => d.CompanyId); + }); - entity.HasOne(d => d.Company).WithMany(p => p.Books).HasForeignKey(d => d.CompanyId); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.DocumentId); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.DocumentId); + entity.HasIndex(e => e.CompanyId); - entity.HasIndex(e => e.CompanyId); + entity.HasIndex(e => e.RoleId); - entity.HasIndex(e => e.RoleId); + entity.HasOne(d => d.Document).WithMany(p => p.Companies).HasForeignKey(d => d.DocumentId); - entity.HasOne(d => d.Document).WithMany(p => p.Companies).HasForeignKey(d => d.DocumentId); + entity.HasOne(d => d.Company).WithMany(p => p.Documents).HasForeignKey(d => d.CompanyId); + }); - entity.HasOne(d => d.Company).WithMany(p => p.Documents).HasForeignKey(d => d.CompanyId); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.MagazineId); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.MagazineId); + entity.HasIndex(e => e.CompanyId); - entity.HasIndex(e => e.CompanyId); + entity.HasIndex(e => e.RoleId); - entity.HasIndex(e => e.RoleId); + entity.HasOne(d => d.Magazine).WithMany(p => p.Companies).HasForeignKey(d => d.MagazineId); - entity.HasOne(d => d.Magazine).WithMany(p => p.Companies).HasForeignKey(d => d.MagazineId); + entity.HasOne(d => d.Company).WithMany(p => p.Magazines).HasForeignKey(d => d.CompanyId); + }); - entity.HasOne(d => d.Company).WithMany(p => p.Magazines).HasForeignKey(d => d.CompanyId); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("companies"); - modelBuilder.Entity(entity => - { - entity.ToTable("companies"); + entity.HasIndex(e => e.Address).HasDatabaseName("idx_companies_address"); - entity.HasIndex(e => e.Address).HasDatabaseName("idx_companies_address"); + entity.HasIndex(e => e.City).HasDatabaseName("idx_companies_city"); - entity.HasIndex(e => e.City).HasDatabaseName("idx_companies_city"); + entity.HasIndex(e => e.CountryId).HasDatabaseName("idx_companies_country"); - entity.HasIndex(e => e.CountryId).HasDatabaseName("idx_companies_country"); + entity.HasIndex(e => e.Facebook).HasDatabaseName("idx_companies_facebook"); - entity.HasIndex(e => e.Facebook).HasDatabaseName("idx_companies_facebook"); + entity.HasIndex(e => e.Founded).HasDatabaseName("idx_companies_founded"); - entity.HasIndex(e => e.Founded).HasDatabaseName("idx_companies_founded"); + entity.HasIndex(e => e.Name).HasDatabaseName("idx_companies_name"); - entity.HasIndex(e => e.Name).HasDatabaseName("idx_companies_name"); + entity.HasIndex(e => e.PostalCode).HasDatabaseName("idx_companies_postal_code"); - entity.HasIndex(e => e.PostalCode).HasDatabaseName("idx_companies_postal_code"); + entity.HasIndex(e => e.Province).HasDatabaseName("idx_companies_province"); - entity.HasIndex(e => e.Province).HasDatabaseName("idx_companies_province"); + entity.HasIndex(e => e.Sold).HasDatabaseName("idx_companies_sold"); - entity.HasIndex(e => e.Sold).HasDatabaseName("idx_companies_sold"); + entity.HasIndex(e => e.SoldToId).HasDatabaseName("idx_companies_sold_to"); - entity.HasIndex(e => e.SoldToId).HasDatabaseName("idx_companies_sold_to"); + entity.HasIndex(e => e.Status).HasDatabaseName("idx_companies_status"); - entity.HasIndex(e => e.Status).HasDatabaseName("idx_companies_status"); + entity.HasIndex(e => e.Twitter).HasDatabaseName("idx_companies_twitter"); - entity.HasIndex(e => e.Twitter).HasDatabaseName("idx_companies_twitter"); + entity.HasIndex(e => e.Website).HasDatabaseName("idx_companies_website"); - entity.HasIndex(e => e.Website).HasDatabaseName("idx_companies_website"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.Property(e => e.Address).HasColumnName("address").HasColumnType("varchar(80)"); - entity.Property(e => e.Address).HasColumnName("address").HasColumnType("varchar(80)"); + entity.Property(e => e.City).HasColumnName("city").HasColumnType("varchar(80)"); - entity.Property(e => e.City).HasColumnName("city").HasColumnType("varchar(80)"); + entity.Property(e => e.CountryId).HasColumnName("country").HasColumnType("smallint(3)"); - entity.Property(e => e.CountryId).HasColumnName("country").HasColumnType("smallint(3)"); + entity.Property(e => e.Facebook).HasColumnName("facebook").HasColumnType("varchar(45)"); - entity.Property(e => e.Facebook).HasColumnName("facebook").HasColumnType("varchar(45)"); + entity.Property(e => e.Founded).HasColumnName("founded").HasColumnType("datetime"); - entity.Property(e => e.Founded).HasColumnName("founded").HasColumnType("datetime"); + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("varchar(128)") + .HasDefaultValueSql("''"); - entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("varchar(128)"). - HasDefaultValueSql("''"); + entity.Property(e => e.PostalCode).HasColumnName("postal_code").HasColumnType("varchar(25)"); - entity.Property(e => e.PostalCode).HasColumnName("postal_code").HasColumnType("varchar(25)"); + entity.Property(e => e.Province).HasColumnName("province").HasColumnType("varchar(80)"); - entity.Property(e => e.Province).HasColumnName("province").HasColumnType("varchar(80)"); + entity.Property(e => e.Sold).HasColumnName("sold").HasColumnType("datetime"); - entity.Property(e => e.Sold).HasColumnName("sold").HasColumnType("datetime"); + entity.Property(e => e.SoldToId).HasColumnName("sold_to").HasColumnType("int(11)"); - entity.Property(e => e.SoldToId).HasColumnName("sold_to").HasColumnType("int(11)"); + entity.Property(e => e.Status).HasColumnName("status").HasColumnType("int(11)"); - entity.Property(e => e.Status).HasColumnName("status").HasColumnType("int(11)"); + entity.Property(e => e.Twitter).HasColumnName("twitter").HasColumnType("varchar(45)"); - entity.Property(e => e.Twitter).HasColumnName("twitter").HasColumnType("varchar(45)"); + entity.Property(e => e.Website).HasColumnName("website").HasColumnType("varchar(255)"); - entity.Property(e => e.Website).HasColumnName("website").HasColumnType("varchar(255)"); + entity.HasOne(d => d.Country) + .WithMany(p => p.Companies) + .HasForeignKey(d => d.CountryId) + .HasConstraintName("fk_companies_country"); - entity.HasOne(d => d.Country).WithMany(p => p.Companies).HasForeignKey(d => d.CountryId). - HasConstraintName("fk_companies_country"); + entity.HasOne(d => d.SoldTo) + .WithMany(p => p.InverseSoldToNavigation) + .HasForeignKey(d => d.SoldToId) + .HasConstraintName("fk_companies_sold_to"); - entity.HasOne(d => d.SoldTo).WithMany(p => p.InverseSoldToNavigation).HasForeignKey(d => d.SoldToId). - HasConstraintName("fk_companies_sold_to"); + entity.HasOne(d => d.DocumentCompany) + .WithOne(p => p.Company) + .HasForeignKey(d => d.CompanyId) + .OnDelete(DeleteBehavior.SetNull); + }); - entity.HasOne(d => d.DocumentCompany).WithOne(p => p.Company). - HasForeignKey(d => d.CompanyId).OnDelete(DeleteBehavior.SetNull); - }); - - modelBuilder.Entity().HasIndex(e => e.Text).IsFullText(); + modelBuilder.Entity().HasIndex(e => e.Text).IsFullText(); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { - entity.HasKey(e => new - { - e.Id, - e.CompanyId, - LogoGuid = e.Guid - }); - - entity.ToTable("company_logos"); - - entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_company_id"); - - entity.HasIndex(e => e.Id).HasDatabaseName("idx_id").IsUnique(); - - entity.HasIndex(e => e.Guid).HasDatabaseName("idx_guid"); - - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)").ValueGeneratedOnAdd(); - - entity.Property(e => e.CompanyId).HasColumnName("company_id").HasColumnType("int(11)"); - - entity.Property(e => e.Guid).HasColumnName("logo_guid").HasColumnType("char(36)"); - - entity.Property(e => e.Year).HasColumnName("year").HasColumnType("int(4)"); - - entity.HasOne(d => d.Company).WithMany(p => p.Logos).HasForeignKey(d => d.CompanyId). - OnDelete(DeleteBehavior.ClientSetNull).HasConstraintName("fk_company_logos_company1"); + e.Id, + e.CompanyId, + LogoGuid = e.Guid }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Title); + entity.ToTable("company_logos"); - entity.HasIndex(e => e.NativeTitle); + entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_company_id"); - entity.HasIndex(e => e.Published); + entity.HasIndex(e => e.Id).HasDatabaseName("idx_id").IsUnique(); - entity.HasIndex(e => e.CountryId); + entity.HasIndex(e => e.Guid).HasDatabaseName("idx_guid"); - entity.HasIndex(e => e.Synopsis).IsFullText(); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)").ValueGeneratedOnAdd(); - entity.HasOne(d => d.Country).WithMany(p => p.Documents).HasForeignKey(d => d.CountryId); - }); + entity.Property(e => e.CompanyId).HasColumnName("company_id").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Name); + entity.Property(e => e.Guid).HasColumnName("logo_guid").HasColumnType("char(36)"); - entity.HasIndex(e => e.CompanyId).IsUnique(); - }); + entity.Property(e => e.Year).HasColumnName("year").HasColumnType("int(4)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Name); + entity.HasOne(d => d.Company) + .WithMany(p => p.Logos) + .HasForeignKey(d => d.CompanyId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_company_logos_company1"); + }); - entity.HasIndex(e => e.Surname); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Title); - entity.HasIndex(e => e.PersonId).IsUnique(); + entity.HasIndex(e => e.NativeTitle); - entity.HasIndex(e => e.Alias); + entity.HasIndex(e => e.Published); - entity.HasIndex(e => e.DisplayName); + entity.HasIndex(e => e.CountryId); - entity.HasOne(d => d.Person).WithOne(p => p.DocumentPerson). - HasForeignKey(d => d.DocumentPersonId).OnDelete(DeleteBehavior.SetNull); - }); + entity.HasIndex(e => e.Synopsis).IsFullText(); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Name); + entity.HasOne(d => d.Country).WithMany(p => p.Documents).HasForeignKey(d => d.CountryId); + }); - entity.HasIndex(e => e.Enabled); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Name); - entity.Property(p => p.Enabled).HasDefaultValue(true); - }); + entity.HasIndex(e => e.CompanyId).IsUnique(); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.DocumentId); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Name); - entity.HasIndex(e => e.MachineId); + entity.HasIndex(e => e.Surname); - entity.HasOne(d => d.Document).WithMany(p => p.Machines).HasForeignKey(d => d.DocumentId); + entity.HasIndex(e => e.PersonId).IsUnique(); - entity.HasOne(d => d.Machine).WithMany(p => p.Documents).HasForeignKey(d => d.MachineId); - }); + entity.HasIndex(e => e.Alias); - modelBuilder.Entity(entity => - { - entity.ToTable("DocumentsByMachineFamily"); + entity.HasIndex(e => e.DisplayName); - entity.HasIndex(e => e.DocumentId); + entity.HasOne(d => d.Person) + .WithOne(p => p.DocumentPerson) + .HasForeignKey(d => d.DocumentPersonId) + .OnDelete(DeleteBehavior.SetNull); + }); - entity.HasIndex(e => e.MachineFamilyId); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Name); - entity.HasOne(d => d.Document).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.DocumentId); + entity.HasIndex(e => e.Enabled); - entity.HasOne(d => d.MachineFamily).WithMany(p => p.Documents).HasForeignKey(d => d.MachineFamilyId); - }); + entity.Property(p => p.Enabled).HasDefaultValue(true); + }); - modelBuilder.Entity(entity => - { - entity.ToTable("forbidden"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.DocumentId); - entity.HasIndex(e => e.Browser).HasDatabaseName("idx_forbidden_browser"); + entity.HasIndex(e => e.MachineId); - entity.HasIndex(e => e.Date).HasDatabaseName("idx_forbidden_date"); + entity.HasOne(d => d.Document).WithMany(p => p.Machines).HasForeignKey(d => d.DocumentId); - entity.HasIndex(e => e.Ip).HasDatabaseName("idx_forbidden_ip"); + entity.HasOne(d => d.Machine).WithMany(p => p.Documents).HasForeignKey(d => d.MachineId); + }); - entity.HasIndex(e => e.Referer).HasDatabaseName("idx_forbidden_referer"); + modelBuilder.Entity(entity => + { + entity.ToTable("DocumentsByMachineFamily"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.HasIndex(e => e.DocumentId); - entity.Property(e => e.Browser).IsRequired().HasColumnName("browser").HasColumnType("char(128)"). - HasDefaultValueSql("''"); + entity.HasIndex(e => e.MachineFamilyId); - entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("char(20)"). - HasDefaultValueSql("''"); + entity.HasOne(d => d.Document).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.DocumentId); - entity.Property(e => e.Ip).IsRequired().HasColumnName("ip").HasColumnType("char(16)"). - HasDefaultValueSql("''"); + entity.HasOne(d => d.MachineFamily).WithMany(p => p.Documents).HasForeignKey(d => d.MachineFamilyId); + }); - entity.Property(e => e.Referer).IsRequired().HasColumnName("referer").HasColumnType("char(255)"). - HasDefaultValueSql("''"); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("forbidden"); - modelBuilder.Entity(entity => - { - entity.ToTable("gpus"); + entity.HasIndex(e => e.Browser).HasDatabaseName("idx_forbidden_browser"); - entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_gpus_company"); + entity.HasIndex(e => e.Date).HasDatabaseName("idx_forbidden_date"); - entity.HasIndex(e => e.DieSize).HasDatabaseName("idx_gpus_die_size"); + entity.HasIndex(e => e.Ip).HasDatabaseName("idx_forbidden_ip"); - entity.HasIndex(e => e.Introduced).HasDatabaseName("idx_gpus_introduced"); + entity.HasIndex(e => e.Referer).HasDatabaseName("idx_forbidden_referer"); - entity.HasIndex(e => e.ModelCode).HasDatabaseName("idx_gpus_model_code"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.HasIndex(e => e.Name).HasDatabaseName("idx_gpus_name"); + entity.Property(e => e.Browser) + .IsRequired() + .HasColumnName("browser") + .HasColumnType("char(128)") + .HasDefaultValueSql("''"); - entity.HasIndex(e => e.Package).HasDatabaseName("idx_gpus_package"); + entity.Property(e => e.Date) + .IsRequired() + .HasColumnName("date") + .HasColumnType("char(20)") + .HasDefaultValueSql("''"); - entity.HasIndex(e => e.Process).HasDatabaseName("idx_gpus_process"); + entity.Property(e => e.Ip) + .IsRequired() + .HasColumnName("ip") + .HasColumnType("char(16)") + .HasDefaultValueSql("''"); - entity.HasIndex(e => e.ProcessNm).HasDatabaseName("idx_gpus_process_nm"); + entity.Property(e => e.Referer) + .IsRequired() + .HasColumnName("referer") + .HasColumnType("char(255)") + .HasDefaultValueSql("''"); + }); - entity.HasIndex(e => e.Transistors).HasDatabaseName("idx_gpus_transistors"); + modelBuilder.Entity(entity => + { + entity.ToTable("gpus"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_gpus_company"); - entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"); + entity.HasIndex(e => e.DieSize).HasDatabaseName("idx_gpus_die_size"); - entity.Property(e => e.DieSize).HasColumnName("die_size"); + entity.HasIndex(e => e.Introduced).HasDatabaseName("idx_gpus_introduced"); - entity.Property(e => e.Introduced).HasColumnName("introduced").HasColumnType("datetime"); + entity.HasIndex(e => e.ModelCode).HasDatabaseName("idx_gpus_model_code"); - entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)"); + entity.HasIndex(e => e.Name).HasDatabaseName("idx_gpus_name"); - entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(128)"). - HasDefaultValueSql("''"); + entity.HasIndex(e => e.Package).HasDatabaseName("idx_gpus_package"); - entity.Property(e => e.Package).HasColumnName("package").HasColumnType("varchar(45)"); + entity.HasIndex(e => e.Process).HasDatabaseName("idx_gpus_process"); - entity.Property(e => e.Process).HasColumnName("process").HasColumnType("varchar(45)"); + entity.HasIndex(e => e.ProcessNm).HasDatabaseName("idx_gpus_process_nm"); - entity.Property(e => e.ProcessNm).HasColumnName("process_nm"); + entity.HasIndex(e => e.Transistors).HasDatabaseName("idx_gpus_transistors"); - entity.Property(e => e.Transistors).HasColumnName("transistors").HasColumnType("bigint(20)"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.HasOne(d => d.Company).WithMany(p => p.Gpus).HasForeignKey(d => d.CompanyId). - HasConstraintName("fk_gpus_company"); - }); + entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.ToTable("gpus_by_machine"); + entity.Property(e => e.DieSize).HasColumnName("die_size"); - entity.HasIndex(e => e.GpuId).HasDatabaseName("idx_gpus_by_machine_gpus"); + entity.Property(e => e.Introduced).HasColumnName("introduced").HasColumnType("datetime"); - entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_gpus_by_machine_machine"); + entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("char(128)") + .HasDefaultValueSql("''"); - entity.Property(e => e.GpuId).HasColumnName("gpu").HasColumnType("int(11)"); + entity.Property(e => e.Package).HasColumnName("package").HasColumnType("varchar(45)"); - entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); + entity.Property(e => e.Process).HasColumnName("process").HasColumnType("varchar(45)"); - entity.HasOne(d => d.Gpu).WithMany(p => p.GpusByMachine).HasForeignKey(d => d.GpuId). - HasConstraintName("fk_gpus_by_machine_gpu"); + entity.Property(e => e.ProcessNm).HasColumnName("process_nm"); - entity.HasOne(d => d.Machine).WithMany(p => p.Gpus).HasForeignKey(d => d.MachineId). - HasConstraintName("fk_gpus_by_machine_machine"); - }); + entity.Property(e => e.Transistors).HasColumnName("transistors").HasColumnType("bigint(20)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.GpuId); + entity.HasOne(d => d.Company) + .WithMany(p => p.Gpus) + .HasForeignKey(d => d.CompanyId) + .HasConstraintName("fk_gpus_company"); + }); - entity.HasIndex(e => e.OwnedMachineId); + modelBuilder.Entity(entity => + { + entity.ToTable("gpus_by_machine"); - entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Gpus).HasForeignKey(d => d.OwnedMachineId); - }); + entity.HasIndex(e => e.GpuId).HasDatabaseName("idx_gpus_by_machine_gpus"); - modelBuilder.Entity(entity => - { - entity.ToTable("instruction_set_extensions"); + entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_gpus_by_machine_machine"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); - entity.Property(e => e.Extension).IsRequired().HasColumnName("extension").HasColumnType("varchar(45)"); - }); + entity.Property(e => e.GpuId).HasColumnName("gpu").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasKey(e => new - { - e.Id, - e.ProcessorId, - e.ExtensionId - }); + entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); - entity.ToTable("instruction_set_extensions_by_processor"); + entity.HasOne(d => d.Gpu) + .WithMany(p => p.GpusByMachine) + .HasForeignKey(d => d.GpuId) + .HasConstraintName("fk_gpus_by_machine_gpu"); - entity.HasIndex(e => e.ExtensionId).HasDatabaseName("idx_setextension_extension"); + entity.HasOne(d => d.Machine) + .WithMany(p => p.Gpus) + .HasForeignKey(d => d.MachineId) + .HasConstraintName("fk_gpus_by_machine_machine"); + }); - entity.HasIndex(e => e.ProcessorId).HasDatabaseName("idx_setextension_processor"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.GpuId); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)").ValueGeneratedOnAdd(); + entity.HasIndex(e => e.OwnedMachineId); - entity.Property(e => e.ProcessorId).HasColumnName("processor_id").HasColumnType("int(11)"); + entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Gpus).HasForeignKey(d => d.OwnedMachineId); + }); - entity.Property(e => e.ExtensionId).HasColumnName("extension_id").HasColumnType("int(11)"); + modelBuilder.Entity(entity => + { + entity.ToTable("instruction_set_extensions"); - entity.HasOne(d => d.Extension).WithMany(p => p.InstructionSetExtensionsByProcessor). - HasForeignKey(d => d.ExtensionId).OnDelete(DeleteBehavior.ClientSetNull). - HasConstraintName("fk_extension_extension_id"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.HasOne(d => d.Processor).WithMany(p => p.InstructionSetExtensions). - HasForeignKey(d => d.ProcessorId).OnDelete(DeleteBehavior.ClientSetNull). - HasConstraintName("fk_extension_processor_id"); - }); + entity.Property(e => e.Extension).IsRequired().HasColumnName("extension").HasColumnType("varchar(45)"); + }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { - entity.ToTable("instruction_sets"); - - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - - entity.Property(e => e.Name).IsRequired().HasColumnName("instruction_set").HasColumnType("varchar(45)"); + e.Id, + e.ProcessorId, + e.ExtensionId }); - modelBuilder.Entity(entity => - { - entity.ToTable("iso3166_1_numeric"); + entity.ToTable("instruction_set_extensions_by_processor"); - entity.HasIndex(e => e.Name).HasDatabaseName("idx_name"); + entity.HasIndex(e => e.ExtensionId).HasDatabaseName("idx_setextension_extension"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("smallint(3)"); + entity.HasIndex(e => e.ProcessorId).HasDatabaseName("idx_setextension_processor"); - entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("varchar(64)"); - }); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)").ValueGeneratedOnAdd(); - modelBuilder.Entity(entity => - { - entity.ToTable("ISO_639-3"); + entity.Property(e => e.ProcessorId).HasColumnName("processor_id").HasColumnType("int(11)"); - entity.HasKey(e => e.Id); + entity.Property(e => e.ExtensionId).HasColumnName("extension_id").HasColumnType("int(11)"); - entity.HasIndex(e => e.Part2B); + entity.HasOne(d => d.Extension) + .WithMany(p => p.InstructionSetExtensionsByProcessor) + .HasForeignKey(d => d.ExtensionId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_extension_extension_id"); - entity.HasIndex(e => e.Part2T); + entity.HasOne(d => d.Processor) + .WithMany(p => p.InstructionSetExtensions) + .HasForeignKey(d => d.ProcessorId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_extension_processor_id"); + }); - entity.HasIndex(e => e.Part1); + modelBuilder.Entity(entity => + { + entity.ToTable("instruction_sets"); - entity.HasIndex(e => e.Scope); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.HasIndex(e => e.Type); + entity.Property(e => e.Name).IsRequired().HasColumnName("instruction_set").HasColumnType("varchar(45)"); + }); - entity.HasIndex(e => e.ReferenceName); + modelBuilder.Entity(entity => + { + entity.ToTable("iso3166_1_numeric"); - entity.HasIndex(e => e.Comment); + entity.HasIndex(e => e.Name).HasDatabaseName("idx_name"); - entity.Property(e => e.ReferenceName).HasColumnName("Ref_Name"); - }); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("smallint(3)"); - modelBuilder.Entity(entity => - { - entity.ToTable("log"); + entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("varchar(64)"); + }); - entity.HasIndex(e => e.Browser).HasDatabaseName("idx_log_browser"); + modelBuilder.Entity(entity => + { + entity.ToTable("ISO_639-3"); - entity.HasIndex(e => e.Date).HasDatabaseName("idx_log_date"); + entity.HasKey(e => e.Id); - entity.HasIndex(e => e.Ip).HasDatabaseName("idx_log_ip"); + entity.HasIndex(e => e.Part2B); - entity.HasIndex(e => e.Referer).HasDatabaseName("idx_log_referer"); + entity.HasIndex(e => e.Part2T); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.HasIndex(e => e.Part1); - entity.Property(e => e.Browser).IsRequired().HasColumnName("browser").HasColumnType("char(128)"). - HasDefaultValueSql("''"); + entity.HasIndex(e => e.Scope); - entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("char(20)"). - HasDefaultValueSql("''"); + entity.HasIndex(e => e.Type); - entity.Property(e => e.Ip).IsRequired().HasColumnName("ip").HasColumnType("char(16)"). - HasDefaultValueSql("''"); + entity.HasIndex(e => e.ReferenceName); - entity.Property(e => e.Referer).IsRequired().HasColumnName("referer").HasColumnType("char(255)"). - HasDefaultValueSql("''"); - }); + entity.HasIndex(e => e.Comment); - modelBuilder.Entity(entity => - { - entity.ToTable("machine_families"); + entity.Property(e => e.ReferenceName).HasColumnName("Ref_Name"); + }); - entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_machine_families_company"); + modelBuilder.Entity(entity => + { + entity.ToTable("log"); - entity.HasIndex(e => e.Name).HasDatabaseName("idx_machine_families_name"); + entity.HasIndex(e => e.Browser).HasDatabaseName("idx_log_browser"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.HasIndex(e => e.Date).HasDatabaseName("idx_log_date"); - entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"); + entity.HasIndex(e => e.Ip).HasDatabaseName("idx_log_ip"); - entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("varchar(255)"); + entity.HasIndex(e => e.Referer).HasDatabaseName("idx_log_referer"); - entity.HasOne(d => d.Company).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.CompanyId). - HasConstraintName("fk_machine_families_company"); - }); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.ToTable("machines"); + entity.Property(e => e.Browser) + .IsRequired() + .HasColumnName("browser") + .HasColumnType("char(128)") + .HasDefaultValueSql("''"); - entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_machines_company"); + entity.Property(e => e.Date) + .IsRequired() + .HasColumnName("date") + .HasColumnType("char(20)") + .HasDefaultValueSql("''"); - entity.HasIndex(e => e.FamilyId).HasDatabaseName("idx_machines_family"); + entity.Property(e => e.Ip) + .IsRequired() + .HasColumnName("ip") + .HasColumnType("char(16)") + .HasDefaultValueSql("''"); - entity.HasIndex(e => e.Introduced).HasDatabaseName("idx_machines_introduced"); + entity.Property(e => e.Referer) + .IsRequired() + .HasColumnName("referer") + .HasColumnType("char(255)") + .HasDefaultValueSql("''"); + }); - entity.HasIndex(e => e.Model).HasDatabaseName("idx_machines_model"); + modelBuilder.Entity(entity => + { + entity.ToTable("machine_families"); - entity.HasIndex(e => e.Name).HasDatabaseName("idx_machines_name"); + entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_machine_families_company"); - entity.HasIndex(e => e.Type).HasDatabaseName("idx_machines_type"); + entity.HasIndex(e => e.Name).HasDatabaseName("idx_machine_families_name"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"); - entity.Property(e => e.FamilyId).HasColumnName("family").HasColumnType("int(11)"); + entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("varchar(255)"); - entity.Property(e => e.Introduced).HasColumnName("introduced").HasColumnType("datetime"); + entity.HasOne(d => d.Company) + .WithMany(p => p.MachineFamilies) + .HasForeignKey(d => d.CompanyId) + .HasConstraintName("fk_machine_families_company"); + }); - entity.Property(e => e.Model).HasColumnName("model").HasColumnType("varchar(50)"); + modelBuilder.Entity(entity => + { + entity.ToTable("machines"); - entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("varchar(255)"); + entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_machines_company"); - entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'"); + entity.HasIndex(e => e.FamilyId).HasDatabaseName("idx_machines_family"); - entity.HasOne(d => d.Company).WithMany(p => p.Machines).HasForeignKey(d => d.CompanyId). - OnDelete(DeleteBehavior.ClientSetNull).HasConstraintName("fk_machines_company"); + entity.HasIndex(e => e.Introduced).HasDatabaseName("idx_machines_introduced"); - entity.HasOne(d => d.Family).WithMany(p => p.Machines).HasForeignKey(d => d.FamilyId). - HasConstraintName("fk_machines_family"); - }); + entity.HasIndex(e => e.Model).HasDatabaseName("idx_machines_model"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.AcquisitionDate); + entity.HasIndex(e => e.Name).HasDatabaseName("idx_machines_name"); - entity.HasIndex(e => e.LostDate); + entity.HasIndex(e => e.Type).HasDatabaseName("idx_machines_type"); - entity.HasIndex(e => e.Status); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.HasIndex(e => e.LastStatusDate); + entity.Property(e => e.CompanyId) + .HasColumnName("company") + .HasColumnType("int(11)") + .HasDefaultValueSql("'0'"); - entity.HasIndex(e => e.Trade); + entity.Property(e => e.FamilyId).HasColumnName("family").HasColumnType("int(11)"); - entity.HasIndex(e => e.Boxed); + entity.Property(e => e.Introduced).HasColumnName("introduced").HasColumnType("datetime"); - entity.HasIndex(e => e.Manuals); + entity.Property(e => e.Model).HasColumnName("model").HasColumnType("varchar(50)"); - entity.HasIndex(e => e.SerialNumber); + entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("varchar(255)"); - entity.HasIndex(e => e.SerialNumberVisible); + entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - entity.Property(e => e.SerialNumberVisible).HasDefaultValue(true); + entity.HasOne(d => d.Company) + .WithMany(p => p.Machines) + .HasForeignKey(d => d.CompanyId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("fk_machines_company"); - entity.HasOne(d => d.User).WithMany(p => p.OwnedMachines).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasOne(d => d.Family) + .WithMany(p => p.Machines) + .HasForeignKey(d => d.FamilyId) + .HasConstraintName("fk_machines_family"); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Aperture); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.AcquisitionDate); - entity.HasIndex(e => e.Author); + entity.HasIndex(e => e.LostDate); - entity.HasIndex(e => e.CameraManufacturer); + entity.HasIndex(e => e.Status); - entity.HasIndex(e => e.CameraModel); + entity.HasIndex(e => e.LastStatusDate); - entity.HasIndex(e => e.ColorSpace); + entity.HasIndex(e => e.Trade); - entity.HasIndex(e => e.Comments); + entity.HasIndex(e => e.Boxed); - entity.HasIndex(e => e.Contrast); + entity.HasIndex(e => e.Manuals); - entity.HasIndex(e => e.CreationDate); + entity.HasIndex(e => e.SerialNumber); - entity.HasIndex(e => e.DigitalZoomRatio); + entity.HasIndex(e => e.SerialNumberVisible); - entity.HasIndex(e => e.ExifVersion); + entity.Property(e => e.SerialNumberVisible).HasDefaultValue(true); - entity.HasIndex(e => e.ExposureTime); + entity.HasOne(d => d.User).WithMany(p => p.OwnedMachines).OnDelete(DeleteBehavior.Cascade); + }); - entity.HasIndex(e => e.ExposureMethod); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Aperture); - entity.HasIndex(e => e.ExposureProgram); + entity.HasIndex(e => e.Author); - entity.HasIndex(e => e.Flash); + entity.HasIndex(e => e.CameraManufacturer); - entity.HasIndex(e => e.Focal); + entity.HasIndex(e => e.CameraModel); - entity.HasIndex(e => e.FocalLength); + entity.HasIndex(e => e.ColorSpace); - entity.HasIndex(e => e.FocalLengthEquivalent); + entity.HasIndex(e => e.Comments); - entity.HasIndex(e => e.HorizontalResolution); + entity.HasIndex(e => e.Contrast); - entity.HasIndex(e => e.IsoRating); + entity.HasIndex(e => e.CreationDate); - entity.HasIndex(e => e.Lens); + entity.HasIndex(e => e.DigitalZoomRatio); - entity.HasIndex(e => e.LightSource); + entity.HasIndex(e => e.ExifVersion); - entity.HasIndex(e => e.MeteringMode); + entity.HasIndex(e => e.ExposureTime); - entity.HasIndex(e => e.ResolutionUnit); + entity.HasIndex(e => e.ExposureMethod); - entity.HasIndex(e => e.Orientation); + entity.HasIndex(e => e.ExposureProgram); - entity.HasIndex(e => e.Saturation); + entity.HasIndex(e => e.Flash); - entity.HasIndex(e => e.SceneCaptureType); + entity.HasIndex(e => e.Focal); - entity.HasIndex(e => e.SensingMethod); + entity.HasIndex(e => e.FocalLength); - entity.HasIndex(e => e.Sharpness); + entity.HasIndex(e => e.FocalLengthEquivalent); - entity.HasIndex(e => e.SoftwareUsed); + entity.HasIndex(e => e.HorizontalResolution); - entity.HasIndex(e => e.SubjectDistanceRange); + entity.HasIndex(e => e.IsoRating); - entity.HasIndex(e => e.UploadDate); + entity.HasIndex(e => e.Lens); - entity.HasIndex(e => e.VerticalResolution); + entity.HasIndex(e => e.LightSource); - entity.HasIndex(e => e.WhiteBalance); + entity.HasIndex(e => e.MeteringMode); - entity.HasOne(d => d.Machine).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade); + entity.HasIndex(e => e.ResolutionUnit); - entity.HasOne(d => d.User).WithMany(p => p.Photos).OnDelete(DeleteBehavior.SetNull); + entity.HasIndex(e => e.Orientation); - entity.HasOne(d => d.License).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.Saturation); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Aperture); + entity.HasIndex(e => e.SceneCaptureType); - entity.HasIndex(e => e.Author); + entity.HasIndex(e => e.SensingMethod); - entity.HasIndex(e => e.CameraManufacturer); + entity.HasIndex(e => e.Sharpness); - entity.HasIndex(e => e.CameraModel); + entity.HasIndex(e => e.SoftwareUsed); - entity.HasIndex(e => e.ColorSpace); + entity.HasIndex(e => e.SubjectDistanceRange); - entity.HasIndex(e => e.Comments); + entity.HasIndex(e => e.UploadDate); - entity.HasIndex(e => e.Contrast); + entity.HasIndex(e => e.VerticalResolution); - entity.HasIndex(e => e.CreationDate); + entity.HasIndex(e => e.WhiteBalance); - entity.HasIndex(e => e.DigitalZoomRatio); + entity.HasOne(d => d.Machine).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade); - entity.HasIndex(e => e.ExifVersion); + entity.HasOne(d => d.User).WithMany(p => p.Photos).OnDelete(DeleteBehavior.SetNull); - entity.HasIndex(e => e.ExposureTime); + entity.HasOne(d => d.License).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade); + }); - entity.HasIndex(e => e.ExposureMethod); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Aperture); - entity.HasIndex(e => e.ExposureProgram); + entity.HasIndex(e => e.Author); - entity.HasIndex(e => e.Flash); + entity.HasIndex(e => e.CameraManufacturer); - entity.HasIndex(e => e.Focal); + entity.HasIndex(e => e.CameraModel); - entity.HasIndex(e => e.FocalLength); + entity.HasIndex(e => e.ColorSpace); - entity.HasIndex(e => e.FocalLengthEquivalent); + entity.HasIndex(e => e.Comments); - entity.HasIndex(e => e.HorizontalResolution); + entity.HasIndex(e => e.Contrast); - entity.HasIndex(e => e.IsoRating); + entity.HasIndex(e => e.CreationDate); - entity.HasIndex(e => e.Lens); + entity.HasIndex(e => e.DigitalZoomRatio); - entity.HasIndex(e => e.LightSource); + entity.HasIndex(e => e.ExifVersion); - entity.HasIndex(e => e.MeteringMode); + entity.HasIndex(e => e.ExposureTime); - entity.HasIndex(e => e.ResolutionUnit); + entity.HasIndex(e => e.ExposureMethod); - entity.HasIndex(e => e.Orientation); + entity.HasIndex(e => e.ExposureProgram); - entity.HasIndex(e => e.Saturation); + entity.HasIndex(e => e.Flash); - entity.HasIndex(e => e.SceneCaptureType); + entity.HasIndex(e => e.Focal); - entity.HasIndex(e => e.SensingMethod); + entity.HasIndex(e => e.FocalLength); - entity.HasIndex(e => e.Sharpness); + entity.HasIndex(e => e.FocalLengthEquivalent); - entity.HasIndex(e => e.SoftwareUsed); + entity.HasIndex(e => e.HorizontalResolution); - entity.HasIndex(e => e.SubjectDistanceRange); + entity.HasIndex(e => e.IsoRating); - entity.HasIndex(e => e.UploadDate); + entity.HasIndex(e => e.Lens); - entity.HasIndex(e => e.VerticalResolution); + entity.HasIndex(e => e.LightSource); - entity.HasIndex(e => e.WhiteBalance); + entity.HasIndex(e => e.MeteringMode); - entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade); + entity.HasIndex(e => e.ResolutionUnit); - entity.HasOne(d => d.User).WithMany(p => p.OwnedMachinePhotos).OnDelete(DeleteBehavior.Cascade); + entity.HasIndex(e => e.Orientation); - entity.HasOne(d => d.License).WithMany(p => p.OwnedMachinePhotos).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.Saturation); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Title); + entity.HasIndex(e => e.SceneCaptureType); - entity.HasIndex(e => e.NativeTitle); + entity.HasIndex(e => e.SensingMethod); - entity.HasIndex(e => e.Published); + entity.HasIndex(e => e.Sharpness); - entity.HasIndex(e => e.CountryId); + entity.HasIndex(e => e.SoftwareUsed); - entity.HasIndex(e => e.Synopsis).IsFullText(); + entity.HasIndex(e => e.SubjectDistanceRange); - entity.HasIndex(e => e.Issn); + entity.HasIndex(e => e.UploadDate); - entity.HasIndex(e => e.FirstPublication); + entity.HasIndex(e => e.VerticalResolution); - entity.HasOne(d => d.Country).WithMany(p => p.Magazines).HasForeignKey(d => d.CountryId); - }); + entity.HasIndex(e => e.WhiteBalance); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Caption); + entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Photos).OnDelete(DeleteBehavior.Cascade); - entity.HasIndex(e => e.NativeCaption); + entity.HasOne(d => d.User).WithMany(p => p.OwnedMachinePhotos).OnDelete(DeleteBehavior.Cascade); - entity.HasIndex(e => e.Published); + entity.HasOne(d => d.License).WithMany(p => p.OwnedMachinePhotos).OnDelete(DeleteBehavior.Cascade); + }); - entity.HasIndex(e => e.ProductCode); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Title); - entity.HasIndex(e => e.Pages); + entity.HasIndex(e => e.NativeTitle); - entity.HasOne(d => d.Magazine).WithMany(p => p.Issues).HasForeignKey(d => d.MagazineId); - }); + entity.HasIndex(e => e.Published); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.MagazineId); + entity.HasIndex(e => e.CountryId); - entity.HasIndex(e => e.MachineId); + entity.HasIndex(e => e.Synopsis).IsFullText(); - entity.HasOne(d => d.Magazine).WithMany(p => p.Machines).HasForeignKey(d => d.MagazineId); + entity.HasIndex(e => e.Issn); - entity.HasOne(d => d.Machine).WithMany(p => p.Magazines).HasForeignKey(d => d.MachineId); - }); - - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.MagazineId); - - entity.HasIndex(e => e.MachineFamilyId); + entity.HasIndex(e => e.FirstPublication); - entity.HasOne(d => d.Magazine).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.MagazineId); - - entity.HasOne(d => d.MachineFamily).WithMany(p => p.Magazines).HasForeignKey(d => d.MachineFamilyId); - }); - - modelBuilder.Entity(entity => - { - entity.ToTable("memory_by_machine"); + entity.HasOne(d => d.Country).WithMany(p => p.Magazines).HasForeignKey(d => d.CountryId); + }); - entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_memory_by_machine_machine"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Caption); - entity.HasIndex(e => e.Size).HasDatabaseName("idx_memory_by_machine_size"); + entity.HasIndex(e => e.NativeCaption); - entity.HasIndex(e => e.Speed).HasDatabaseName("idx_memory_by_machine_speed"); + entity.HasIndex(e => e.Published); - entity.HasIndex(e => e.Type).HasDatabaseName("idx_memory_by_machine_type"); + entity.HasIndex(e => e.ProductCode); - entity.HasIndex(e => e.Usage).HasDatabaseName("idx_memory_by_machine_usage"); + entity.HasIndex(e => e.Pages); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); + entity.HasOne(d => d.Magazine).WithMany(p => p.Issues).HasForeignKey(d => d.MagazineId); + }); - entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); - - entity.Property(e => e.Size).HasColumnName("size").HasColumnType("bigint(20)"); - - entity.Property(e => e.Speed).HasColumnName("speed"); - - entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - - entity.Property(e => e.Usage).HasColumnName("usage").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - - entity.HasOne(d => d.Machine).WithMany(p => p.Memory).HasForeignKey(d => d.MachineId). - HasConstraintName("fk_memory_by_machine_machine"); - }); - - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.OwnedMachineId); - - entity.HasIndex(e => e.Size); - - entity.HasIndex(e => e.Speed); - - entity.HasIndex(e => e.Type); - - entity.HasIndex(e => e.Usage); - - entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Memory).HasForeignKey(d => d.OwnedMachineId); - }); - - modelBuilder.Entity(entity => - { - entity.ToTable("money_donations"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.MagazineId); - entity.HasIndex(e => e.Donator).HasDatabaseName("idx_money_donations_donator"); - - entity.HasIndex(e => e.Quantity).HasDatabaseName("idx_money_donations_quantity"); - - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - - entity.Property(e => e.Donator).IsRequired().HasColumnName("donator").HasColumnType("char(128)"). - HasDefaultValueSql("''"); - - entity.Property(e => e.Quantity).HasColumnName("quantity").HasColumnType("decimal(11,2)"). - HasDefaultValueSql("'0.00'"); - }); - - modelBuilder.Entity(entity => - { - entity.ToTable("news"); - - entity.HasIndex(e => e.AddedId).HasDatabaseName("idx_news_ip"); - - entity.HasIndex(e => e.Date).HasDatabaseName("idx_news_date"); - - entity.HasIndex(e => e.Type).HasDatabaseName("idx_news_type"); - - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - - entity.Property(e => e.AddedId).HasColumnName("added_id").HasColumnType("int(11)"). - HasDefaultValueSql("'0'"); - - entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("datetime"); - - entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - }); - - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.PersonId); - - entity.HasIndex(e => e.BookId); - - entity.HasOne(d => d.Person).WithMany(p => p.Books).HasForeignKey(d => d.PersonId); - - entity.HasOne(d => d.Book).WithMany(p => p.People).HasForeignKey(d => d.BookId); - }); - - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.PersonId); - - entity.HasIndex(e => e.CompanyId); - - entity.HasIndex(e => e.Position); - - entity.HasIndex(e => e.Start); - - entity.HasIndex(e => e.End); - - entity.HasOne(d => d.Person).WithMany(p => p.Companies).HasForeignKey(d => d.PersonId); - - entity.HasOne(d => d.Company).WithMany(p => p.People).HasForeignKey(d => d.CompanyId); - }); - - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.PersonId); + entity.HasIndex(e => e.MachineId); - entity.HasIndex(e => e.DocumentId); + entity.HasOne(d => d.Magazine).WithMany(p => p.Machines).HasForeignKey(d => d.MagazineId); - entity.HasOne(d => d.Person).WithMany(p => p.Documents).HasForeignKey(d => d.PersonId); + entity.HasOne(d => d.Machine).WithMany(p => p.Magazines).HasForeignKey(d => d.MachineId); + }); - entity.HasOne(d => d.Document).WithMany(p => p.People).HasForeignKey(d => d.DocumentId); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.MagazineId); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.PersonId); + entity.HasIndex(e => e.MachineFamilyId); - entity.HasIndex(e => e.MagazineId); + entity.HasOne(d => d.Magazine).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.MagazineId); - entity.HasOne(d => d.Person).WithMany(p => p.Magazines).HasForeignKey(d => d.PersonId); + entity.HasOne(d => d.MachineFamily).WithMany(p => p.Magazines).HasForeignKey(d => d.MachineFamilyId); + }); - entity.HasOne(d => d.Magazine).WithMany(p => p.People).HasForeignKey(d => d.MagazineId); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("memory_by_machine"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Name); + entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_memory_by_machine_machine"); - entity.HasIndex(e => e.Surname); + entity.HasIndex(e => e.Size).HasDatabaseName("idx_memory_by_machine_size"); - entity.HasIndex(e => e.CountryOfBirthId); + entity.HasIndex(e => e.Speed).HasDatabaseName("idx_memory_by_machine_speed"); - entity.HasIndex(e => e.BirthDate); + entity.HasIndex(e => e.Type).HasDatabaseName("idx_memory_by_machine_type"); - entity.HasIndex(e => e.DeathDate); + entity.HasIndex(e => e.Usage).HasDatabaseName("idx_memory_by_machine_usage"); - entity.HasIndex(e => e.Webpage); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); - entity.HasIndex(e => e.Twitter); + entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); - entity.HasIndex(e => e.Facebook); + entity.Property(e => e.Size).HasColumnName("size").HasColumnType("bigint(20)"); - entity.HasIndex(e => e.Photo); + entity.Property(e => e.Speed).HasColumnName("speed"); - entity.HasIndex(e => e.Alias); + entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - entity.HasIndex(e => e.DisplayName); + entity.Property(e => e.Usage).HasColumnName("usage").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - entity.HasOne(d => d.CountryOfBirth).WithMany(p => p.People).HasForeignKey(d => d.CountryOfBirthId); + entity.HasOne(d => d.Machine) + .WithMany(p => p.Memory) + .HasForeignKey(d => d.MachineId) + .HasConstraintName("fk_memory_by_machine_machine"); + }); - entity.HasOne(d => d.DocumentPerson).WithOne(p => p.Person). - HasForeignKey(d => d.PersonId).OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.OwnedMachineId); - modelBuilder.Entity(entity => - { - entity.ToTable("processors"); + entity.HasIndex(e => e.Size); - entity.HasIndex(e => e.AddrBus).HasDatabaseName("idx_processors_addr_bus"); + entity.HasIndex(e => e.Speed); - entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_processors_company"); + entity.HasIndex(e => e.Type); - entity.HasIndex(e => e.Cores).HasDatabaseName("idx_processors_cores"); + entity.HasIndex(e => e.Usage); - entity.HasIndex(e => e.DataBus).HasDatabaseName("idx_processors_data_bus"); + entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Memory).HasForeignKey(d => d.OwnedMachineId); + }); - entity.HasIndex(e => e.DieSize).HasDatabaseName("idx_processors_die_size"); + modelBuilder.Entity(entity => + { + entity.ToTable("money_donations"); - entity.HasIndex(e => e.FprSize).HasDatabaseName("idx_processors_FPR_size"); + entity.HasIndex(e => e.Donator).HasDatabaseName("idx_money_donations_donator"); - entity.HasIndex(e => e.Fprs).HasDatabaseName("idx_processors_FPRs"); + entity.HasIndex(e => e.Quantity).HasDatabaseName("idx_money_donations_quantity"); - entity.HasIndex(e => e.GprSize).HasDatabaseName("idx_processors_GPR_size"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.HasIndex(e => e.Gprs).HasDatabaseName("idx_processors_GPRs"); + entity.Property(e => e.Donator) + .IsRequired() + .HasColumnName("donator") + .HasColumnType("char(128)") + .HasDefaultValueSql("''"); - entity.HasIndex(e => e.InstructionSetId).HasDatabaseName("idx_processors_instruction_set"); + entity.Property(e => e.Quantity) + .HasColumnName("quantity") + .HasColumnType("decimal(11,2)") + .HasDefaultValueSql("'0.00'"); + }); - entity.HasIndex(e => e.Introduced).HasDatabaseName("idx_processors_introduced"); + modelBuilder.Entity(entity => + { + entity.ToTable("news"); - entity.HasIndex(e => e.L1Data).HasDatabaseName("idx_processors_L1_data"); + entity.HasIndex(e => e.AddedId).HasDatabaseName("idx_news_ip"); - entity.HasIndex(e => e.L1Instruction).HasDatabaseName("idx_processors_L1_instruction"); + entity.HasIndex(e => e.Date).HasDatabaseName("idx_news_date"); - entity.HasIndex(e => e.L2).HasDatabaseName("idx_processors_L2"); + entity.HasIndex(e => e.Type).HasDatabaseName("idx_news_type"); - entity.HasIndex(e => e.L3).HasDatabaseName("idx_processors_L3"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.HasIndex(e => e.ModelCode).HasDatabaseName("idx_processors_model_code"); + entity.Property(e => e.AddedId) + .HasColumnName("added_id") + .HasColumnType("int(11)") + .HasDefaultValueSql("'0'"); - entity.HasIndex(e => e.Name).HasDatabaseName("idx_processors_name"); + entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("datetime"); - entity.HasIndex(e => e.Package).HasDatabaseName("idx_processors_package"); + entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'"); + }); - entity.HasIndex(e => e.Process).HasDatabaseName("idx_processors_process"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.PersonId); - entity.HasIndex(e => e.ProcessNm).HasDatabaseName("idx_processors_process_nm"); + entity.HasIndex(e => e.BookId); - entity.HasIndex(e => e.SimdRegisters).HasDatabaseName("idx_processors_SIMD_registers"); + entity.HasOne(d => d.Person).WithMany(p => p.Books).HasForeignKey(d => d.PersonId); - entity.HasIndex(e => e.SimdSize).HasDatabaseName("idx_processors_SIMD_size"); + entity.HasOne(d => d.Book).WithMany(p => p.People).HasForeignKey(d => d.BookId); + }); - entity.HasIndex(e => e.Speed).HasDatabaseName("idx_processors_speed"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.PersonId); - entity.HasIndex(e => e.ThreadsPerCore).HasDatabaseName("idx_processors_threads_per_core"); + entity.HasIndex(e => e.CompanyId); - entity.HasIndex(e => e.Transistors).HasDatabaseName("idx_processors_transistors"); + entity.HasIndex(e => e.Position); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.HasIndex(e => e.Start); - entity.Property(e => e.AddrBus).HasColumnName("addr_bus").HasColumnType("int(11)"); + entity.HasIndex(e => e.End); - entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"); + entity.HasOne(d => d.Person).WithMany(p => p.Companies).HasForeignKey(d => d.PersonId); - entity.Property(e => e.Cores).HasColumnName("cores").HasColumnType("int(11)"); + entity.HasOne(d => d.Company).WithMany(p => p.People).HasForeignKey(d => d.CompanyId); + }); - entity.Property(e => e.DataBus).HasColumnName("data_bus").HasColumnType("int(11)"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.PersonId); - entity.Property(e => e.DieSize).HasColumnName("die_size"); + entity.HasIndex(e => e.DocumentId); - entity.Property(e => e.FprSize).HasColumnName("FPR_size").HasColumnType("int(11)"); + entity.HasOne(d => d.Person).WithMany(p => p.Documents).HasForeignKey(d => d.PersonId); - entity.Property(e => e.Fprs).HasColumnName("FPRs").HasColumnType("int(11)"); + entity.HasOne(d => d.Document).WithMany(p => p.People).HasForeignKey(d => d.DocumentId); + }); - entity.Property(e => e.GprSize).HasColumnName("GPR_size").HasColumnType("int(11)"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.PersonId); - entity.Property(e => e.Gprs).HasColumnName("GPRs").HasColumnType("int(11)"); + entity.HasIndex(e => e.MagazineId); - entity.Property(e => e.InstructionSetId).HasColumnName("instruction_set").HasColumnType("int(11)"); + entity.HasOne(d => d.Person).WithMany(p => p.Magazines).HasForeignKey(d => d.PersonId); - entity.Property(e => e.Introduced).HasColumnName("introduced").HasColumnType("datetime"); + entity.HasOne(d => d.Magazine).WithMany(p => p.People).HasForeignKey(d => d.MagazineId); + }); - entity.Property(e => e.L1Data).HasColumnName("L1_data"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Name); - entity.Property(e => e.L1Instruction).HasColumnName("L1_instruction"); + entity.HasIndex(e => e.Surname); - entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)"); + entity.HasIndex(e => e.CountryOfBirthId); - entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(50)"). - HasDefaultValueSql("''"); + entity.HasIndex(e => e.BirthDate); - entity.Property(e => e.Package).HasColumnName("package").HasColumnType("varchar(45)"); + entity.HasIndex(e => e.DeathDate); - entity.Property(e => e.Process).HasColumnName("process").HasColumnType("varchar(45)"); + entity.HasIndex(e => e.Webpage); - entity.Property(e => e.ProcessNm).HasColumnName("process_nm"); + entity.HasIndex(e => e.Twitter); - entity.Property(e => e.SimdRegisters).HasColumnName("SIMD_registers").HasColumnType("int(11)"); + entity.HasIndex(e => e.Facebook); - entity.Property(e => e.SimdSize).HasColumnName("SIMD_size").HasColumnType("int(11)"); + entity.HasIndex(e => e.Photo); - entity.Property(e => e.Speed).HasColumnName("speed"); + entity.HasIndex(e => e.Alias); - entity.Property(e => e.ThreadsPerCore).HasColumnName("threads_per_core").HasColumnType("int(11)"); + entity.HasIndex(e => e.DisplayName); - entity.Property(e => e.Transistors).HasColumnName("transistors").HasColumnType("bigint(20)"); + entity.HasOne(d => d.CountryOfBirth).WithMany(p => p.People).HasForeignKey(d => d.CountryOfBirthId); - entity.HasOne(d => d.Company).WithMany(p => p.Processors).HasForeignKey(d => d.CompanyId). - HasConstraintName("fk_processors_company"); + entity.HasOne(d => d.DocumentPerson) + .WithOne(p => p.Person) + .HasForeignKey(d => d.PersonId) + .OnDelete(DeleteBehavior.SetNull); + }); - entity.HasOne(d => d.InstructionSet).WithMany(p => p.Processors).HasForeignKey(d => d.InstructionSetId). - HasConstraintName("fk_processors_instruction_set"); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("processors"); - modelBuilder.Entity(entity => - { - entity.ToTable("processors_by_machine"); + entity.HasIndex(e => e.AddrBus).HasDatabaseName("idx_processors_addr_bus"); - entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_processors_by_machine_machine"); + entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_processors_company"); - entity.HasIndex(e => e.ProcessorId).HasDatabaseName("idx_processors_by_machine_processor"); + entity.HasIndex(e => e.Cores).HasDatabaseName("idx_processors_cores"); - entity.HasIndex(e => e.Speed).HasDatabaseName("idx_processors_by_machine_speed"); + entity.HasIndex(e => e.DataBus).HasDatabaseName("idx_processors_data_bus"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); + entity.HasIndex(e => e.DieSize).HasDatabaseName("idx_processors_die_size"); - entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); + entity.HasIndex(e => e.FprSize).HasDatabaseName("idx_processors_FPR_size"); - entity.Property(e => e.ProcessorId).HasColumnName("processor").HasColumnType("int(11)"); + entity.HasIndex(e => e.Fprs).HasDatabaseName("idx_processors_FPRs"); - entity.Property(e => e.Speed).HasColumnName("speed"); + entity.HasIndex(e => e.GprSize).HasDatabaseName("idx_processors_GPR_size"); - entity.HasOne(d => d.Machine).WithMany(p => p.Processors).HasForeignKey(d => d.MachineId). - HasConstraintName("fk_processors_by_machine_machine"); + entity.HasIndex(e => e.Gprs).HasDatabaseName("idx_processors_GPRs"); - entity.HasOne(d => d.Processor).WithMany(p => p.ProcessorsByMachine).HasForeignKey(d => d.ProcessorId). - HasConstraintName("fk_processors_by_machine_processor"); - }); + entity.HasIndex(e => e.InstructionSetId).HasDatabaseName("idx_processors_instruction_set"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.OwnedMachineId); + entity.HasIndex(e => e.Introduced).HasDatabaseName("idx_processors_introduced"); - entity.HasIndex(e => e.ProcessorId); + entity.HasIndex(e => e.L1Data).HasDatabaseName("idx_processors_L1_data"); - entity.HasIndex(e => e.Speed); + entity.HasIndex(e => e.L1Instruction).HasDatabaseName("idx_processors_L1_instruction"); - entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Processors).HasForeignKey(d => d.OwnedMachineId); - }); + entity.HasIndex(e => e.L2).HasDatabaseName("idx_processors_L2"); - modelBuilder.Entity(entity => - { - entity.ToTable("resolutions"); + entity.HasIndex(e => e.L3).HasDatabaseName("idx_processors_L3"); - entity.HasIndex(e => e.Colors).HasDatabaseName("idx_resolutions_colors"); + entity.HasIndex(e => e.ModelCode).HasDatabaseName("idx_processors_model_code"); - entity.HasIndex(e => e.Height).HasDatabaseName("idx_resolutions_height"); + entity.HasIndex(e => e.Name).HasDatabaseName("idx_processors_name"); - entity.HasIndex(e => e.Palette).HasDatabaseName("idx_resolutions_palette"); + entity.HasIndex(e => e.Package).HasDatabaseName("idx_processors_package"); - entity.HasIndex(e => e.Width).HasDatabaseName("idx_resolutions_width"); + entity.HasIndex(e => e.Process).HasDatabaseName("idx_processors_process"); - entity.HasIndex(e => new - { - e.Width, - e.Height - }).HasDatabaseName("idx_resolutions_resolution"); + entity.HasIndex(e => e.ProcessNm).HasDatabaseName("idx_processors_process_nm"); - entity.HasIndex(e => new - { - e.Width, - e.Height, - e.Colors - }).HasDatabaseName("idx_resolutions_resolution_with_color"); + entity.HasIndex(e => e.SimdRegisters).HasDatabaseName("idx_processors_SIMD_registers"); - entity.HasIndex(e => new - { - e.Width, - e.Height, - e.Colors, - e.Palette - }).HasDatabaseName("idx_resolutions_resolution_with_color_and_palette"); + entity.HasIndex(e => e.SimdSize).HasDatabaseName("idx_processors_SIMD_size"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.HasIndex(e => e.Speed).HasDatabaseName("idx_processors_speed"); - entity.Property(e => e.Chars).HasColumnName("chars").HasColumnType("tinyint(1)"). - HasDefaultValueSql("'0'"); + entity.HasIndex(e => e.ThreadsPerCore).HasDatabaseName("idx_processors_threads_per_core"); - entity.Property(e => e.Colors).HasColumnName("colors").HasColumnType("bigint(20)"); + entity.HasIndex(e => e.Transistors).HasDatabaseName("idx_processors_transistors"); - entity.Property(e => e.Height).HasColumnName("height").HasColumnType("int(11)"). - HasDefaultValueSql("'0'"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.Property(e => e.Palette).HasColumnName("palette").HasColumnType("bigint(20)"); + entity.Property(e => e.AddrBus).HasColumnName("addr_bus").HasColumnType("int(11)"); - entity.Property(e => e.Width).HasColumnName("width").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - }); + entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.ToTable("resolutions_by_gpu"); + entity.Property(e => e.Cores).HasColumnName("cores").HasColumnType("int(11)"); - entity.HasIndex(e => e.GpuId).HasDatabaseName("idx_resolutions_by_gpu_gpu"); + entity.Property(e => e.DataBus).HasColumnName("data_bus").HasColumnType("int(11)"); - entity.HasIndex(e => e.ResolutionId).HasDatabaseName("idx_resolutions_by_gpu_resolution"); + entity.Property(e => e.DieSize).HasColumnName("die_size"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); + entity.Property(e => e.FprSize).HasColumnName("FPR_size").HasColumnType("int(11)"); - entity.Property(e => e.GpuId).HasColumnName("gpu").HasColumnType("int(11)"); + entity.Property(e => e.Fprs).HasColumnName("FPRs").HasColumnType("int(11)"); - entity.Property(e => e.ResolutionId).HasColumnName("resolution").HasColumnType("int(11)"); + entity.Property(e => e.GprSize).HasColumnName("GPR_size").HasColumnType("int(11)"); - entity.HasOne(d => d.Gpu).WithMany(p => p.ResolutionsByGpu).HasForeignKey(d => d.GpuId). - HasConstraintName("fk_resolutions_by_gpu_gpu"); + entity.Property(e => e.Gprs).HasColumnName("GPRs").HasColumnType("int(11)"); - entity.HasOne(d => d.Resolution).WithMany(p => p.ResolutionsByGpu).HasForeignKey(d => d.ResolutionId). - HasConstraintName("fk_resolutions_by_gpu_resolution"); - }); + entity.Property(e => e.InstructionSetId).HasColumnName("instruction_set").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.ScreenId); + entity.Property(e => e.Introduced).HasColumnName("introduced").HasColumnType("datetime"); - entity.HasIndex(e => e.ResolutionId); - }); + entity.Property(e => e.L1Data).HasColumnName("L1_data"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.ScreenId); + entity.Property(e => e.L1Instruction).HasColumnName("L1_instruction"); - entity.HasIndex(e => e.MachineId); - }); + entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Width); + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("char(50)") + .HasDefaultValueSql("''"); - entity.HasIndex(e => e.Height); + entity.Property(e => e.Package).HasColumnName("package").HasColumnType("varchar(45)"); - entity.HasIndex(e => e.Diagonal); + entity.Property(e => e.Process).HasColumnName("process").HasColumnType("varchar(45)"); - entity.HasIndex(e => e.EffectiveColors); + entity.Property(e => e.ProcessNm).HasColumnName("process_nm"); - entity.HasIndex(e => e.Type); + entity.Property(e => e.SimdRegisters).HasColumnName("SIMD_registers").HasColumnType("int(11)"); - entity.HasOne(d => d.NativeResolution).WithMany(p => p.Screens); - }); + entity.Property(e => e.SimdSize).HasColumnName("SIMD_size").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.ToTable("sound_by_machine"); + entity.Property(e => e.Speed).HasColumnName("speed"); - entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_sound_by_machine_machine"); + entity.Property(e => e.ThreadsPerCore).HasColumnName("threads_per_core").HasColumnType("int(11)"); - entity.HasIndex(e => e.SoundSynthId).HasDatabaseName("idx_sound_by_machine_sound_synth"); + entity.Property(e => e.Transistors).HasColumnName("transistors").HasColumnType("bigint(20)"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); + entity.HasOne(d => d.Company) + .WithMany(p => p.Processors) + .HasForeignKey(d => d.CompanyId) + .HasConstraintName("fk_processors_company"); - entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); + entity.HasOne(d => d.InstructionSet) + .WithMany(p => p.Processors) + .HasForeignKey(d => d.InstructionSetId) + .HasConstraintName("fk_processors_instruction_set"); + }); - entity.Property(e => e.SoundSynthId).HasColumnName("sound_synth").HasColumnType("int(11)"); + modelBuilder.Entity(entity => + { + entity.ToTable("processors_by_machine"); - entity.HasOne(d => d.Machine).WithMany(p => p.Sound).HasForeignKey(d => d.MachineId). - HasConstraintName("fk_sound_by_machine_machine"); + entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_processors_by_machine_machine"); - entity.HasOne(d => d.SoundSynth).WithMany(p => p.SoundByMachine).HasForeignKey(d => d.SoundSynthId). - HasConstraintName("fk_sound_by_machine_sound_synth"); - }); + entity.HasIndex(e => e.ProcessorId).HasDatabaseName("idx_processors_by_machine_processor"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.OwnedMachineId); + entity.HasIndex(e => e.Speed).HasDatabaseName("idx_processors_by_machine_speed"); - entity.HasIndex(e => e.SoundSynthId); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); - entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Sound).HasForeignKey(d => d.OwnedMachineId); - }); + entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.ToTable("sound_synths"); + entity.Property(e => e.ProcessorId).HasColumnName("processor").HasColumnType("int(11)"); - entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_sound_synths_company"); + entity.Property(e => e.Speed).HasColumnName("speed"); - entity.HasIndex(e => e.Depth).HasDatabaseName("idx_sound_synths_depth"); + entity.HasOne(d => d.Machine) + .WithMany(p => p.Processors) + .HasForeignKey(d => d.MachineId) + .HasConstraintName("fk_processors_by_machine_machine"); - entity.HasIndex(e => e.Frequency).HasDatabaseName("idx_sound_synths_frequency"); + entity.HasOne(d => d.Processor) + .WithMany(p => p.ProcessorsByMachine) + .HasForeignKey(d => d.ProcessorId) + .HasConstraintName("fk_processors_by_machine_processor"); + }); - entity.HasIndex(e => e.Introduced).HasDatabaseName("idx_sound_synths_introduced"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.OwnedMachineId); - entity.HasIndex(e => e.ModelCode).HasDatabaseName("idx_sound_synths_model_code"); + entity.HasIndex(e => e.ProcessorId); - entity.HasIndex(e => e.Name).HasDatabaseName("idx_sound_synths_name"); + entity.HasIndex(e => e.Speed); - entity.HasIndex(e => e.SquareWave).HasDatabaseName("idx_sound_synths_square_wave"); + entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Processors).HasForeignKey(d => d.OwnedMachineId); + }); - entity.HasIndex(e => e.Type).HasDatabaseName("idx_sound_synths_type"); + modelBuilder.Entity(entity => + { + entity.ToTable("resolutions"); - entity.HasIndex(e => e.Voices).HasDatabaseName("idx_sound_synths_voices"); + entity.HasIndex(e => e.Colors).HasDatabaseName("idx_resolutions_colors"); - entity.HasIndex(e => e.WhiteNoise).HasDatabaseName("idx_sound_synths_white_noise"); + entity.HasIndex(e => e.Height).HasDatabaseName("idx_resolutions_height"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); + entity.HasIndex(e => e.Palette).HasDatabaseName("idx_resolutions_palette"); - entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"); + entity.HasIndex(e => e.Width).HasDatabaseName("idx_resolutions_width"); - entity.Property(e => e.Depth).HasColumnName("depth").HasColumnType("int(11)"); + entity.HasIndex(e => new + { + e.Width, + e.Height + }) + .HasDatabaseName("idx_resolutions_resolution"); - entity.Property(e => e.Frequency).HasColumnName("frequency"); + entity.HasIndex(e => new + { + e.Width, + e.Height, + e.Colors + }) + .HasDatabaseName("idx_resolutions_resolution_with_color"); - entity.Property(e => e.Introduced).HasColumnName("introduced").HasColumnType("datetime"); + entity.HasIndex(e => new + { + e.Width, + e.Height, + e.Colors, + e.Palette + }) + .HasDatabaseName("idx_resolutions_resolution_with_color_and_palette"); - entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(50)"). - HasDefaultValueSql("''"); + entity.Property(e => e.Chars).HasColumnName("chars").HasColumnType("tinyint(1)").HasDefaultValueSql("'0'"); - entity.Property(e => e.SquareWave).HasColumnName("square_wave").HasColumnType("int(11)"); + entity.Property(e => e.Colors).HasColumnName("colors").HasColumnType("bigint(20)"); - entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)"); + entity.Property(e => e.Height).HasColumnName("height").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - entity.Property(e => e.Voices).HasColumnName("voices").HasColumnType("int(11)"); + entity.Property(e => e.Palette).HasColumnName("palette").HasColumnType("bigint(20)"); - entity.Property(e => e.WhiteNoise).HasColumnName("white_noise").HasColumnType("int(11)"); + entity.Property(e => e.Width).HasColumnName("width").HasColumnType("int(11)").HasDefaultValueSql("'0'"); + }); - entity.HasOne(d => d.Company).WithMany(p => p.SoundSynths).HasForeignKey(d => d.CompanyId). - HasConstraintName("fk_sound_synths_company"); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("resolutions_by_gpu"); - modelBuilder.Entity(entity => - { - entity.ToTable("storage_by_machine"); + entity.HasIndex(e => e.GpuId).HasDatabaseName("idx_resolutions_by_gpu_gpu"); - entity.HasIndex(e => e.Capacity).HasDatabaseName("idx_storage_capacity"); + entity.HasIndex(e => e.ResolutionId).HasDatabaseName("idx_resolutions_by_gpu_resolution"); - entity.HasIndex(e => e.Interface).HasDatabaseName("idx_storage_interface"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); - entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_storage_machine"); + entity.Property(e => e.GpuId).HasColumnName("gpu").HasColumnType("int(11)"); - entity.HasIndex(e => e.Type).HasDatabaseName("idx_storage_type"); + entity.Property(e => e.ResolutionId).HasColumnName("resolution").HasColumnType("int(11)"); - entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); + entity.HasOne(d => d.Gpu) + .WithMany(p => p.ResolutionsByGpu) + .HasForeignKey(d => d.GpuId) + .HasConstraintName("fk_resolutions_by_gpu_gpu"); - entity.Property(e => e.Capacity).HasColumnName("capacity").HasColumnType("bigint(20)"); + entity.HasOne(d => d.Resolution) + .WithMany(p => p.ResolutionsByGpu) + .HasForeignKey(d => d.ResolutionId) + .HasConstraintName("fk_resolutions_by_gpu_resolution"); + }); - entity.Property(e => e.Interface).HasColumnName("interface").HasColumnType("int(11)"). - HasDefaultValueSql("'0'"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.ScreenId); - entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); + entity.HasIndex(e => e.ResolutionId); + }); - entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'"); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.ScreenId); - entity.HasOne(d => d.Machine).WithMany(p => p.Storage).HasForeignKey(d => d.MachineId). - HasConstraintName("fk_storage_by_machine_machine"); - }); + entity.HasIndex(e => e.MachineId); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Capacity); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Width); - entity.HasIndex(e => e.Interface); + entity.HasIndex(e => e.Height); - entity.HasIndex(e => e.OwnedMachineId); + entity.HasIndex(e => e.Diagonal); - entity.HasIndex(e => e.Type); + entity.HasIndex(e => e.EffectiveColors); - entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Storage).HasForeignKey(d => d.OwnedMachineId); - }); + entity.HasIndex(e => e.Type); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Name); - entity.HasIndex(e => e.SPDX); - entity.HasIndex(e => e.FsfApproved); - entity.HasIndex(e => e.OsiApproved); - }); + entity.HasOne(d => d.NativeResolution).WithMany(p => p.Screens); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(d => d.Table); - entity.HasIndex(d => d.Type); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("sound_by_machine"); - modelBuilder.Entity(entity => - { - entity.HasIndex(d => d.Numeric); - entity.HasIndex(d => d.Withdrawn); - }); + entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_sound_by_machine_machine"); - modelBuilder.Entity(entity => - { - entity.HasIndex(d => d.Year); - }); + entity.HasIndex(e => e.SoundSynthId).HasDatabaseName("idx_sound_by_machine_sound_synth"); - modelBuilder.Entity(entity => - { - entity.HasIndex(d => d.Start); - entity.HasIndex(d => d.End); - }); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Manufacturer); - entity.HasIndex(e => e.Model); - entity.HasIndex(e => e.Revision); - entity.HasIndex(e => e.Firmware); - entity.HasIndex(e => e.Serial); - entity.HasIndex(e => e.SoftwareName); - entity.HasIndex(e => e.SoftwareVersion); - entity.HasIndex(e => e.SoftwareOperatingSystem); - - entity.HasOne(e => e.Dump).WithMany(e => e.DumpHardware).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.Property(e => e.Md5).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha1).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha256).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha3).HasConversion(hexToBytesConverter); - - entity.HasIndex(e => e.Size); - entity.HasIndex(e => e.Md5); - entity.HasIndex(e => e.Sha1); - entity.HasIndex(e => e.Sha256); - entity.HasIndex(e => e.Sha3); - entity.HasIndex(e => e.Spamsum); - entity.HasIndex(e => e.Mime); - entity.HasIndex(e => e.Magic); - entity.HasIndex(e => e.AccoustId); - entity.HasIndex(e => e.Infected); - entity.HasIndex(e => e.Malware); - entity.HasIndex(e => e.Hack); - entity.HasIndex(e => e.HackGroup); - }); + entity.Property(e => e.SoundSynthId).HasColumnName("sound_synth").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(d => d.Name); - entity.HasIndex(d => d.Size); - }); + entity.HasOne(d => d.Machine) + .WithMany(p => p.Sound) + .HasForeignKey(d => d.MachineId) + .HasConstraintName("fk_sound_by_machine_machine"); - modelBuilder.Entity(entity => - { - entity.HasIndex(d => d.Type); - entity.HasIndex(d => d.CreationDate); - entity.HasIndex(d => d.ModificationDate); - entity.HasIndex(d => d.BackupDate); - entity.HasIndex(d => d.Serial); - entity.HasIndex(d => d.Label); - entity.HasIndex(d => d.SystemIdentifier); - entity.HasIndex(d => d.VolumeSetIdentifier); - entity.HasIndex(d => d.PublisherIdentifier); - entity.HasIndex(d => d.DataPreparerIdentifier); - entity.HasIndex(d => d.ApplicationIdentifier); - }); + entity.HasOne(d => d.SoundSynth) + .WithMany(p => p.SoundByMachine) + .HasForeignKey(d => d.SoundSynthId) + .HasConstraintName("fk_sound_by_machine_sound_synth"); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Description); - entity.HasIndex(e => e.Name); - entity.HasIndex(e => e.Type); - entity.HasIndex(e => e.Scheme); - entity.HasIndex(e => e.FirstSector); - entity.HasIndex(e => e.LastSector); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.OwnedMachineId); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Partition).WithMany(p => p.Filesystems).OnDelete(DeleteBehavior.Cascade); + entity.HasIndex(e => e.SoundSynthId); - entity.HasOne(d => d.Filesystem).WithMany(p => p.Partitions).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Sound).HasForeignKey(d => d.OwnedMachineId); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Title); - entity.HasIndex(e => e.Type); - entity.HasIndex(e => e.CopyProtection); - entity.HasIndex(e => e.PartNumber); - entity.HasIndex(e => e.SerialNumber); - entity.HasIndex(e => e.Barcode); - entity.HasIndex(e => e.CatalogueNumber); - entity.HasIndex(e => e.Manufacturer); - entity.HasIndex(e => e.Model); - entity.HasIndex(e => e.Revision); - entity.HasIndex(e => e.Firmware); - - entity.HasOne(d => d.MagazineIssue).WithMany(p => p.Coverdiscs).OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("sound_synths"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Partition).WithMany(p => p.Media).OnDelete(DeleteBehavior.Cascade); + entity.HasIndex(e => e.CompanyId).HasDatabaseName("idx_sound_synths_company"); - entity.HasOne(d => d.Media).WithMany(p => p.LogicalPartitions).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.Depth).HasDatabaseName("idx_sound_synths_depth"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Media).WithMany(p => p.MediaDumps).OnDelete(DeleteBehavior.Cascade); + entity.HasIndex(e => e.Frequency).HasDatabaseName("idx_sound_synths_frequency"); - entity.HasIndex(e => e.Status); - entity.HasIndex(e => e.Format); - }); + entity.HasIndex(e => e.Introduced).HasDatabaseName("idx_sound_synths_introduced"); - modelBuilder.Entity(entity => - { - entity.Property(e => e.Md5).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha1).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha256).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha3).HasConversion(hexToBytesConverter); - - entity.HasOne(d => d.MediaDump).WithMany(p => p.Files).OnDelete(DeleteBehavior.Cascade); - - entity.HasIndex(e => e.Size); - entity.HasIndex(e => e.Md5); - entity.HasIndex(e => e.Sha1); - entity.HasIndex(e => e.Sha256); - entity.HasIndex(e => e.Sha3); - entity.HasIndex(e => e.Spamsum); - }); + entity.HasIndex(e => e.ModelCode).HasDatabaseName("idx_sound_synths_model_code"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.MediaDumpFileImage).WithMany(p => p.Filesystems).OnDelete(DeleteBehavior.Cascade); + entity.HasIndex(e => e.Name).HasDatabaseName("idx_sound_synths_name"); - entity.HasOne(d => d.Filesystem).WithMany(p => p.MediaDumpFileImages).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.SquareWave).HasDatabaseName("idx_sound_synths_square_wave"); - modelBuilder.Entity(entity => - { - entity.Property(e => e.Md5).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha1).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha256).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha3).HasConversion(hexToBytesConverter); - - entity.HasOne(d => d.MediaDump).WithOne(p => p.Image).OnDelete(DeleteBehavior.Cascade); - - entity.HasIndex(e => e.Size); - entity.HasIndex(e => e.Md5); - entity.HasIndex(e => e.Sha1); - entity.HasIndex(e => e.Sha256); - entity.HasIndex(e => e.Sha3); - entity.HasIndex(e => e.Spamsum); - entity.HasIndex(e => e.AccoustId); - }); + entity.HasIndex(e => e.Type).HasDatabaseName("idx_sound_synths_type"); - modelBuilder.Entity(entity => - { - entity.Property(e => e.Md5).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha1).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha256).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha3).HasConversion(hexToBytesConverter); - - entity.HasOne(d => d.MediaDump).WithOne(p => p.Subchannel).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.Track).WithOne(p => p.Subchannel).OnDelete(DeleteBehavior.Cascade); - - entity.HasIndex(e => e.Size); - entity.HasIndex(e => e.Md5); - entity.HasIndex(e => e.Sha1); - entity.HasIndex(e => e.Sha256); - entity.HasIndex(e => e.Sha3); - entity.HasIndex(e => e.Spamsum); - }); + entity.HasIndex(e => e.Voices).HasDatabaseName("idx_sound_synths_voices"); - modelBuilder.Entity(entity => - { - entity.Property(e => e.Md5).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha1).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha256).HasConversion(hexToBytesConverter); - entity.Property(e => e.Sha3).HasConversion(hexToBytesConverter); - - entity.HasOne(d => d.MediaDump).WithMany(p => p.Tracks).OnDelete(DeleteBehavior.Cascade); - - entity.HasIndex(e => e.Size); - entity.HasIndex(e => e.Format); - entity.HasIndex(e => e.Md5); - entity.HasIndex(e => e.Sha1); - entity.HasIndex(e => e.Sha256); - entity.HasIndex(e => e.Sha3); - entity.HasIndex(e => e.Spamsum); - }); + entity.HasIndex(e => e.WhiteNoise).HasDatabaseName("idx_sound_synths_white_noise"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Path); - entity.HasIndex(e => e.Name); - entity.HasIndex(e => e.IsDirectory); - entity.HasIndex(e => e.CreationDate); - entity.HasIndex(e => e.AccessDate); - entity.HasIndex(e => e.StatusChangeDate); - entity.HasIndex(e => e.BackupDate); - entity.HasIndex(e => e.LastWriteDate); - entity.HasIndex(e => e.GroupId); - entity.HasIndex(e => e.UserId); - }); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.MediaFile).WithMany(p => p.DataStreams).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.CompanyId).HasColumnName("company").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Filesystem).WithMany(p => p.Files).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.Depth).HasColumnName("depth").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Dumper); - entity.HasIndex(e => e.DumpingGroup); - entity.HasIndex(e => e.DumpDate); + entity.Property(e => e.Frequency).HasColumnName("frequency"); - entity.HasOne(e => e.User).WithMany(e => e.Dumps).OnDelete(DeleteBehavior.SetNull); - entity.HasOne(e => e.Media).WithMany(e => e.Dumps).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(e => e.MediaDump).WithMany(e => e.Dumps).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.Introduced).HasColumnName("introduced").HasColumnType("datetime"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Name); - entity.HasIndex(e => e.Introduced); + entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)"); - entity.HasOne(e => e.Parent).WithMany(e => e.Children).OnDelete(DeleteBehavior.SetNull); - }); + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("char(50)") + .HasDefaultValueSql("''"); - modelBuilder.Entity(entity => - { - entity.ToTable("CompaniesBySoftwareFamily"); + entity.Property(e => e.SquareWave).HasColumnName("square_wave").HasColumnType("int(11)"); - entity.HasOne(d => d.Company).WithMany(p => p.SoftwareFamilies).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareFamily).WithMany(p => p.Companies).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Person).WithMany(p => p.SoftwareFamilies).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareFamily).WithMany(p => p.People).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.Voices).HasColumnName("voices").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.ToTable("SoftwareVersion"); + entity.Property(e => e.WhiteNoise).HasColumnName("white_noise").HasColumnType("int(11)"); - entity.HasIndex(e => e.Name); - entity.HasIndex(e => e.Introduced); - entity.HasIndex(e => e.Codename); - entity.HasIndex(e => e.Version); + entity.HasOne(d => d.Company) + .WithMany(p => p.SoundSynths) + .HasForeignKey(d => d.CompanyId) + .HasConstraintName("fk_sound_synths_company"); + }); - entity.HasOne(e => e.Family).WithMany(e => e.Versions).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(e => e.Previous).WithOne(e => e.Next).OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity(entity => + { + entity.ToTable("storage_by_machine"); - modelBuilder.Entity(entity => - { - entity.ToTable("CompaniesBySoftwareVersion"); + entity.HasIndex(e => e.Capacity).HasDatabaseName("idx_storage_capacity"); - entity.HasOne(d => d.Company).WithMany(p => p.SoftwareVersions).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVersion).WithMany(p => p.Companies).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.Interface).HasDatabaseName("idx_storage_interface"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Person).WithMany(p => p.SoftwareVersions).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVersion).WithMany(p => p.People).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.MachineId).HasDatabaseName("idx_storage_machine"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Introduced); - entity.HasIndex(e => e.Name); - entity.HasIndex(e => e.CatalogueNumber); - entity.HasIndex(e => e.DistributionMode); - entity.HasIndex(e => e.MinimumMemory); - entity.HasIndex(e => e.PartNumber); - entity.HasIndex(e => e.ProductCode); - entity.HasIndex(e => e.RecommendedMemory); - entity.HasIndex(e => e.RequiredStorage); - entity.HasIndex(e => e.SerialNumber); - entity.HasIndex(e => e.Version); - - entity.HasOne(e => e.Parent).WithMany(e => e.Derivates).OnDelete(DeleteBehavior.SetNull); - entity.HasOne(e => e.SoftwareVersion).WithMany(e => e.Variants).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.Type).HasDatabaseName("idx_storage_type"); - modelBuilder.Entity(entity => - { - entity.ToTable("CompaniesBySoftwareVariant"); + entity.Property(e => e.Id).HasColumnName("id").HasColumnType("bigint(20)"); - entity.HasOne(d => d.Company).WithMany(p => p.SoftwareVariants).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Companies).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.Capacity).HasColumnName("capacity").HasColumnType("bigint(20)"); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Minimum); - entity.HasIndex(e => e.Recommended); + entity.Property(e => e.Interface) + .HasColumnName("interface") + .HasColumnType("int(11)") + .HasDefaultValueSql("'0'"); - entity.HasOne(d => d.Gpu).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Gpus).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.InstructionSet).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Architectures).OnDelete(DeleteBehavior.Cascade); - }); + entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'"); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Language).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Languages).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasOne(d => d.Machine) + .WithMany(p => p.Storage) + .HasForeignKey(d => d.MachineId) + .HasConstraintName("fk_storage_by_machine_machine"); + }); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.MachineFamily).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.MachineFamilies).OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Capacity); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Machine).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Machines).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.Interface); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Media).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Media).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.OwnedMachineId); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.Person).WithMany(p => p.SoftwareVariants).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.People).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasIndex(e => e.Type); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Minimum); - entity.HasIndex(e => e.Recommended); - entity.HasIndex(e => e.Speed); + entity.HasOne(d => d.OwnedMachine).WithMany(p => p.Storage).HasForeignKey(d => d.OwnedMachineId); + }); - entity.HasOne(d => d.Processor).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Processors).OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Name); + entity.HasIndex(e => e.SPDX); + entity.HasIndex(e => e.FsfApproved); + entity.HasIndex(e => e.OsiApproved); + }); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.RequiredOperatingSystems). - OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(d => d.Table); + entity.HasIndex(d => d.Type); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(d => d.Numeric); + entity.HasIndex(d => d.Withdrawn); + }); + + modelBuilder.Entity(entity => { entity.HasIndex(d => d.Year); }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(d => d.Start); + entity.HasIndex(d => d.End); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Manufacturer); + entity.HasIndex(e => e.Model); + entity.HasIndex(e => e.Revision); + entity.HasIndex(e => e.Firmware); + entity.HasIndex(e => e.Serial); + entity.HasIndex(e => e.SoftwareName); + entity.HasIndex(e => e.SoftwareVersion); + entity.HasIndex(e => e.SoftwareOperatingSystem); + + entity.HasOne(e => e.Dump).WithMany(e => e.DumpHardware).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.Md5).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha1).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha256).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha3).HasConversion(_hexToBytesConverter); + + entity.HasIndex(e => e.Size); + entity.HasIndex(e => e.Md5); + entity.HasIndex(e => e.Sha1); + entity.HasIndex(e => e.Sha256); + entity.HasIndex(e => e.Sha3); + entity.HasIndex(e => e.Spamsum); + entity.HasIndex(e => e.Mime); + entity.HasIndex(e => e.Magic); + entity.HasIndex(e => e.AccoustId); + entity.HasIndex(e => e.Infected); + entity.HasIndex(e => e.Malware); + entity.HasIndex(e => e.Hack); + entity.HasIndex(e => e.HackGroup); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(d => d.Name); + entity.HasIndex(d => d.Size); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(d => d.Type); + entity.HasIndex(d => d.CreationDate); + entity.HasIndex(d => d.ModificationDate); + entity.HasIndex(d => d.BackupDate); + entity.HasIndex(d => d.Serial); + entity.HasIndex(d => d.Label); + entity.HasIndex(d => d.SystemIdentifier); + entity.HasIndex(d => d.VolumeSetIdentifier); + entity.HasIndex(d => d.PublisherIdentifier); + entity.HasIndex(d => d.DataPreparerIdentifier); + entity.HasIndex(d => d.ApplicationIdentifier); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Description); + entity.HasIndex(e => e.Name); + entity.HasIndex(e => e.Type); + entity.HasIndex(e => e.Scheme); + entity.HasIndex(e => e.FirstSector); + entity.HasIndex(e => e.LastSector); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Partition).WithMany(p => p.Filesystems).OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.Filesystem).WithMany(p => p.Partitions).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Title); + entity.HasIndex(e => e.Type); + entity.HasIndex(e => e.CopyProtection); + entity.HasIndex(e => e.PartNumber); + entity.HasIndex(e => e.SerialNumber); + entity.HasIndex(e => e.Barcode); + entity.HasIndex(e => e.CatalogueNumber); + entity.HasIndex(e => e.Manufacturer); + entity.HasIndex(e => e.Model); + entity.HasIndex(e => e.Revision); + entity.HasIndex(e => e.Firmware); + + entity.HasOne(d => d.MagazineIssue).WithMany(p => p.Coverdiscs).OnDelete(DeleteBehavior.SetNull); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Partition).WithMany(p => p.Media).OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.Media).WithMany(p => p.LogicalPartitions).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Media).WithMany(p => p.MediaDumps).OnDelete(DeleteBehavior.Cascade); + + entity.HasIndex(e => e.Status); + entity.HasIndex(e => e.Format); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.Md5).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha1).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha256).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha3).HasConversion(_hexToBytesConverter); + + entity.HasOne(d => d.MediaDump).WithMany(p => p.Files).OnDelete(DeleteBehavior.Cascade); + + entity.HasIndex(e => e.Size); + entity.HasIndex(e => e.Md5); + entity.HasIndex(e => e.Sha1); + entity.HasIndex(e => e.Sha256); + entity.HasIndex(e => e.Sha3); + entity.HasIndex(e => e.Spamsum); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.MediaDumpFileImage).WithMany(p => p.Filesystems).OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.Filesystem).WithMany(p => p.MediaDumpFileImages).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.Md5).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha1).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha256).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha3).HasConversion(_hexToBytesConverter); + + entity.HasOne(d => d.MediaDump).WithOne(p => p.Image).OnDelete(DeleteBehavior.Cascade); + + entity.HasIndex(e => e.Size); + entity.HasIndex(e => e.Md5); + entity.HasIndex(e => e.Sha1); + entity.HasIndex(e => e.Sha256); + entity.HasIndex(e => e.Sha3); + entity.HasIndex(e => e.Spamsum); + entity.HasIndex(e => e.AccoustId); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.Md5).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha1).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha256).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha3).HasConversion(_hexToBytesConverter); + + entity.HasOne(d => d.MediaDump).WithOne(p => p.Subchannel).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.Track).WithOne(p => p.Subchannel).OnDelete(DeleteBehavior.Cascade); + + entity.HasIndex(e => e.Size); + entity.HasIndex(e => e.Md5); + entity.HasIndex(e => e.Sha1); + entity.HasIndex(e => e.Sha256); + entity.HasIndex(e => e.Sha3); + entity.HasIndex(e => e.Spamsum); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.Md5).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha1).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha256).HasConversion(_hexToBytesConverter); + entity.Property(e => e.Sha3).HasConversion(_hexToBytesConverter); + + entity.HasOne(d => d.MediaDump).WithMany(p => p.Tracks).OnDelete(DeleteBehavior.Cascade); + + entity.HasIndex(e => e.Size); + entity.HasIndex(e => e.Format); + entity.HasIndex(e => e.Md5); + entity.HasIndex(e => e.Sha1); + entity.HasIndex(e => e.Sha256); + entity.HasIndex(e => e.Sha3); + entity.HasIndex(e => e.Spamsum); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Path); + entity.HasIndex(e => e.Name); + entity.HasIndex(e => e.IsDirectory); + entity.HasIndex(e => e.CreationDate); + entity.HasIndex(e => e.AccessDate); + entity.HasIndex(e => e.StatusChangeDate); + entity.HasIndex(e => e.BackupDate); + entity.HasIndex(e => e.LastWriteDate); + entity.HasIndex(e => e.GroupId); + entity.HasIndex(e => e.UserId); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.MediaFile) + .WithMany(p => p.DataStreams) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Filesystem) + .WithMany(p => p.Files) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Dumper); + entity.HasIndex(e => e.DumpingGroup); + entity.HasIndex(e => e.DumpDate); + + entity.HasOne(e => e.User).WithMany(e => e.Dumps).OnDelete(DeleteBehavior.SetNull); + entity.HasOne(e => e.Media).WithMany(e => e.Dumps).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(e => e.MediaDump).WithMany(e => e.Dumps).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Name); + entity.HasIndex(e => e.Introduced); + + entity.HasOne(e => e.Parent).WithMany(e => e.Children).OnDelete(DeleteBehavior.SetNull); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("CompaniesBySoftwareFamily"); + + entity.HasOne(d => d.Company).WithMany(p => p.SoftwareFamilies).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareFamily).WithMany(p => p.Companies).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Person).WithMany(p => p.SoftwareFamilies).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareFamily).WithMany(p => p.People).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("SoftwareVersion"); + + entity.HasIndex(e => e.Name); + entity.HasIndex(e => e.Introduced); + entity.HasIndex(e => e.Codename); + entity.HasIndex(e => e.Version); + + entity.HasOne(e => e.Family).WithMany(e => e.Versions).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(e => e.Previous).WithOne(e => e.Next).OnDelete(DeleteBehavior.SetNull); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("CompaniesBySoftwareVersion"); + + entity.HasOne(d => d.Company).WithMany(p => p.SoftwareVersions).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVersion).WithMany(p => p.Companies).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Person).WithMany(p => p.SoftwareVersions).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVersion).WithMany(p => p.People).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Introduced); + entity.HasIndex(e => e.Name); + entity.HasIndex(e => e.CatalogueNumber); + entity.HasIndex(e => e.DistributionMode); + entity.HasIndex(e => e.MinimumMemory); + entity.HasIndex(e => e.PartNumber); + entity.HasIndex(e => e.ProductCode); + entity.HasIndex(e => e.RecommendedMemory); + entity.HasIndex(e => e.RequiredStorage); + entity.HasIndex(e => e.SerialNumber); + entity.HasIndex(e => e.Version); + + entity.HasOne(e => e.Parent).WithMany(e => e.Derivates).OnDelete(DeleteBehavior.SetNull); + entity.HasOne(e => e.SoftwareVersion).WithMany(e => e.Variants).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("CompaniesBySoftwareVariant"); + + entity.HasOne(d => d.Company).WithMany(p => p.SoftwareVariants).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Companies).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Minimum); + entity.HasIndex(e => e.Recommended); + + entity.HasOne(d => d.Gpu).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Gpus).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.InstructionSet).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Architectures).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Language).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Languages).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.MachineFamily).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.MachineFamilies).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Machine).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Machines).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Media).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Media).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.Person).WithMany(p => p.SoftwareVariants).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.People).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Minimum); + entity.HasIndex(e => e.Recommended); + entity.HasIndex(e => e.Speed); + + entity.HasOne(d => d.Processor).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Processors).OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.SoftwareVariant) + .WithMany(p => p.RequiredOperatingSystems) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.SoftwareVariant) + .WithMany(p => p.RequiredSoftware) + .OnDelete(DeleteBehavior.Cascade); + }); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.RequiredSoftware). - OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.SoundSynth).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.SupportedSound).OnDelete(DeleteBehavior.Cascade); + }); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.SoundSynth).WithMany(p => p.Software).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.SupportedSound).OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity(entity => + { + entity.HasOne(d => d.StandaloneFile) + .WithMany(p => p.DataStreams) + .OnDelete(DeleteBehavior.Cascade); + }); - modelBuilder.Entity(entity => - { - entity.HasOne(d => d.StandaloneFile).WithMany(p => p.DataStreams).OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Path); + entity.HasIndex(e => e.Name); + entity.HasIndex(e => e.IsDirectory); + entity.HasIndex(e => e.CreationDate); + entity.HasIndex(e => e.AccessDate); + entity.HasIndex(e => e.StatusChangeDate); + entity.HasIndex(e => e.BackupDate); + entity.HasIndex(e => e.LastWriteDate); + entity.HasIndex(e => e.GroupId); + entity.HasIndex(e => e.UserId); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Path); - entity.HasIndex(e => e.Name); - entity.HasIndex(e => e.IsDirectory); - entity.HasIndex(e => e.CreationDate); - entity.HasIndex(e => e.AccessDate); - entity.HasIndex(e => e.StatusChangeDate); - entity.HasIndex(e => e.BackupDate); - entity.HasIndex(e => e.LastWriteDate); - entity.HasIndex(e => e.GroupId); - entity.HasIndex(e => e.UserId); - - entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Files).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasOne(d => d.SoftwareVariant).WithMany(p => p.Files).OnDelete(DeleteBehavior.Cascade); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Type); - entity.HasIndex(e => e.Text); - entity.HasOne(d => d.Media).WithMany(p => p.MasteringTexts).OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Type); + entity.HasIndex(e => e.Text); + entity.HasOne(d => d.Media).WithMany(p => p.MasteringTexts).OnDelete(DeleteBehavior.Cascade); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Type); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Type); - entity.HasOne(e => e.MediaDump).WithMany(e => e.Tags).OnDelete(DeleteBehavior.Cascade); - }); + entity.HasOne(e => e.MediaDump).WithMany(e => e.Tags).OnDelete(DeleteBehavior.Cascade); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Path); - }); + modelBuilder.Entity(entity => { entity.HasIndex(e => e.Path); }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Author); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Author); - entity.HasIndex(e => e.ColorSpace); + entity.HasIndex(e => e.ColorSpace); - entity.HasIndex(e => e.Comments); + entity.HasIndex(e => e.Comments); - entity.HasIndex(e => e.CreationDate); + entity.HasIndex(e => e.CreationDate); - entity.HasIndex(e => e.ExifVersion); + entity.HasIndex(e => e.ExifVersion); - entity.HasIndex(e => e.HorizontalResolution); + entity.HasIndex(e => e.HorizontalResolution); - entity.HasIndex(e => e.ResolutionUnit); + entity.HasIndex(e => e.ResolutionUnit); - entity.HasIndex(e => e.ScannerManufacturer); + entity.HasIndex(e => e.ScannerManufacturer); - entity.HasIndex(e => e.ScannerModel); + entity.HasIndex(e => e.ScannerModel); - entity.HasIndex(e => e.SoftwareUsed); + entity.HasIndex(e => e.SoftwareUsed); - entity.HasIndex(e => e.UploadDate); + entity.HasIndex(e => e.UploadDate); - entity.HasIndex(e => e.VerticalResolution); + entity.HasIndex(e => e.VerticalResolution); - entity.HasIndex(e => e.Type); + entity.HasIndex(e => e.Type); - entity.HasIndex(e => e.Page); + entity.HasIndex(e => e.Page); - entity.HasOne(d => d.Book).WithMany(p => p.Scans).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.Book).WithMany(p => p.Scans).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.User).WithMany(p => p.BookScans).OnDelete(DeleteBehavior.SetNull); - }); + entity.HasOne(d => d.User).WithMany(p => p.BookScans).OnDelete(DeleteBehavior.SetNull); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Author); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Author); - entity.HasIndex(e => e.ColorSpace); + entity.HasIndex(e => e.ColorSpace); - entity.HasIndex(e => e.Comments); + entity.HasIndex(e => e.Comments); - entity.HasIndex(e => e.CreationDate); + entity.HasIndex(e => e.CreationDate); - entity.HasIndex(e => e.ExifVersion); + entity.HasIndex(e => e.ExifVersion); - entity.HasIndex(e => e.HorizontalResolution); + entity.HasIndex(e => e.HorizontalResolution); - entity.HasIndex(e => e.ResolutionUnit); + entity.HasIndex(e => e.ResolutionUnit); - entity.HasIndex(e => e.ScannerManufacturer); + entity.HasIndex(e => e.ScannerManufacturer); - entity.HasIndex(e => e.ScannerModel); + entity.HasIndex(e => e.ScannerModel); - entity.HasIndex(e => e.SoftwareUsed); + entity.HasIndex(e => e.SoftwareUsed); - entity.HasIndex(e => e.UploadDate); + entity.HasIndex(e => e.UploadDate); - entity.HasIndex(e => e.VerticalResolution); + entity.HasIndex(e => e.VerticalResolution); - entity.HasIndex(e => e.Type); + entity.HasIndex(e => e.Type); - entity.HasIndex(e => e.Page); + entity.HasIndex(e => e.Page); - entity.HasOne(d => d.Document).WithMany(p => p.Scans).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.Document).WithMany(p => p.Scans).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.User).WithMany(p => p.DocumentScans).OnDelete(DeleteBehavior.SetNull); - }); + entity.HasOne(d => d.User).WithMany(p => p.DocumentScans).OnDelete(DeleteBehavior.SetNull); + }); - modelBuilder.Entity(entity => - { - entity.HasIndex(e => e.Author); + modelBuilder.Entity(entity => + { + entity.HasIndex(e => e.Author); - entity.HasIndex(e => e.ColorSpace); + entity.HasIndex(e => e.ColorSpace); - entity.HasIndex(e => e.Comments); + entity.HasIndex(e => e.Comments); - entity.HasIndex(e => e.CreationDate); + entity.HasIndex(e => e.CreationDate); - entity.HasIndex(e => e.ExifVersion); + entity.HasIndex(e => e.ExifVersion); - entity.HasIndex(e => e.HorizontalResolution); + entity.HasIndex(e => e.HorizontalResolution); - entity.HasIndex(e => e.ResolutionUnit); + entity.HasIndex(e => e.ResolutionUnit); - entity.HasIndex(e => e.ScannerManufacturer); + entity.HasIndex(e => e.ScannerManufacturer); - entity.HasIndex(e => e.ScannerModel); + entity.HasIndex(e => e.ScannerModel); - entity.HasIndex(e => e.SoftwareUsed); + entity.HasIndex(e => e.SoftwareUsed); - entity.HasIndex(e => e.UploadDate); + entity.HasIndex(e => e.UploadDate); - entity.HasIndex(e => e.VerticalResolution); + entity.HasIndex(e => e.VerticalResolution); - entity.HasIndex(e => e.Type); + entity.HasIndex(e => e.Type); - entity.HasIndex(e => e.Page); + entity.HasIndex(e => e.Page); - entity.HasOne(d => d.Magazine).WithMany(p => p.Scans).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(d => d.Magazine).WithMany(p => p.Scans).OnDelete(DeleteBehavior.Cascade); - entity.HasOne(d => d.User).WithMany(p => p.MagazineScans).OnDelete(DeleteBehavior.SetNull); - }); - } + entity.HasOne(d => d.User).WithMany(p => p.MagazineScans).OnDelete(DeleteBehavior.SetNull); + }); } } \ No newline at end of file diff --git a/Marechai.Database/Models/MarechaiDb.cs b/Marechai.Database/Models/MarechaiDb.cs index 9d6d3de0..3363eb64 100644 --- a/Marechai.Database/Models/MarechaiDb.cs +++ b/Marechai.Database/Models/MarechaiDb.cs @@ -25,12 +25,11 @@ using System; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MarechaiDb { - public class MarechaiDb - { - public int Id { get; set; } - public int Version { get; set; } - public DateTimeOffset? Updated { get; set; } - } + public int Id { get; set; } + public int Version { get; set; } + public DateTimeOffset? Updated { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MasteringText.cs b/Marechai.Database/Models/MasteringText.cs index 3ff0cd13..a855b555 100644 --- a/Marechai.Database/Models/MasteringText.cs +++ b/Marechai.Database/Models/MasteringText.cs @@ -1,15 +1,14 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MasteringText : BaseModel { - public class MasteringText : BaseModel - { - public MasteringTextType Type { get; set; } - [Required] - public string Text { get; set; } - public short? Side { get; set; } - public short? Layer { get; set; } - [Required] - public virtual Media Media { get; set; } - } + public MasteringTextType Type { get; set; } + [Required] + public string Text { get; set; } + public short? Side { get; set; } + public short? Layer { get; set; } + [Required] + public virtual Media Media { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Media.cs b/Marechai.Database/Models/Media.cs index 2c0f5aa8..525db507 100644 --- a/Marechai.Database/Models/Media.cs +++ b/Marechai.Database/Models/Media.cs @@ -28,44 +28,43 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Aaru.CommonTypes; -namespace Marechai.Database.Models -{ - public class Media : BaseModel - { - [Required] - public string Title { get; set; } - public ushort? Sequence { get; set; } - public ushort? LastSequence { get; set; } - public MediaType Type { get; set; } - public int? WriteOffset { get; set; } - public ushort? Sides { get; set; } - public ushort? Layers { get; set; } - public ushort? Sessions { get; set; } - public ushort? Tracks { get; set; } - public ulong Sectors { get; set; } - public ulong Size { get; set; } - public string CopyProtection { get; set; } - public string PartNumber { get; set; } - public string SerialNumber { get; set; } - public string Barcode { get; set; } - public string CatalogueNumber { get; set; } - public string Manufacturer { get; set; } - public string Model { get; set; } - public string Revision { get; set; } - public string Firmware { get; set; } - public int? PhysicalBlockSize { get; set; } - public int? LogicalBlockSize { get; set; } - [Column(TypeName = "json")] - public VariableBlockSize[] BlockSizes { get; set; } - public StorageInterface? StorageInterface { get; set; } - [Column(TypeName = "json")] - public OpticalDiscTrack[] TableOfContents { get; set; } - public virtual MagazineIssue MagazineIssue { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection LogicalPartitions { get; set; } - public virtual ICollection MediaDumps { get; set; } - public virtual ICollection Dumps { get; set; } - public virtual ICollection Software { get; set; } - public virtual ICollection MasteringTexts { get; set; } - } +public class Media : BaseModel +{ + [Required] + public string Title { get; set; } + public ushort? Sequence { get; set; } + public ushort? LastSequence { get; set; } + public MediaType Type { get; set; } + public int? WriteOffset { get; set; } + public ushort? Sides { get; set; } + public ushort? Layers { get; set; } + public ushort? Sessions { get; set; } + public ushort? Tracks { get; set; } + public ulong Sectors { get; set; } + public ulong Size { get; set; } + public string CopyProtection { get; set; } + public string PartNumber { get; set; } + public string SerialNumber { get; set; } + public string Barcode { get; set; } + public string CatalogueNumber { get; set; } + public string Manufacturer { get; set; } + public string Model { get; set; } + public string Revision { get; set; } + public string Firmware { get; set; } + public int? PhysicalBlockSize { get; set; } + public int? LogicalBlockSize { get; set; } + [Column(TypeName = "json")] + public VariableBlockSize[] BlockSizes { get; set; } + public StorageInterface? StorageInterface { get; set; } + [Column(TypeName = "json")] + public OpticalDiscTrack[] TableOfContents { get; set; } + public virtual MagazineIssue MagazineIssue { get; set; } + + public virtual ICollection LogicalPartitions { get; set; } + public virtual ICollection MediaDumps { get; set; } + public virtual ICollection Dumps { get; set; } + public virtual ICollection Software { get; set; } + public virtual ICollection MasteringTexts { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MediaBySoftwareVariant.cs b/Marechai.Database/Models/MediaBySoftwareVariant.cs index ae44b67e..2a390413 100644 --- a/Marechai.Database/Models/MediaBySoftwareVariant.cs +++ b/Marechai.Database/Models/MediaBySoftwareVariant.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MediaBySoftwareVariant : BaseModel { - public class MediaBySoftwareVariant : BaseModel - { - [Required] - public virtual Media Media { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - } + [Required] + public virtual Media Media { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MediaDump.cs b/Marechai.Database/Models/MediaDump.cs index eda0f7b9..c40db328 100644 --- a/Marechai.Database/Models/MediaDump.cs +++ b/Marechai.Database/Models/MediaDump.cs @@ -26,20 +26,19 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class MediaDump : BaseModel - { - [Required] - public virtual Media Media { get; set; } - public string Format { get; set; } - public DumpStatus Status { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection Files { get; set; } - public virtual MediaDumpImage Image { get; set; } - public virtual MediaDumpSubchannelImage Subchannel { get; set; } - public virtual ICollection Tracks { get; set; } - public virtual ICollection Dumps { get; set; } - public virtual ICollection Tags { get; set; } - } +public class MediaDump : BaseModel +{ + [Required] + public virtual Media Media { get; set; } + public string Format { get; set; } + public DumpStatus Status { get; set; } + + public virtual ICollection Files { get; set; } + public virtual MediaDumpImage Image { get; set; } + public virtual MediaDumpSubchannelImage Subchannel { get; set; } + public virtual ICollection Tracks { get; set; } + public virtual ICollection Dumps { get; set; } + public virtual ICollection Tags { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MediaDumpFileImage.cs b/Marechai.Database/Models/MediaDumpFileImage.cs index b3488454..ffc672fb 100644 --- a/Marechai.Database/Models/MediaDumpFileImage.cs +++ b/Marechai.Database/Models/MediaDumpFileImage.cs @@ -27,25 +27,24 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class MediaDumpFileImage : BaseModel - { - [Required] - public virtual MediaDump MediaDump { get; set; } - public long FileSequence { get; set; } - public short PartitionSequence { get; set; } - public ulong Size { get; set; } - [Column(TypeName = "binary(16)")] - public string Md5 { get; set; } - [Column(TypeName = "binary(20)")] - public string Sha1 { get; set; } - [Column(TypeName = "binary(32)")] - public string Sha256 { get; set; } - [Column(TypeName = "binary(64)")] - public string Sha3 { get; set; } - public string Spamsum { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection Filesystems { get; set; } - } +public class MediaDumpFileImage : BaseModel +{ + [Required] + public virtual MediaDump MediaDump { get; set; } + public long FileSequence { get; set; } + public short PartitionSequence { get; set; } + public ulong Size { get; set; } + [Column(TypeName = "binary(16)")] + public string Md5 { get; set; } + [Column(TypeName = "binary(20)")] + public string Sha1 { get; set; } + [Column(TypeName = "binary(32)")] + public string Sha256 { get; set; } + [Column(TypeName = "binary(64)")] + public string Sha3 { get; set; } + public string Spamsum { get; set; } + + public virtual ICollection Filesystems { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MediaDumpImage.cs b/Marechai.Database/Models/MediaDumpImage.cs index 111b0662..8d8a6bc0 100644 --- a/Marechai.Database/Models/MediaDumpImage.cs +++ b/Marechai.Database/Models/MediaDumpImage.cs @@ -1,23 +1,22 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MediaDumpImage : BaseModel { - public class MediaDumpImage : BaseModel - { - public ulong MediaDumpId { get; set; } - [Required] - public virtual MediaDump MediaDump { get; set; } - public ulong Size { get; set; } - [Column(TypeName = "binary(16)")] - public string Md5 { get; set; } - [Column(TypeName = "binary(20)")] - public string Sha1 { get; set; } - [Column(TypeName = "binary(32)")] - public string Sha256 { get; set; } - [Column(TypeName = "binary(64)")] - public string Sha3 { get; set; } - public string Spamsum { get; set; } - public string AccoustId { get; set; } - } + public ulong MediaDumpId { get; set; } + [Required] + public virtual MediaDump MediaDump { get; set; } + public ulong Size { get; set; } + [Column(TypeName = "binary(16)")] + public string Md5 { get; set; } + [Column(TypeName = "binary(20)")] + public string Sha1 { get; set; } + [Column(TypeName = "binary(32)")] + public string Sha256 { get; set; } + [Column(TypeName = "binary(64)")] + public string Sha3 { get; set; } + public string Spamsum { get; set; } + public string AccoustId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MediaDumpSubchannelImage.cs b/Marechai.Database/Models/MediaDumpSubchannelImage.cs index a66f7afd..0a4c2c4b 100644 --- a/Marechai.Database/Models/MediaDumpSubchannelImage.cs +++ b/Marechai.Database/Models/MediaDumpSubchannelImage.cs @@ -25,26 +25,25 @@ using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class MediaDumpSubchannelImage : BaseModel - { - public short TrackSequence { get; set; } - public SubchannelStatus Status { get; set; } - public ulong Size { get; set; } - [Column(TypeName = "binary(16)")] - public string Md5 { get; set; } - [Column(TypeName = "binary(20)")] - public string Sha1 { get; set; } - [Column(TypeName = "binary(32)")] - public string Sha256 { get; set; } - [Column(TypeName = "binary(64)")] - public string Sha3 { get; set; } - public string Spamsum { get; set; } - public ulong? MediaDumpId { get; set; } - public ulong? TrackId { get; set; } +namespace Marechai.Database.Models; - public virtual MediaDump MediaDump { get; set; } - public virtual MediaDumpTrackImage Track { get; set; } - } +public class MediaDumpSubchannelImage : BaseModel +{ + public short TrackSequence { get; set; } + public SubchannelStatus Status { get; set; } + public ulong Size { get; set; } + [Column(TypeName = "binary(16)")] + public string Md5 { get; set; } + [Column(TypeName = "binary(20)")] + public string Sha1 { get; set; } + [Column(TypeName = "binary(32)")] + public string Sha256 { get; set; } + [Column(TypeName = "binary(64)")] + public string Sha3 { get; set; } + public string Spamsum { get; set; } + public ulong? MediaDumpId { get; set; } + public ulong? TrackId { get; set; } + + public virtual MediaDump MediaDump { get; set; } + public virtual MediaDumpTrackImage Track { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MediaDumpTrackImage.cs b/Marechai.Database/Models/MediaDumpTrackImage.cs index 7f247172..bae246f5 100644 --- a/Marechai.Database/Models/MediaDumpTrackImage.cs +++ b/Marechai.Database/Models/MediaDumpTrackImage.cs @@ -25,24 +25,23 @@ using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class MediaDumpTrackImage : BaseModel - { - public short TrackSequence { get; set; } - public string Format { get; set; } - public ulong Size { get; set; } - [Column(TypeName = "binary(16)")] - public string Md5 { get; set; } - [Column(TypeName = "binary(20)")] - public string Sha1 { get; set; } - [Column(TypeName = "binary(32)")] - public string Sha256 { get; set; } - [Column(TypeName = "binary(64)")] - public string Sha3 { get; set; } - public string Spamsum { get; set; } +namespace Marechai.Database.Models; - public virtual MediaDump MediaDump { get; set; } - public virtual MediaDumpSubchannelImage Subchannel { get; set; } - } +public class MediaDumpTrackImage : BaseModel +{ + public short TrackSequence { get; set; } + public string Format { get; set; } + public ulong Size { get; set; } + [Column(TypeName = "binary(16)")] + public string Md5 { get; set; } + [Column(TypeName = "binary(20)")] + public string Sha1 { get; set; } + [Column(TypeName = "binary(32)")] + public string Sha256 { get; set; } + [Column(TypeName = "binary(64)")] + public string Sha3 { get; set; } + public string Spamsum { get; set; } + + public virtual MediaDump MediaDump { get; set; } + public virtual MediaDumpSubchannelImage Subchannel { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MediaFile.cs b/Marechai.Database/Models/MediaFile.cs index 71142440..48c0a330 100644 --- a/Marechai.Database/Models/MediaFile.cs +++ b/Marechai.Database/Models/MediaFile.cs @@ -25,10 +25,9 @@ using System.Collections.Generic; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MediaFile : BaseFile { - public class MediaFile : BaseFile - { - public virtual ICollection DataStreams { get; set; } - } + public virtual ICollection DataStreams { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MediaTagDump.cs b/Marechai.Database/Models/MediaTagDump.cs index dcfa91ec..b8291089 100644 --- a/Marechai.Database/Models/MediaTagDump.cs +++ b/Marechai.Database/Models/MediaTagDump.cs @@ -1,16 +1,15 @@ using System.ComponentModel.DataAnnotations; using Aaru.CommonTypes.Enums; -namespace Marechai.Database.Models -{ - public class MediaTagDump : BaseModel - { - [Required] - public virtual MediaDump MediaDump { get; set; } - public MediaTagType Type { get; set; } - [Required] - public virtual DbFile File { get; set; } +namespace Marechai.Database.Models; - public ulong FileId { get; set; } - } +public class MediaTagDump : BaseModel +{ + [Required] + public virtual MediaDump MediaDump { get; set; } + public MediaTagType Type { get; set; } + [Required] + public virtual DbFile File { get; set; } + + public ulong FileId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MemoryByMachine.cs b/Marechai.Database/Models/MemoryByMachine.cs index 61a14d61..cfcfc282 100644 --- a/Marechai.Database/Models/MemoryByMachine.cs +++ b/Marechai.Database/Models/MemoryByMachine.cs @@ -25,17 +25,16 @@ using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class MemoryByMachine : BaseModel - { - public int MachineId { get; set; } - public MemoryType Type { get; set; } - public MemoryUsage Usage { get; set; } - public long? Size { get; set; } - [DisplayName("Speed (Hz)")] - public double? Speed { get; set; } +namespace Marechai.Database.Models; - public virtual Machine Machine { get; set; } - } +public class MemoryByMachine : BaseModel +{ + public int MachineId { get; set; } + public MemoryType Type { get; set; } + public MemoryUsage Usage { get; set; } + public long? Size { get; set; } + [DisplayName("Speed (Hz)")] + public double? Speed { get; set; } + + public virtual Machine Machine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MemoryByOwnedMachine.cs b/Marechai.Database/Models/MemoryByOwnedMachine.cs index ef56ed6c..5041ec24 100644 --- a/Marechai.Database/Models/MemoryByOwnedMachine.cs +++ b/Marechai.Database/Models/MemoryByOwnedMachine.cs @@ -25,17 +25,16 @@ using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class MemoryByOwnedMachine : BaseModel - { - public long OwnedMachineId { get; set; } - public MemoryType Type { get; set; } - public MemoryUsage Usage { get; set; } - public long Size { get; set; } - [DisplayName("Speed (Hz)")] - public double Speed { get; set; } +namespace Marechai.Database.Models; - public virtual OwnedMachine OwnedMachine { get; set; } - } +public class MemoryByOwnedMachine : BaseModel +{ + public long OwnedMachineId { get; set; } + public MemoryType Type { get; set; } + public MemoryUsage Usage { get; set; } + public long Size { get; set; } + [DisplayName("Speed (Hz)")] + public double Speed { get; set; } + + public virtual OwnedMachine OwnedMachine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/MoneyDonation.cs b/Marechai.Database/Models/MoneyDonation.cs index 25a609b6..5fec50d9 100644 --- a/Marechai.Database/Models/MoneyDonation.cs +++ b/Marechai.Database/Models/MoneyDonation.cs @@ -23,11 +23,10 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class MoneyDonation : BaseModel { - public class MoneyDonation : BaseModel - { - public string Donator { get; set; } - public decimal Quantity { get; set; } - } + public string Donator { get; set; } + public decimal Quantity { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/News.cs b/Marechai.Database/Models/News.cs index b79e4a05..6a7d15ac 100644 --- a/Marechai.Database/Models/News.cs +++ b/Marechai.Database/Models/News.cs @@ -26,13 +26,12 @@ using System; using System.ComponentModel; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class News : BaseModel { - public class News : BaseModel - { - public DateTime Date { get; set; } - public NewsType Type { get; set; } - [DisplayName("Affected ID")] - public int AddedId { get; set; } - } + public DateTime Date { get; set; } + public NewsType Type { get; set; } + [DisplayName("Affected ID")] + public int AddedId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/OpticalDiscTrack.cs b/Marechai.Database/Models/OpticalDiscTrack.cs index 9a88eb78..66b874b1 100644 --- a/Marechai.Database/Models/OpticalDiscTrack.cs +++ b/Marechai.Database/Models/OpticalDiscTrack.cs @@ -1,14 +1,13 @@ using Aaru.CommonTypes.Enums; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +// Not for a table +public class OpticalDiscTrack { - // Not for a table - public class OpticalDiscTrack - { - public int TrackNumber { get; set; } - public int SessionNumber { get; set; } - public long FirstSector { get; set; } - public long LastSector { get; set; } - public TrackType Type { get; set; } - } + public int TrackNumber { get; set; } + public int SessionNumber { get; set; } + public long FirstSector { get; set; } + public long LastSector { get; set; } + public TrackType Type { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/OwnedMachine.cs b/Marechai.Database/Models/OwnedMachine.cs index 67ca45b5..f142a7e0 100644 --- a/Marechai.Database/Models/OwnedMachine.cs +++ b/Marechai.Database/Models/OwnedMachine.cs @@ -27,38 +27,41 @@ using System; using System.Collections.Generic; using System.ComponentModel; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class OwnedMachine : BaseModel { - public class OwnedMachine : BaseModel - { - [DisplayName("Acquisition date")] - public DateTime AcquisitionDate { get; set; } - [DisplayName("Date when sold, traded, or otherwise lost")] - public DateTime? LostDate { get; set; } - public StatusType Status { get; set; } - [DisplayName("Last status check date")] - public DateTime? LastStatusDate { get; set; } - [DisplayName("Available for trade or sale"), DefaultValue(false)] - public bool Trade { get; set; } - [DisplayName("Has original boxes"), DefaultValue(false)] - public bool Boxed { get; set; } - [DisplayName("Has original manuals"), DefaultValue(false)] - public bool Manuals { get; set; } - [DisplayName("Serial number")] - public string SerialNumber { get; set; } - [DisplayName("Serial number visible to other users"), DefaultValue(false)] - public bool SerialNumberVisible { get; set; } - public int MachineId { get; set; } - public string UserId { get; set; } + [DisplayName("Acquisition date")] + public DateTime AcquisitionDate { get; set; } + [DisplayName("Date when sold, traded, or otherwise lost")] + public DateTime? LostDate { get; set; } + public StatusType Status { get; set; } + [DisplayName("Last status check date")] + public DateTime? LastStatusDate { get; set; } + [DisplayName("Available for trade or sale")] + [DefaultValue(false)] + public bool Trade { get; set; } + [DisplayName("Has original boxes")] + [DefaultValue(false)] + public bool Boxed { get; set; } + [DisplayName("Has original manuals")] + [DefaultValue(false)] + public bool Manuals { get; set; } + [DisplayName("Serial number")] + public string SerialNumber { get; set; } + [DisplayName("Serial number visible to other users")] + [DefaultValue(false)] + public bool SerialNumberVisible { get; set; } + public int MachineId { get; set; } + public string UserId { get; set; } - public virtual ICollection Gpus { get; set; } - public virtual ICollection Memory { get; set; } - public virtual ICollection Processors { get; set; } - public virtual ICollection Sound { get; set; } - public virtual ICollection Storage { get; set; } - public virtual ICollection Photos { get; set; } + public virtual ICollection Gpus { get; set; } + public virtual ICollection Memory { get; set; } + public virtual ICollection Processors { get; set; } + public virtual ICollection Sound { get; set; } + public virtual ICollection Storage { get; set; } + public virtual ICollection Photos { get; set; } - public virtual ApplicationUser User { get; set; } - public virtual Machine Machine { get; set; } - } + public virtual ApplicationUser User { get; set; } + public virtual Machine Machine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/OwnedMachinePhoto.cs b/Marechai.Database/Models/OwnedMachinePhoto.cs index d10e0192..b987b91a 100644 --- a/Marechai.Database/Models/OwnedMachinePhoto.cs +++ b/Marechai.Database/Models/OwnedMachinePhoto.cs @@ -23,11 +23,10 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class OwnedMachinePhoto : BasePhoto { - public class OwnedMachinePhoto : BasePhoto - { - public virtual OwnedMachine OwnedMachine { get; set; } - public long OwnedMachineId { get; set; } - } + public virtual OwnedMachine OwnedMachine { get; set; } + public long OwnedMachineId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/PeopleByBook.cs b/Marechai.Database/Models/PeopleByBook.cs index 04570a5c..31e9b7e8 100644 --- a/Marechai.Database/Models/PeopleByBook.cs +++ b/Marechai.Database/Models/PeopleByBook.cs @@ -26,17 +26,17 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class PeopleByBook : BaseModel - { - public int PersonId { get; set; } - public long BookId { get; set; } - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } +namespace Marechai.Database.Models; - public virtual DocumentPerson Person { get; set; } - public virtual Book Book { get; set; } - public virtual DocumentRole Role { get; set; } - } +public class PeopleByBook : BaseModel +{ + public int PersonId { get; set; } + public long BookId { get; set; } + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } + + public virtual DocumentPerson Person { get; set; } + public virtual Book Book { get; set; } + public virtual DocumentRole Role { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/PeopleByCompany.cs b/Marechai.Database/Models/PeopleByCompany.cs index fb565653..2a53e8db 100644 --- a/Marechai.Database/Models/PeopleByCompany.cs +++ b/Marechai.Database/Models/PeopleByCompany.cs @@ -26,19 +26,18 @@ using System; using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class PeopleByCompany : BaseModel - { - public int PersonId { get; set; } - public int CompanyId { get; set; } - public string Position { get; set; } - public DateTime? Start { get; set; } - public DateTime? End { get; set; } - [DefaultValue(false)] - public bool Ongoing { get; set; } +namespace Marechai.Database.Models; - public virtual Person Person { get; set; } - public virtual Company Company { get; set; } - } +public class PeopleByCompany : BaseModel +{ + public int PersonId { get; set; } + public int CompanyId { get; set; } + public string Position { get; set; } + public DateTime? Start { get; set; } + public DateTime? End { get; set; } + [DefaultValue(false)] + public bool Ongoing { get; set; } + + public virtual Person Person { get; set; } + public virtual Company Company { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/PeopleByDocument.cs b/Marechai.Database/Models/PeopleByDocument.cs index ed75706e..edbd91eb 100644 --- a/Marechai.Database/Models/PeopleByDocument.cs +++ b/Marechai.Database/Models/PeopleByDocument.cs @@ -26,17 +26,17 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class PeopleByDocument : BaseModel - { - public int PersonId { get; set; } - public long DocumentId { get; set; } - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } +namespace Marechai.Database.Models; - public virtual DocumentPerson Person { get; set; } - public virtual Document Document { get; set; } - public virtual DocumentRole Role { get; set; } - } +public class PeopleByDocument : BaseModel +{ + public int PersonId { get; set; } + public long DocumentId { get; set; } + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } + + public virtual DocumentPerson Person { get; set; } + public virtual Document Document { get; set; } + public virtual DocumentRole Role { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/PeopleByMagazine.cs b/Marechai.Database/Models/PeopleByMagazine.cs index 30ecbda5..aac3df69 100644 --- a/Marechai.Database/Models/PeopleByMagazine.cs +++ b/Marechai.Database/Models/PeopleByMagazine.cs @@ -26,17 +26,17 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class PeopleByMagazine : BaseModel - { - public int PersonId { get; set; } - public long MagazineId { get; set; } - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } +namespace Marechai.Database.Models; - public virtual DocumentPerson Person { get; set; } - public virtual MagazineIssue Magazine { get; set; } - public virtual DocumentRole Role { get; set; } - } +public class PeopleByMagazine : BaseModel +{ + public int PersonId { get; set; } + public long MagazineId { get; set; } + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } + + public virtual DocumentPerson Person { get; set; } + public virtual MagazineIssue Magazine { get; set; } + public virtual DocumentRole Role { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/PeopleBySoftwareFamily.cs b/Marechai.Database/Models/PeopleBySoftwareFamily.cs index 8a388263..7e8dbf99 100644 --- a/Marechai.Database/Models/PeopleBySoftwareFamily.cs +++ b/Marechai.Database/Models/PeopleBySoftwareFamily.cs @@ -26,18 +26,18 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class PeopleBySoftwareFamily : BaseModel - { - [Required] - public virtual DocumentRole Role { get; set; } - [Required] - public virtual Person Person { get; set; } - [Required] - public virtual SoftwareFamily SoftwareFamily { get; set; } +namespace Marechai.Database.Models; - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } - } +public class PeopleBySoftwareFamily : BaseModel +{ + [Required] + public virtual DocumentRole Role { get; set; } + [Required] + public virtual Person Person { get; set; } + [Required] + public virtual SoftwareFamily SoftwareFamily { get; set; } + + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/PeopleBySoftwareVariant.cs b/Marechai.Database/Models/PeopleBySoftwareVariant.cs index 5d184145..e57b2d54 100644 --- a/Marechai.Database/Models/PeopleBySoftwareVariant.cs +++ b/Marechai.Database/Models/PeopleBySoftwareVariant.cs @@ -26,18 +26,18 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class PeopleBySoftwareVariant : BaseModel - { - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - [Required] - public virtual Person Person { get; set; } - [Required] - public virtual DocumentRole Role { get; set; } +namespace Marechai.Database.Models; - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } - } +public class PeopleBySoftwareVariant : BaseModel +{ + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } + [Required] + public virtual Person Person { get; set; } + [Required] + public virtual DocumentRole Role { get; set; } + + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/PeopleBySoftwareVersion.cs b/Marechai.Database/Models/PeopleBySoftwareVersion.cs index 3c610d59..a94e8e65 100644 --- a/Marechai.Database/Models/PeopleBySoftwareVersion.cs +++ b/Marechai.Database/Models/PeopleBySoftwareVersion.cs @@ -26,18 +26,18 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Marechai.Database.Models -{ - public class PeopleBySoftwareVersion : BaseModel - { - [Required] - public virtual SoftwareVersion SoftwareVersion { get; set; } - [Required] - public virtual Person Person { get; set; } - [Required] - public virtual DocumentRole Role { get; set; } +namespace Marechai.Database.Models; - [Column(TypeName = "char(3)"), Required] - public string RoleId { get; set; } - } +public class PeopleBySoftwareVersion : BaseModel +{ + [Required] + public virtual SoftwareVersion SoftwareVersion { get; set; } + [Required] + public virtual Person Person { get; set; } + [Required] + public virtual DocumentRole Role { get; set; } + + [Column(TypeName = "char(3)")] + [Required] + public string RoleId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Person.cs b/Marechai.Database/Models/Person.cs index 61481c30..be5850da 100644 --- a/Marechai.Database/Models/Person.cs +++ b/Marechai.Database/Models/Person.cs @@ -30,38 +30,40 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Microsoft.AspNetCore.Mvc; -namespace Marechai.Database.Models -{ - public class Person : BaseModel - { - [Required] - public string Name { get; set; } - [Required] - public string Surname { get; set; } - [DisplayName("Country of birth")] - public virtual Iso31661Numeric CountryOfBirth { get; set; } - [DisplayName("Birth date"), DataType(DataType.Date)] - public DateTime BirthDate { get; set; } - [DisplayName("Date of death"), DataType(DataType.Date)] - public DateTime? DeathDate { get; set; } - [Url] - public string Webpage { get; set; } - [Remote("VerifyTwitter", "People", "Admin")] - public string Twitter { get; set; } - public string Facebook { get; set; } - public Guid Photo { get; set; } - public int? DocumentPersonId { get; set; } - public string Alias { get; set; } - [DisplayName("Name to be displayed")] - public string DisplayName { get; set; } - [NotMapped, DisplayName("Name")] - public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}"; +namespace Marechai.Database.Models; - public short? CountryOfBirthId { get; set; } - public virtual ICollection Companies { get; set; } - public virtual DocumentPerson DocumentPerson { get; set; } - public virtual ICollection SoftwareFamilies { get; set; } - public virtual ICollection SoftwareVersions { get; set; } - public virtual ICollection SoftwareVariants { get; set; } - } +public class Person : BaseModel +{ + [Required] + public string Name { get; set; } + [Required] + public string Surname { get; set; } + [DisplayName("Country of birth")] + public virtual Iso31661Numeric CountryOfBirth { get; set; } + [DisplayName("Birth date")] + [DataType(DataType.Date)] + public DateTime BirthDate { get; set; } + [DisplayName("Date of death")] + [DataType(DataType.Date)] + public DateTime? DeathDate { get; set; } + [Url] + public string Webpage { get; set; } + [Remote("VerifyTwitter", "People", "Admin")] + public string Twitter { get; set; } + public string Facebook { get; set; } + public Guid Photo { get; set; } + public int? DocumentPersonId { get; set; } + public string Alias { get; set; } + [DisplayName("Name to be displayed")] + public string DisplayName { get; set; } + [NotMapped] + [DisplayName("Name")] + public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}"; + + public short? CountryOfBirthId { get; set; } + public virtual ICollection Companies { get; set; } + public virtual DocumentPerson DocumentPerson { get; set; } + public virtual ICollection SoftwareFamilies { get; set; } + public virtual ICollection SoftwareVersions { get; set; } + public virtual ICollection SoftwareVariants { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Processor.cs b/Marechai.Database/Models/Processor.cs index e5c1d54c..ebb08d09 100644 --- a/Marechai.Database/Models/Processor.cs +++ b/Marechai.Database/Models/Processor.cs @@ -29,69 +29,71 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class Processor : BaseModel { - public class Processor : BaseModel + public Processor() { - public Processor() - { - InstructionSetExtensions = new HashSet(); - ProcessorsByMachine = new HashSet(); - } - - [Required, StringLength(50)] - public string Name { get; set; } - public int? CompanyId { get; set; } - [DisplayName("Model code"), StringLength(45)] - public string ModelCode { get; set; } - [DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)] - public DateTime? Introduced { get; set; } - [DisplayName("Instruction set")] - public int? InstructionSetId { get; set; } - [DisplayName("Nominal speed (MHz)")] - public double? Speed { get; set; } - [StringLength(45)] - public string Package { get; set; } - [DisplayName("General Purpose Registers")] - public int? Gprs { get; set; } - [DisplayName("General Purporse Register size")] - public int? GprSize { get; set; } - [DisplayName("Floating Point Registers")] - public int? Fprs { get; set; } - [DisplayName("Floating Point Register Size")] - public int? FprSize { get; set; } - public int? Cores { get; set; } - [DisplayName("Threads per core")] - public int? ThreadsPerCore { get; set; } - [StringLength(45)] - public string Process { get; set; } - [DisplayName("Process (nm)")] - public float? ProcessNm { get; set; } - [DisplayName("Die size (mm²)")] - public float? DieSize { get; set; } - public long? Transistors { get; set; } - [DisplayName("Data bus size")] - public int? DataBus { get; set; } - [DisplayName("Address bus size")] - public int? AddrBus { get; set; } - [DisplayName("SIMD registers")] - public int? SimdRegisters { get; set; } - [DisplayName("SIMD register size")] - public int? SimdSize { get; set; } - [DisplayName("L1 instruction cache (KiB)")] - public float? L1Instruction { get; set; } - [DisplayName("L1 data cache (KiB)")] - public float? L1Data { get; set; } - [DisplayName("L2 cache (KiB)")] - public float? L2 { get; set; } - [DisplayName("L3 cache (KiB)")] - public float? L3 { get; set; } - - public virtual Company Company { get; set; } - [DisplayName("Instruction set")] - public virtual InstructionSet InstructionSet { get; set; } - public virtual ICollection InstructionSetExtensions { get; set; } - public virtual ICollection ProcessorsByMachine { get; set; } - public virtual ICollection Software { get; set; } + InstructionSetExtensions = new HashSet(); + ProcessorsByMachine = new HashSet(); } + + [Required] + [StringLength(50)] + public string Name { get; set; } + public int? CompanyId { get; set; } + [DisplayName("Model code")] + [StringLength(45)] + public string ModelCode { get; set; } + [DisplayFormat(DataFormatString = "{0:d}")] + [DataType(DataType.Date)] + public DateTime? Introduced { get; set; } + [DisplayName("Instruction set")] + public int? InstructionSetId { get; set; } + [DisplayName("Nominal speed (MHz)")] + public double? Speed { get; set; } + [StringLength(45)] + public string Package { get; set; } + [DisplayName("General Purpose Registers")] + public int? Gprs { get; set; } + [DisplayName("General Purporse Register size")] + public int? GprSize { get; set; } + [DisplayName("Floating Point Registers")] + public int? Fprs { get; set; } + [DisplayName("Floating Point Register Size")] + public int? FprSize { get; set; } + public int? Cores { get; set; } + [DisplayName("Threads per core")] + public int? ThreadsPerCore { get; set; } + [StringLength(45)] + public string Process { get; set; } + [DisplayName("Process (nm)")] + public float? ProcessNm { get; set; } + [DisplayName("Die size (mm²)")] + public float? DieSize { get; set; } + public long? Transistors { get; set; } + [DisplayName("Data bus size")] + public int? DataBus { get; set; } + [DisplayName("Address bus size")] + public int? AddrBus { get; set; } + [DisplayName("SIMD registers")] + public int? SimdRegisters { get; set; } + [DisplayName("SIMD register size")] + public int? SimdSize { get; set; } + [DisplayName("L1 instruction cache (KiB)")] + public float? L1Instruction { get; set; } + [DisplayName("L1 data cache (KiB)")] + public float? L1Data { get; set; } + [DisplayName("L2 cache (KiB)")] + public float? L2 { get; set; } + [DisplayName("L3 cache (KiB)")] + public float? L3 { get; set; } + + public virtual Company Company { get; set; } + [DisplayName("Instruction set")] + public virtual InstructionSet InstructionSet { get; set; } + public virtual ICollection InstructionSetExtensions { get; set; } + public virtual ICollection ProcessorsByMachine { get; set; } + public virtual ICollection Software { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/ProcessorsByMachine.cs b/Marechai.Database/Models/ProcessorsByMachine.cs index 1cdba615..bc4ea182 100644 --- a/Marechai.Database/Models/ProcessorsByMachine.cs +++ b/Marechai.Database/Models/ProcessorsByMachine.cs @@ -25,16 +25,15 @@ using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class ProcessorsByMachine : BaseModel - { - public int ProcessorId { get; set; } - public int MachineId { get; set; } - [DisplayName("Speed (MHz)")] - public float? Speed { get; set; } +namespace Marechai.Database.Models; - public virtual Machine Machine { get; set; } - public virtual Processor Processor { get; set; } - } +public class ProcessorsByMachine : BaseModel +{ + public int ProcessorId { get; set; } + public int MachineId { get; set; } + [DisplayName("Speed (MHz)")] + public float? Speed { get; set; } + + public virtual Machine Machine { get; set; } + public virtual Processor Processor { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/ProcessorsByOwnedMachine.cs b/Marechai.Database/Models/ProcessorsByOwnedMachine.cs index d16ca68a..343e497d 100644 --- a/Marechai.Database/Models/ProcessorsByOwnedMachine.cs +++ b/Marechai.Database/Models/ProcessorsByOwnedMachine.cs @@ -25,16 +25,15 @@ using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class ProcessorsByOwnedMachine : BaseModel - { - public int ProcessorId { get; set; } - public long OwnedMachineId { get; set; } - [DisplayName("Speed (MHz)")] - public float Speed { get; set; } +namespace Marechai.Database.Models; - public virtual OwnedMachine OwnedMachine { get; set; } - public virtual Processor Processor { get; set; } - } +public class ProcessorsByOwnedMachine : BaseModel +{ + public int ProcessorId { get; set; } + public long OwnedMachineId { get; set; } + [DisplayName("Speed (MHz)")] + public float Speed { get; set; } + + public virtual OwnedMachine OwnedMachine { get; set; } + public virtual Processor Processor { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/ProcessorsBySoftwareVariant.cs b/Marechai.Database/Models/ProcessorsBySoftwareVariant.cs index d5290e0d..a6b8f8c9 100644 --- a/Marechai.Database/Models/ProcessorsBySoftwareVariant.cs +++ b/Marechai.Database/Models/ProcessorsBySoftwareVariant.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class ProcessorsBySoftwareVariant : BaseModel { - public class ProcessorsBySoftwareVariant : BaseModel - { - [Required] - public virtual Processor Processor { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - public float? Speed { get; set; } - public bool? Minimum { get; set; } - public bool? Recommended { get; set; } - } + [Required] + public virtual Processor Processor { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } + public float? Speed { get; set; } + public bool? Minimum { get; set; } + public bool? Recommended { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/RequiredOperatingSystemsBySofwareVariant.cs b/Marechai.Database/Models/RequiredOperatingSystemsBySofwareVariant.cs index a0c564e8..e547b6f2 100644 --- a/Marechai.Database/Models/RequiredOperatingSystemsBySofwareVariant.cs +++ b/Marechai.Database/Models/RequiredOperatingSystemsBySofwareVariant.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class RequiredOperatingSystemsBySofwareVariant : BaseModel - { - [Required] - public virtual SoftwareVersion OperatingSystem { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } +namespace Marechai.Database.Models; - public ulong OperatingSystemId { get; set; } - public ulong SoftwareVariantId { get; set; } - } +public class RequiredOperatingSystemsBySofwareVariant : BaseModel +{ + [Required] + public virtual SoftwareVersion OperatingSystem { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } + + public ulong OperatingSystemId { get; set; } + public ulong SoftwareVariantId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/RequiredSoftwareBySoftwareVariant.cs b/Marechai.Database/Models/RequiredSoftwareBySoftwareVariant.cs index 1ff9fd10..fb098885 100644 --- a/Marechai.Database/Models/RequiredSoftwareBySoftwareVariant.cs +++ b/Marechai.Database/Models/RequiredSoftwareBySoftwareVariant.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class RequiredSoftwareBySoftwareVariant : BaseModel - { - [Required] - public virtual SoftwareVersion SoftwareVersion { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } +namespace Marechai.Database.Models; - public ulong SoftwareVersionId { get; set; } - public ulong SoftwareVariantId { get; set; } - } +public class RequiredSoftwareBySoftwareVariant : BaseModel +{ + [Required] + public virtual SoftwareVersion SoftwareVersion { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } + + public ulong SoftwareVersionId { get; set; } + public ulong SoftwareVariantId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Resolution.cs b/Marechai.Database/Models/Resolution.cs index 30506820..a3c23c36 100644 --- a/Marechai.Database/Models/Resolution.cs +++ b/Marechai.Database/Models/Resolution.cs @@ -27,29 +27,32 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class Resolution : BaseModel { - public class Resolution : BaseModel - { - public Resolution() => ResolutionsByGpu = new HashSet(); + public Resolution() => ResolutionsByGpu = new HashSet(); - [Required, Range(1, 131072)] - public int Width { get; set; } - [Required, Range(1, 131072)] - public int Height { get; set; } - [Range(2, 281474976710656)] - public long? Colors { get; set; } - [Range(2, 281474976710656)] - public long? Palette { get; set; } - [DisplayName("Character based"), DefaultValue(false)] - public bool Chars { get; set; } - [DisplayName("Grayscale"), DefaultValue(false)] - public bool Grayscale { get; set; } + [Required] + [Range(1, 131072)] + public int Width { get; set; } + [Required] + [Range(1, 131072)] + public int Height { get; set; } + [Range(2, 281474976710656)] + public long? Colors { get; set; } + [Range(2, 281474976710656)] + public long? Palette { get; set; } + [DisplayName("Character based")] + [DefaultValue(false)] + public bool Chars { get; set; } + [DisplayName("Grayscale")] + [DefaultValue(false)] + public bool Grayscale { get; set; } - public virtual ICollection ResolutionsByGpu { get; set; } - public virtual ICollection ResolutionsByScreen { get; set; } - public virtual ICollection Screens { get; set; } + public virtual ICollection ResolutionsByGpu { get; set; } + public virtual ICollection ResolutionsByScreen { get; set; } + public virtual ICollection Screens { get; set; } - public long? PaletteView => Palette ?? Colors; - } + public long? PaletteView => Palette ?? Colors; } \ No newline at end of file diff --git a/Marechai.Database/Models/ResolutionsByGpu.cs b/Marechai.Database/Models/ResolutionsByGpu.cs index 46fdc136..0e28245e 100644 --- a/Marechai.Database/Models/ResolutionsByGpu.cs +++ b/Marechai.Database/Models/ResolutionsByGpu.cs @@ -26,17 +26,16 @@ using System.ComponentModel; using Microsoft.AspNetCore.Mvc; -namespace Marechai.Database.Models -{ - public class ResolutionsByGpu : BaseModel - { - [Remote("VerifyUnique", "ResolutionsByGpu", "Admin", AdditionalFields = nameof(ResolutionId))] - public int GpuId { get; set; } - [Remote("VerifyUnique", "ResolutionsByGpu", "Admin", AdditionalFields = nameof(GpuId))] - public int ResolutionId { get; set; } +namespace Marechai.Database.Models; - [DisplayName("GPU")] - public virtual Gpu Gpu { get; set; } - public virtual Resolution Resolution { get; set; } - } +public class ResolutionsByGpu : BaseModel +{ + [Remote("VerifyUnique", "ResolutionsByGpu", "Admin", AdditionalFields = nameof(ResolutionId))] + public int GpuId { get; set; } + [Remote("VerifyUnique", "ResolutionsByGpu", "Admin", AdditionalFields = nameof(GpuId))] + public int ResolutionId { get; set; } + + [DisplayName("GPU")] + public virtual Gpu Gpu { get; set; } + public virtual Resolution Resolution { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/ResolutionsByScreen.cs b/Marechai.Database/Models/ResolutionsByScreen.cs index d24be162..6e5c76e5 100644 --- a/Marechai.Database/Models/ResolutionsByScreen.cs +++ b/Marechai.Database/Models/ResolutionsByScreen.cs @@ -25,16 +25,15 @@ using Microsoft.AspNetCore.Mvc; -namespace Marechai.Database.Models -{ - public class ResolutionsByScreen : BaseModel - { - [Remote("VerifyUnique", "ResolutionsByScreen", "Admin", AdditionalFields = nameof(ResolutionId))] - public int ScreenId { get; set; } - [Remote("VerifyUnique", "ResolutionsByScreen", "Admin", AdditionalFields = nameof(ScreenId))] - public int ResolutionId { get; set; } +namespace Marechai.Database.Models; - public virtual Screen Screen { get; set; } - public virtual Resolution Resolution { get; set; } - } +public class ResolutionsByScreen : BaseModel +{ + [Remote("VerifyUnique", "ResolutionsByScreen", "Admin", AdditionalFields = nameof(ResolutionId))] + public int ScreenId { get; set; } + [Remote("VerifyUnique", "ResolutionsByScreen", "Admin", AdditionalFields = nameof(ScreenId))] + public int ResolutionId { get; set; } + + public virtual Screen Screen { get; set; } + public virtual Resolution Resolution { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/Screen.cs b/Marechai.Database/Models/Screen.cs index f2c08f40..e58d0ab8 100644 --- a/Marechai.Database/Models/Screen.cs +++ b/Marechai.Database/Models/Screen.cs @@ -27,26 +27,29 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class Screen : BaseModel - { - [Range(1, 131072), DisplayName("Width (mm)")] - public double? Width { get; set; } - [Range(1, 131072), DisplayName("Height (mm)")] - public double? Height { get; set; } - [Required, DisplayName("Diagonal (inches)")] - public double Diagonal { get; set; } - [DisplayName("Native resolution")] - public virtual Resolution NativeResolution { get; set; } - [Range(2, 281474976710656), DisplayName("Effective colors")] - public long? EffectiveColors { get; set; } - [Required] - public string Type { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection Resolutions { get; set; } - public virtual ICollection ScreensByMachines { get; set; } - [Required] - public int NativeResolutionId { get; set; } - } +public class Screen : BaseModel +{ + [Range(1, 131072)] + [DisplayName("Width (mm)")] + public double? Width { get; set; } + [Range(1, 131072)] + [DisplayName("Height (mm)")] + public double? Height { get; set; } + [Required] + [DisplayName("Diagonal (inches)")] + public double Diagonal { get; set; } + [DisplayName("Native resolution")] + public virtual Resolution NativeResolution { get; set; } + [Range(2, 281474976710656)] + [DisplayName("Effective colors")] + public long? EffectiveColors { get; set; } + [Required] + public string Type { get; set; } + + public virtual ICollection Resolutions { get; set; } + public virtual ICollection ScreensByMachines { get; set; } + [Required] + public int NativeResolutionId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/ScreensByMachine.cs b/Marechai.Database/Models/ScreensByMachine.cs index 77e357e4..56b50752 100644 --- a/Marechai.Database/Models/ScreensByMachine.cs +++ b/Marechai.Database/Models/ScreensByMachine.cs @@ -25,16 +25,15 @@ using Microsoft.AspNetCore.Mvc; -namespace Marechai.Database.Models -{ - public class ScreensByMachine : BaseModel - { - [Remote("VerifyUnique", "ScreensByMachine", "Admin", AdditionalFields = nameof(MachineId))] - public int ScreenId { get; set; } - [Remote("VerifyUnique", "ScreensByMachine", "Admin", AdditionalFields = nameof(ScreenId))] - public int MachineId { get; set; } +namespace Marechai.Database.Models; - public virtual Screen Screen { get; set; } - public virtual Machine Machine { get; set; } - } +public class ScreensByMachine : BaseModel +{ + [Remote("VerifyUnique", "ScreensByMachine", "Admin", AdditionalFields = nameof(MachineId))] + public int ScreenId { get; set; } + [Remote("VerifyUnique", "ScreensByMachine", "Admin", AdditionalFields = nameof(ScreenId))] + public int MachineId { get; set; } + + public virtual Screen Screen { get; set; } + public virtual Machine Machine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/SoftwareFamily.cs b/Marechai.Database/Models/SoftwareFamily.cs index 61744d27..b534f615 100644 --- a/Marechai.Database/Models/SoftwareFamily.cs +++ b/Marechai.Database/Models/SoftwareFamily.cs @@ -27,19 +27,18 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class SoftwareFamily : BaseModel - { - [Required] - public string Name { get; set; } - public DateTime? Introduced { get; set; } - public virtual SoftwareFamily Parent { get; set; } - public ulong? ParentId { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection Children { get; set; } - public virtual ICollection Companies { get; set; } - public virtual ICollection People { get; set; } - public virtual ICollection Versions { get; set; } - } +public class SoftwareFamily : BaseModel +{ + [Required] + public string Name { get; set; } + public DateTime? Introduced { get; set; } + public virtual SoftwareFamily Parent { get; set; } + public ulong? ParentId { get; set; } + + public virtual ICollection Children { get; set; } + public virtual ICollection Companies { get; set; } + public virtual ICollection People { get; set; } + public virtual ICollection Versions { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/SoftwareVariant.cs b/Marechai.Database/Models/SoftwareVariant.cs index bfa1bdba..7fd256fb 100644 --- a/Marechai.Database/Models/SoftwareVariant.cs +++ b/Marechai.Database/Models/SoftwareVariant.cs @@ -27,40 +27,39 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class SoftwareVariant : BaseModel - { - public string Name { get; set; } - public string Version { get; set; } - public DateTime? Introduced { get; set; } - public virtual SoftwareVariant Parent { get; set; } - [Required] - public virtual SoftwareVersion SoftwareVersion { get; set; } - public ulong? MinimumMemory { get; set; } - public ulong? RecommendedMemory { get; set; } - public ulong? RequiredStorage { get; set; } - public string PartNumber { get; set; } - public string SerialNumber { get; set; } - public string ProductCode { get; set; } - public string CatalogueNumber { get; set; } - public DistributionMode DistributionMode { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection Derivates { get; set; } - public virtual ICollection Companies { get; set; } - public virtual ICollection Gpus { get; set; } - public virtual ICollection Architectures { get; set; } - public virtual ICollection Languages { get; set; } - public virtual ICollection MachineFamilies { get; set; } - public virtual ICollection Machines { get; set; } - public virtual ICollection Media { get; set; } - public virtual ICollection People { get; set; } - public virtual ICollection Processors { get; set; } - public virtual ICollection RequiredOperatingSystems { get; set; } - public virtual ICollection RequiredSoftware { get; set; } - public virtual ICollection SupportedSound { get; set; } - public virtual ICollection Files { get; set; } - public ulong? ParentId { get; set; } - public ulong SoftwareVersionId { get; set; } - } +public class SoftwareVariant : BaseModel +{ + public string Name { get; set; } + public string Version { get; set; } + public DateTime? Introduced { get; set; } + public virtual SoftwareVariant Parent { get; set; } + [Required] + public virtual SoftwareVersion SoftwareVersion { get; set; } + public ulong? MinimumMemory { get; set; } + public ulong? RecommendedMemory { get; set; } + public ulong? RequiredStorage { get; set; } + public string PartNumber { get; set; } + public string SerialNumber { get; set; } + public string ProductCode { get; set; } + public string CatalogueNumber { get; set; } + public DistributionMode DistributionMode { get; set; } + + public virtual ICollection Derivates { get; set; } + public virtual ICollection Companies { get; set; } + public virtual ICollection Gpus { get; set; } + public virtual ICollection Architectures { get; set; } + public virtual ICollection Languages { get; set; } + public virtual ICollection MachineFamilies { get; set; } + public virtual ICollection Machines { get; set; } + public virtual ICollection Media { get; set; } + public virtual ICollection People { get; set; } + public virtual ICollection Processors { get; set; } + public virtual ICollection RequiredOperatingSystems { get; set; } + public virtual ICollection RequiredSoftware { get; set; } + public virtual ICollection SupportedSound { get; set; } + public virtual ICollection Files { get; set; } + public ulong? ParentId { get; set; } + public ulong SoftwareVersionId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/SoftwareVariantByCompilationMedia.cs b/Marechai.Database/Models/SoftwareVariantByCompilationMedia.cs index 90887630..49b97903 100644 --- a/Marechai.Database/Models/SoftwareVariantByCompilationMedia.cs +++ b/Marechai.Database/Models/SoftwareVariantByCompilationMedia.cs @@ -26,19 +26,18 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class SoftwareVariantByCompilationMedia : BaseModel - { - public string Path { get; set; } - [DefaultValue('/')] - public char PathSeparator { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - [Required] - public virtual Media Media { get; set; } +namespace Marechai.Database.Models; - public ulong SoftwareVariantId { get; set; } - public ulong MediaId { get; set; } - } +public class SoftwareVariantByCompilationMedia : BaseModel +{ + public string Path { get; set; } + [DefaultValue('/')] + public char PathSeparator { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } + [Required] + public virtual Media Media { get; set; } + + public ulong SoftwareVariantId { get; set; } + public ulong MediaId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/SoftwareVersion.cs b/Marechai.Database/Models/SoftwareVersion.cs index 5d123972..42983916 100644 --- a/Marechai.Database/Models/SoftwareVersion.cs +++ b/Marechai.Database/Models/SoftwareVersion.cs @@ -27,26 +27,25 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class SoftwareVersion : BaseModel - { - [Required] - public virtual SoftwareFamily Family { get; set; } - public string Name { get; set; } - public string Codename { get; set; } - [Required] - public string Version { get; set; } - public DateTime? Introduced { get; set; } - public virtual License License { get; set; } - public virtual SoftwareVersion Previous { get; set; } - public virtual SoftwareVersion Next { get; set; } - public virtual ICollection Companies { get; set; } - public virtual ICollection People { get; set; } - public virtual ICollection Variants { get; set; } +namespace Marechai.Database.Models; - public ulong FamilyId { get; set; } - public int? LicenseId { get; set; } - public ulong? PreviousId { get; set; } - } +public class SoftwareVersion : BaseModel +{ + [Required] + public virtual SoftwareFamily Family { get; set; } + public string Name { get; set; } + public string Codename { get; set; } + [Required] + public string Version { get; set; } + public DateTime? Introduced { get; set; } + public virtual License License { get; set; } + public virtual SoftwareVersion Previous { get; set; } + public virtual SoftwareVersion Next { get; set; } + public virtual ICollection Companies { get; set; } + public virtual ICollection People { get; set; } + public virtual ICollection Variants { get; set; } + + public ulong FamilyId { get; set; } + public int? LicenseId { get; set; } + public ulong? PreviousId { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/SoundByMachine.cs b/Marechai.Database/Models/SoundByMachine.cs index 38e91269..85c31c29 100644 --- a/Marechai.Database/Models/SoundByMachine.cs +++ b/Marechai.Database/Models/SoundByMachine.cs @@ -25,15 +25,14 @@ using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class SoundByMachine : BaseModel - { - public int SoundSynthId { get; set; } - public int MachineId { get; set; } +namespace Marechai.Database.Models; - public virtual Machine Machine { get; set; } - [DisplayName("Sound synthetizer")] - public virtual SoundSynth SoundSynth { get; set; } - } +public class SoundByMachine : BaseModel +{ + public int SoundSynthId { get; set; } + public int MachineId { get; set; } + + public virtual Machine Machine { get; set; } + [DisplayName("Sound synthetizer")] + public virtual SoundSynth SoundSynth { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/SoundByOwnedMachine.cs b/Marechai.Database/Models/SoundByOwnedMachine.cs index 4ea44139..280bb106 100644 --- a/Marechai.Database/Models/SoundByOwnedMachine.cs +++ b/Marechai.Database/Models/SoundByOwnedMachine.cs @@ -25,15 +25,14 @@ using System.ComponentModel; -namespace Marechai.Database.Models -{ - public class SoundByOwnedMachine : BaseModel - { - public int SoundSynthId { get; set; } - public long OwnedMachineId { get; set; } +namespace Marechai.Database.Models; - public virtual OwnedMachine OwnedMachine { get; set; } - [DisplayName("Sound synthetizer")] - public virtual SoundSynth SoundSynth { get; set; } - } +public class SoundByOwnedMachine : BaseModel +{ + public int SoundSynthId { get; set; } + public long OwnedMachineId { get; set; } + + public virtual OwnedMachine OwnedMachine { get; set; } + [DisplayName("Sound synthetizer")] + public virtual SoundSynth SoundSynth { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/SoundBySoftwareVariant.cs b/Marechai.Database/Models/SoundBySoftwareVariant.cs index d92337b6..25a68b22 100644 --- a/Marechai.Database/Models/SoundBySoftwareVariant.cs +++ b/Marechai.Database/Models/SoundBySoftwareVariant.cs @@ -25,13 +25,12 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class SoundBySoftwareVariant : BaseModel { - public class SoundBySoftwareVariant : BaseModel - { - [Required] - public virtual SoundSynth SoundSynth { get; set; } - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } - } + [Required] + public virtual SoundSynth SoundSynth { get; set; } + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/SoundSynth.cs b/Marechai.Database/Models/SoundSynth.cs index e1faeee8..35407806 100644 --- a/Marechai.Database/Models/SoundSynth.cs +++ b/Marechai.Database/Models/SoundSynth.cs @@ -28,33 +28,39 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +public class SoundSynth : BaseModel { - public class SoundSynth : BaseModel - { - public SoundSynth() => SoundByMachine = new HashSet(); + public SoundSynth() => SoundByMachine = new HashSet(); - [Required, StringLength(50)] - public string Name { get; set; } - public int? CompanyId { get; set; } - [DisplayName("Model code"), StringLength(45)] - public string ModelCode { get; set; } - [DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)] - public DateTime? Introduced { get; set; } - [DisplayName("PCM voices"), Range(1, int.MaxValue)] - public int? Voices { get; set; } - [DisplayName("Sample rate (Hz)")] - public double? Frequency { get; set; } - [DisplayName("Sample resolution"), Range(1, int.MaxValue)] - public int? Depth { get; set; } - [DisplayName("Square wave channels"), Range(1, int.MaxValue)] - public int? SquareWave { get; set; } - [DisplayName("White noise channels"), Range(1, int.MaxValue)] - public int? WhiteNoise { get; set; } - public int? Type { get; set; } + [Required] + [StringLength(50)] + public string Name { get; set; } + public int? CompanyId { get; set; } + [DisplayName("Model code")] + [StringLength(45)] + public string ModelCode { get; set; } + [DisplayFormat(DataFormatString = "{0:d}")] + [DataType(DataType.Date)] + public DateTime? Introduced { get; set; } + [DisplayName("PCM voices")] + [Range(1, int.MaxValue)] + public int? Voices { get; set; } + [DisplayName("Sample rate (Hz)")] + public double? Frequency { get; set; } + [DisplayName("Sample resolution")] + [Range(1, int.MaxValue)] + public int? Depth { get; set; } + [DisplayName("Square wave channels")] + [Range(1, int.MaxValue)] + public int? SquareWave { get; set; } + [DisplayName("White noise channels")] + [Range(1, int.MaxValue)] + public int? WhiteNoise { get; set; } + public int? Type { get; set; } - public virtual Company Company { get; set; } - public virtual ICollection SoundByMachine { get; set; } - public virtual ICollection Software { get; set; } - } + public virtual Company Company { get; set; } + public virtual ICollection SoundByMachine { get; set; } + public virtual ICollection Software { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/StandaloneFile.cs b/Marechai.Database/Models/StandaloneFile.cs index 793dbb0d..061998bf 100644 --- a/Marechai.Database/Models/StandaloneFile.cs +++ b/Marechai.Database/Models/StandaloneFile.cs @@ -26,13 +26,12 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class StandaloneFile : BaseFile - { - [Required] - public virtual SoftwareVariant SoftwareVariant { get; set; } +namespace Marechai.Database.Models; - public virtual ICollection DataStreams { get; set; } - } +public class StandaloneFile : BaseFile +{ + [Required] + public virtual SoftwareVariant SoftwareVariant { get; set; } + + public virtual ICollection DataStreams { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/StorageByMachine.cs b/Marechai.Database/Models/StorageByMachine.cs index b865a2f7..c84858de 100644 --- a/Marechai.Database/Models/StorageByMachine.cs +++ b/Marechai.Database/Models/StorageByMachine.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class StorageByMachine : BaseModel - { - public int MachineId { get; set; } - public StorageType Type { get; set; } - public StorageInterface Interface { get; set; } - [Range(1, long.MaxValue)] - public long? Capacity { get; set; } +namespace Marechai.Database.Models; - public virtual Machine Machine { get; set; } - } +public class StorageByMachine : BaseModel +{ + public int MachineId { get; set; } + public StorageType Type { get; set; } + public StorageInterface Interface { get; set; } + [Range(1, long.MaxValue)] + public long? Capacity { get; set; } + + public virtual Machine Machine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/StorageByOwnedMachine.cs b/Marechai.Database/Models/StorageByOwnedMachine.cs index 5c2c7b5f..37638c72 100644 --- a/Marechai.Database/Models/StorageByOwnedMachine.cs +++ b/Marechai.Database/Models/StorageByOwnedMachine.cs @@ -25,16 +25,15 @@ using System.ComponentModel.DataAnnotations; -namespace Marechai.Database.Models -{ - public class StorageByOwnedMachine : BaseModel - { - public long OwnedMachineId { get; set; } - public StorageType Type { get; set; } - public StorageInterface Interface { get; set; } - [Range(1, long.MaxValue)] - public long Capacity { get; set; } +namespace Marechai.Database.Models; - public virtual OwnedMachine OwnedMachine { get; set; } - } +public class StorageByOwnedMachine : BaseModel +{ + public long OwnedMachineId { get; set; } + public StorageType Type { get; set; } + public StorageInterface Interface { get; set; } + [Range(1, long.MaxValue)] + public long Capacity { get; set; } + + public virtual OwnedMachine OwnedMachine { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Models/VariableBlockSize.cs b/Marechai.Database/Models/VariableBlockSize.cs index 93edb7e6..65d4d7c7 100644 --- a/Marechai.Database/Models/VariableBlockSize.cs +++ b/Marechai.Database/Models/VariableBlockSize.cs @@ -23,13 +23,12 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Models +namespace Marechai.Database.Models; + +// Not for a table +public class VariableBlockSize { - // Not for a table - public class VariableBlockSize - { - public ulong Start { get; set; } - public ulong End { get; set; } - public uint Size { get; set; } - } + public ulong Start { get; set; } + public ulong End { get; set; } + public uint Size { get; set; } } \ No newline at end of file diff --git a/Marechai.Database/Mysql.cs b/Marechai.Database/Mysql.cs index f47a1d49..4a20222a 100644 --- a/Marechai.Database/Mysql.cs +++ b/Marechai.Database/Mysql.cs @@ -27,101 +27,96 @@ using System; using System.Data; using MySqlConnector; -namespace Marechai.Database +namespace Marechai.Database; + +public class Mysql : IDbCore { - public class Mysql : IDbCore + MySqlConnection _connection; + + /// Database operations + public Operations Operations { get; private set; } + + /// Last inserted row's ID + public long LastInsertRowId { - MySqlConnection connection; - - /// Database operations - public Operations Operations { get; private set; } - - /// Last inserted row's ID - public long LastInsertRowId + get { - get - { - MySqlCommand command = connection.CreateCommand(); - command.CommandText = "SELECT LAST_INSERT_ID()"; - IDataReader reader = command.ExecuteReader(); + MySqlCommand command = _connection.CreateCommand(); + command.CommandText = "SELECT LAST_INSERT_ID()"; + IDataReader reader = command.ExecuteReader(); - if(reader == null || - !reader.Read()) - return 0; + if(reader == null || !reader.Read()) return 0; - long id = reader.GetInt64(0); - reader.Close(); - - return id; - } - } - - /// Opens an existing database - /// Server - /// User - /// Database name - /// Password - /// Port - /// true if database opened correctly, false otherwise - public bool OpenDb(string server, string user, string database, string password, ushort port = 3306) - { - try - { - string connectionString = - $"server={server};user={user};database={database};port={port};password={password}"; - - connection = new MySqlConnection(connectionString); - connection.Open(); - - Operations = new Operations(connection, this); - - bool res = Operations.UpdateDatabase(); - - if(res) - return true; - - connection = null; - - return false; - } - catch(MySqlException ex) - { - Console.WriteLine("Error opening database."); - Console.WriteLine(ex); - connection = null; - - return false; - } - } - - /// Closes the database - public void CloseDb() - { - connection?.Close(); - connection = null; - } - - /// Gets a data adapter for the opened database - /// Data adapter - public IDbDataAdapter GetNewDataAdapter() => new MySqlDataAdapter(); - - public bool TableExists(string tableName) - { - MySqlCommand cmd = connection.CreateCommand(); - - cmd.CommandText = - $"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{connection.Database}' AND table_name = '{tableName}'"; - - MySqlDataReader reader = cmd.ExecuteReader(); - - reader.Read(); - - int count = reader.GetInt32(0); + long id = reader.GetInt64(0); reader.Close(); - return count > 0; + return id; } - - ~Mysql() => CloseDb(); } + + /// Opens an existing database + /// Server + /// User + /// Database name + /// Password + /// Port + /// true if database opened correctly, false otherwise + public bool OpenDb(string server, string user, string database, string password, ushort port = 3306) + { + try + { + var connectionString = $"server={server};user={user};database={database};port={port};password={password}"; + + _connection = new MySqlConnection(connectionString); + _connection.Open(); + + Operations = new Operations(_connection, this); + + bool res = Operations.UpdateDatabase(); + + if(res) return true; + + _connection = null; + + return false; + } + catch(MySqlException ex) + { + Console.WriteLine("Error opening database."); + Console.WriteLine(ex); + _connection = null; + + return false; + } + } + + /// Closes the database + public void CloseDb() + { + _connection?.Close(); + _connection = null; + } + + /// Gets a data adapter for the opened database + /// Data adapter + public IDbDataAdapter GetNewDataAdapter() => new MySqlDataAdapter(); + + public bool TableExists(string tableName) + { + MySqlCommand cmd = _connection.CreateCommand(); + + cmd.CommandText = + $"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{_connection.Database}' AND table_name = '{tableName}'"; + + MySqlDataReader reader = cmd.ExecuteReader(); + + reader.Read(); + + int count = reader.GetInt32(0); + reader.Close(); + + return count > 0; + } + + ~Mysql() => CloseDb(); } \ No newline at end of file diff --git a/Marechai.Database/Operations/Operations.cs b/Marechai.Database/Operations/Operations.cs index d12d7b33..b9e5f50d 100644 --- a/Marechai.Database/Operations/Operations.cs +++ b/Marechai.Database/Operations/Operations.cs @@ -25,28 +25,18 @@ using System.Data; -namespace Marechai.Database +namespace Marechai.Database; + +public partial class Operations(IDbConnection connection, IDbCore core) { - public partial class Operations - { - /// Last known database version - const int DB_VERSION = 24; - public const int DbVersionEntityFramework = 1984; - /// The column with this value indicates there is no item of this type. - public const int DB_NONE = -1; - /// - /// This value indicates there's no processing unit, but a direct memory connection (a framebuffer or sound - /// buffer). - /// - public const int DB_SOFTWARE = -2; - - readonly IDbConnection dbCon; - readonly IDbCore dbCore; - - public Operations(IDbConnection connection, IDbCore core) - { - dbCon = connection; - dbCore = core; - } - } + /// Last known database version + const int DB_VERSION = 24; + public const int DbVersionEntityFramework = 1984; + /// The column with this value indicates there is no item of this type. + public const int DbNone = -1; + /// + /// This value indicates there's no processing unit, but a direct memory connection (a framebuffer or sound + /// buffer). + /// + public const int DbSoftware = -2; } \ No newline at end of file diff --git a/Marechai.Database/Operations/Update.cs b/Marechai.Database/Operations/Update.cs index 62ce96b4..cd01077e 100644 --- a/Marechai.Database/Operations/Update.cs +++ b/Marechai.Database/Operations/Update.cs @@ -29,2832 +29,21 @@ using System.Data; using System.IO; using Marechai.Database.Schemas.Sql; -namespace Marechai.Database +namespace Marechai.Database; + +public partial class Operations { - public partial class Operations + /// Updates opened database to last known version + /// true if updated correctly, false otherwise + public bool UpdateDatabase() { - /// Updates opened database to last known version - /// true if updated correctly, false otherwise - public bool UpdateDatabase() + bool dbV2 = !core.TableExists("marechai_db"); + var currentDbVersion = 2; + + if(!dbV2) { - bool dbV2 = !dbCore.TableExists("marechai_db"); - int currentDbVersion = 2; - - if(!dbV2) - { - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * FROM marechai_db"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - int newId = int.Parse(dataRow["version"].ToString()); - - if(newId > currentDbVersion) - currentDbVersion = newId; - } - } - - Console.WriteLine("Database version: {0}", currentDbVersion); - - if(currentDbVersion > DB_VERSION) - { - Console.WriteLine("Current database version is higher than last supported version {0}, cannot continue...", - DB_VERSION); - - return false; - } - - if(currentDbVersion == DB_VERSION) - return true; - - for(int i = currentDbVersion; i < DB_VERSION; i++) - switch(i) - { - case 2: - { - UpdateDatabaseToV3(); - - break; - } - case 3: - { - UpdateDatabaseToV4(); - - break; - } - case 4: - { - UpdateDatabaseToV5(); - - break; - } - case 5: - { - UpdateDatabaseToV6(); - - break; - } - case 6: - { - UpdateDatabaseToV7(); - - break; - } - case 7: - { - UpdateDatabaseToV8(); - - break; - } - case 8: - { - UpdateDatabaseToV9(); - - break; - } - case 9: - { - UpdateDatabaseToV10(); - - break; - } - case 10: - { - UpdateDatabaseToV11(); - - break; - } - case 11: - { - UpdateDatabaseToV12(); - - break; - } - case 12: - { - UpdateDatabaseToV13(); - - break; - } - case 13: - { - UpdateDatabaseToV14(); - - break; - } - case 14: - { - UpdateDatabaseToV15(); - - break; - } - case 15: - { - UpdateDatabaseToV16(); - - break; - } - case 16: - { - UpdateDatabaseToV17(); - - break; - } - case 17: - { - UpdateDatabaseToV18(); - - break; - } - case 18: - { - UpdateDatabaseToV19(); - - break; - } - case 19: - { - UpdateDatabaseToV20(); - - break; - } - case 20: - { - UpdateDatabaseToV21(); - - break; - } - case 21: - { - UpdateDatabaseToV22(); - - break; - } - case 22: - { - UpdateDatabaseToV23(); - - break; - } - case 23: - { - UpdateVersionToEntityFramework(); - - break; - } - } - - OptimizeDatabase(); - - return true; - } - - void UpdateDatabaseToV3() - { - Console.WriteLine("Updating database to version 3"); - - Console.WriteLine("Creating versioning table"); - IDbCommand dbCmd = dbCon.CreateCommand(); - - dbCmd.CommandText = @"CREATE TABLE `marechai_db` ( - `id` INT NOT NULL AUTO_INCREMENT, - `version` INT NOT NULL, - `updated` DATETIME DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) )"; - - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming table `admin` to `admins`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `admin` RENAME TO `admins`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `browser_test.idstring` to `browser_test.user_agent`"); - dbCmd = dbCon.CreateCommand(); - - dbCmd.CommandText = - @"ALTER TABLE `browser_test` CHANGE COLUMN `idstring` `user_agent` varchar(128) NOT NULL DEFAULT '';"; - - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming table `browser_test` to `browser_tests`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `browser_test` RENAME TO `browser_tests`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `Companias.Compania` to `Companias.name`"); - dbCmd = dbCon.CreateCommand(); - - dbCmd.CommandText = - @"ALTER TABLE `Companias` CHANGE COLUMN `Compania` `name` varchar(128) NOT NULL DEFAULT '';"; - - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming table `Companias` to `companies`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `Companias` RENAME TO `companies`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `computers.spu` to `computers.sound_synth`"); - dbCmd = dbCon.CreateCommand(); - - dbCmd.CommandText = - @"ALTER TABLE `computers` CHANGE COLUMN `spu` `sound_synth` int(11) NOT NULL DEFAULT '0'"; - - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming column `computers.mpu` to `music_synth.name`"); - dbCmd = dbCon.CreateCommand(); - - dbCmd.CommandText = - @"ALTER TABLE `computers` CHANGE COLUMN `mpu` `music_synth` int(11) NOT NULL DEFAULT '0'"; - - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Dropping column `computers.comment`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `computers` DROP COLUMN `comment`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `consoles.name` to `consoles.model`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `consoles` CHANGE COLUMN `name` `model` char(50) NOT NULL DEFAULT ''"; - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming column `consoles.spu` to `consoles.sound_synth`"); - dbCmd = dbCon.CreateCommand(); - - dbCmd.CommandText = - @"ALTER TABLE `consoles` CHANGE COLUMN `spu` `sound_synth` int(11) NOT NULL DEFAULT '0'"; - - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming column `consoles.mpu` to `consoles.music_synth`"); - dbCmd = dbCon.CreateCommand(); - - dbCmd.CommandText = - @"ALTER TABLE `consoles` CHANGE COLUMN `mpu` `music_synth` int(11) NOT NULL DEFAULT '0'"; - - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Dropping column `consoles.comments`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `consoles` DROP COLUMN `comments`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `cpu.cpu` to `cpu.name`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `cpu` CHANGE COLUMN `cpu` `name` char(50) NOT NULL DEFAULT ''"; - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming table `cpu` to `processors`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `cpu` RENAME TO `processors`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `DSPs.DSP` to `DSPs.name`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `DSPs` CHANGE COLUMN `DSP` `name` char(50) NOT NULL DEFAULT ''"; - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming table `DSPs` to `sound_synths`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `DSPs` RENAME TO `sound_synths`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `Formatos_de_disco.Format` to `Formatos_de_disco.description`"); - dbCmd = dbCon.CreateCommand(); - - dbCmd.CommandText = - @"ALTER TABLE `Formatos_de_disco` CHANGE COLUMN `Format` `description` char(50) NOT NULL DEFAULT ''"; - - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming table `Formatos_de_disco` to `disk_formats`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `Formatos_de_disco` RENAME TO `disk_formats`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `gpus.gpu` to `gpus.name`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `gpus` CHANGE COLUMN `gpu` `name` char(128) NOT NULL DEFAULT ''"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming table `money_donation` to `money_donations`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `money_donation` RENAME TO `money_donations`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming column `mpus.mpu` to `mpus.name`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `mpus` CHANGE COLUMN `mpu` `name` char(50) NOT NULL DEFAULT ''"; - dbCmd.ExecuteNonQuery(); - Console.WriteLine("Renaming table `mpus` to `music_synths`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `mpus` RENAME TO `music_synths`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming table `own_computer` to `owned_computers`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `own_computer` RENAME TO `owned_computers`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Renaming table `own_consoles` to `owned_consoles`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"ALTER TABLE `own_consoles` RENAME TO `owned_consoles`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Dropping table `procesadores_principales`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"DROP TABLE `procesadores_principales`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Getting all items from `console_company`"); - - Dictionary consoleCompanies = new(); - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from console_company"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - consoleCompanies.Add(int.Parse(dataRow["id"].ToString()), dataRow["company"].ToString()); - - Dictionary conversionEquivalents = new(); - IDbTransaction trans; - - Console.WriteLine("Converting all items from `console_company` to `companies`"); - - foreach(KeyValuePair consoleCompany in consoleCompanies) - { - dbCmd = dbCon.CreateCommand(); - dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = $"SELECT * from companies WHERE name LIKE '{consoleCompany.Value}'"; - dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - if(dataSet.Tables[0].Rows.Count == 1) - { - Console.WriteLine("Converting console company `{0}` to company `{1}`", consoleCompany.Value, - dataSet.Tables[0].Rows[0]["name"]); - - conversionEquivalents.Add(consoleCompany.Key, - int.Parse(dataSet.Tables[0].Rows[0]["id"].ToString())); - } - else - { - Console.Write("Adding new company `{0}`... ", consoleCompany.Value); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = $"INSERT INTO companies (name) VALUES ('{consoleCompany.Value}')"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - long id = dbCore.LastInsertRowId; - Console.WriteLine("got id {0}", id); - conversionEquivalents.Add(consoleCompany.Key, (int)id); - } - } - - Console.WriteLine("Getting all items from `consoles`"); - Dictionary consoleIdAndCompanyId = new(); - dbCmd = dbCon.CreateCommand(); - dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT id,company from consoles"; - dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - consoleIdAndCompanyId.Add(int.Parse(dataRow["id"].ToString()), - int.Parse(dataRow["company"].ToString())); - - trans = dbCon.BeginTransaction(); - - foreach(KeyValuePair keyValuePair in consoleIdAndCompanyId) - { - conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId); - - Console.WriteLine("Converting console company {0} to company {1} for console {2}... ", - keyValuePair.Value, newId, keyValuePair.Key); - - dbCmd = dbCon.CreateCommand(); - dbCmd.Transaction = trans; - dbCmd.CommandText = $"UPDATE consoles SET company = {newId} WHERE id = {keyValuePair.Key}"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - Console.WriteLine("Comitting changes..."); - trans.Commit(); - - Console.WriteLine("Moving company logos..."); - - foreach(string file in Directory.GetFiles("wwwroot/assets/logos/computers/", "*", - SearchOption.TopDirectoryOnly)) - { - string newPath = Path.Combine("wwwroot/assets/logos/", Path.GetFileName(file)); - Console.WriteLine("Moving {0} to {1}...", file, newPath); - File.Move(file, newPath); - } - - Console.WriteLine("Removing old computer company logos directory..."); - Directory.Delete("wwwroot/assets/logos/computers"); - - Console.WriteLine("Moving console company logos..."); - - foreach(string file in Directory.GetFiles("wwwroot/assets/logos/consoles/", "*", - SearchOption.TopDirectoryOnly)) - { - string oldNameWithoutExtension = Path.GetFileNameWithoutExtension(file); - - if(!int.TryParse(oldNameWithoutExtension, out int oldId)) - { - Console.WriteLine("Removing stray file {0}...", file); - File.Delete(file); - - continue; - } - - conversionEquivalents.TryGetValue(oldId, out int newId); - string extension = Path.GetExtension(file); - - string newPath = Path.Combine("wwwroot/assets/logos/", $"{newId}{extension}"); - - if(File.Exists(newPath)) - { - Console.WriteLine("Removing duplicate file {0}...", file); - File.Delete(file); - } - else - { - Console.WriteLine("Moving {0} to {1}...", file, newPath); - File.Move(file, newPath); - } - } - - Console.WriteLine("Removing old console company logos directory..."); - Directory.Delete("wwwroot/assets/logos/consoles"); - - Console.WriteLine("Dropping table `console_company`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = @"DROP TABLE `console_company`;"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Setting new database version to 3..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = @"INSERT INTO marechai_db (version) VALUES ('3')"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Finished update version to 3..."); - } - - void UpdateDatabaseToV4() - { - Console.WriteLine("Updating database to version 4"); - IDbCommand dbCmd; - IDbTransaction trans; - - if(dbCore is Mysql) - { - Console.WriteLine("Changing table formats..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `admins` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `browser_tests` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `marechai_db` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `companies` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `computers` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `consoles` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `disk_formats` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `forbidden` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `gpus` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `log` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `money_donations` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `music_synths` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `news` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `owned_computers` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `owned_consoles` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `processors` ROW_FORMAT = DYNAMIC;\n" + - "ALTER TABLE `sound_synths` ROW_FORMAT = DYNAMIC;\n"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - } - - Console.WriteLine("Correcting primary key on table `processors`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "ALTER TABLE `processors` ADD PRIMARY KEY (id);\n" + "DROP INDEX id ON processors"; - dbCmd.ExecuteNonQuery(); - - Console.WriteLine("Creating indexes on `admins`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX idx_admins_user ON admins (user);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `browser_tests`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_browser_tests_user_agent ON browser_tests (user_agent);\n" + - "CREATE INDEX idx_browser_tests_browser ON browser_tests (browser);\n" + - "CREATE INDEX idx_browser_tests_version ON browser_tests (version);\n" + - "CREATE INDEX idx_browser_tests_os ON browser_tests (os);\n" + - "CREATE INDEX idx_browser_tests_platform ON browser_tests (platform);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `companies`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX idx_companies_name ON companies (name);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `computers`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_computers_company ON computers (company);\n" + - "CREATE INDEX idx_computers_year ON computers (year);\n" + - "CREATE INDEX idx_computers_model ON computers (model);\n" + - "CREATE INDEX idx_computers_cpu1 ON computers (cpu1);\n" + - "CREATE INDEX idx_computers_cpu2 ON computers (cpu2);\n" + - "CREATE INDEX idx_computers_mhz1 ON computers (mhz1);\n" + - "CREATE INDEX idx_computers_mhz2 ON computers (mhz2);\n" + - "CREATE INDEX idx_computers_bits ON computers (bits);\n" + - "CREATE INDEX idx_computers_ram ON computers (ram);\n" + - "CREATE INDEX idx_computers_rom ON computers (rom);\n" + - "CREATE INDEX idx_computers_gpu ON computers (gpu);\n" + - "CREATE INDEX idx_computers_vram ON computers (vram);\n" + - "CREATE INDEX idx_computers_colors ON computers (colors);\n" + - "CREATE INDEX idx_computers_res ON computers (res);\n" + - "CREATE INDEX idx_computers_sound_synth ON computers (sound_synth);\n" + - "CREATE INDEX idx_computers_music_synth ON computers (music_synth);\n" + - "CREATE INDEX idx_computers_hdd1 ON computers (hdd1);\n" + - "CREATE INDEX idx_computers_hdd2 ON computers (hdd2);\n" + - "CREATE INDEX idx_computers_hdd3 ON computers (hdd3);\n" + - "CREATE INDEX idx_computers_disk1 ON computers (disk1);\n" + - "CREATE INDEX idx_computers_disk2 ON computers (disk2);\n" + - "CREATE INDEX idx_computers_cap1 ON computers (cap1);\n" + - "CREATE INDEX idx_computers_cap2 ON computers (cap2);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `consoles`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_consoles_company ON consoles (company);\n" + - "CREATE INDEX idx_consoles_year ON consoles (year);\n" + - "CREATE INDEX idx_consoles_model ON consoles (model);\n" + - "CREATE INDEX idx_consoles_cpu1 ON consoles (cpu1);\n" + - "CREATE INDEX idx_consoles_cpu2 ON consoles (cpu2);\n" + - "CREATE INDEX idx_consoles_mhz1 ON consoles (mhz1);\n" + - "CREATE INDEX idx_consoles_mhz2 ON consoles (mhz2);\n" + - "CREATE INDEX idx_consoles_bits ON consoles (bits);\n" + - "CREATE INDEX idx_consoles_ram ON consoles (ram);\n" + - "CREATE INDEX idx_consoles_rom ON consoles (rom);\n" + - "CREATE INDEX idx_consoles_gpu ON consoles (gpu);\n" + - "CREATE INDEX idx_consoles_vram ON consoles (vram);\n" + - "CREATE INDEX idx_consoles_colors ON consoles (colors);\n" + - "CREATE INDEX idx_consoles_res ON consoles (res);\n" + - "CREATE INDEX idx_consoles_sound_synth ON consoles (sound_synth);\n" + - "CREATE INDEX idx_consoles_music_synth ON consoles (music_synth);\n" + - "CREATE INDEX idx_consoles_palette ON consoles (palette);\n" + - "CREATE INDEX idx_consoles_format ON consoles (format);\n" + - "CREATE INDEX idx_consoles_cap ON consoles (cap);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `disk_formats`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX idx_disk_formats_description ON disk_formats (description);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `forbidden`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_forbidden_browser ON forbidden (browser);\n" + - "CREATE INDEX idx_forbidden_date ON forbidden (date);\n" + - "CREATE INDEX idx_forbidden_ip ON forbidden (ip);\n" + - "CREATE INDEX idx_forbidden_referer ON forbidden (referer);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `gpus`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX idx_gpus_name ON gpus (name);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `log`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_log_browser ON log (browser);\n" + - "CREATE INDEX idx_log_date ON log (date);\n" + - "CREATE INDEX idx_log_ip ON log (ip);\n" + - "CREATE INDEX idx_log_referer ON log (referer);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `money_donations`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_money_donations_donator ON money_donations (donator);\n" + - "CREATE INDEX idx_money_donations_quantity ON money_donations (quantity);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `music_synths`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX idx_music_synts_name ON music_synths (name);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `news`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_news_date ON news (date);\n" + - "CREATE INDEX idx_news_type ON news (type);\n" + - "CREATE INDEX idx_news_ip ON news (added_id);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `owned_computers`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_owned_computers_db_id ON owned_computers (db_id);\n" + - "CREATE INDEX idx_owned_computers_date ON owned_computers (date);\n" + - "CREATE INDEX idx_owned_computers_status ON owned_computers (status);\n" + - "CREATE INDEX idx_owned_computers_trade ON owned_computers (trade);\n" + - "CREATE INDEX idx_owned_computers_boxed ON owned_computers (boxed);\n" + - "CREATE INDEX idx_owned_computers_manuals ON owned_computers (manuals);\n" + - "CREATE INDEX idx_owned_computers_cpu1 ON owned_computers (cpu1);\n" + - "CREATE INDEX idx_owned_computers_cpu2 ON owned_computers (cpu2);\n" + - "CREATE INDEX idx_owned_computers_mhz1 ON owned_computers (mhz1);\n" + - "CREATE INDEX idx_owned_computers_mhz2 ON owned_computers (mhz2);\n" + - "CREATE INDEX idx_owned_computers_ram ON owned_computers (ram);\n" + - "CREATE INDEX idx_owned_computers_vram ON owned_computers (vram);\n" + - "CREATE INDEX idx_owned_computers_rigid ON owned_computers (rigid);\n" + - "CREATE INDEX idx_owned_computers_disk1 ON owned_computers (disk1);\n" + - "CREATE INDEX idx_owned_computers_disk2 ON owned_computers (disk2);\n" + - "CREATE INDEX idx_owned_computers_cap1 ON owned_computers (cap1);\n" + - "CREATE INDEX idx_owned_computers_cap2 ON owned_computers (cap2);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `owned_consoles`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX idx_owned_consoles_db_id ON owned_consoles (db_id);\n" + - "CREATE INDEX idx_owned_consoles_date ON owned_consoles (date);\n" + - "CREATE INDEX idx_owned_consoles_status ON owned_consoles (status);\n" + - "CREATE INDEX idx_owned_consoles_trade ON owned_consoles (trade);\n" + - "CREATE INDEX idx_owned_consoles_boxed ON owned_consoles (boxed);\n" + - "CREATE INDEX idx_owned_consoles_manuals ON owned_consoles (manuals);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `processors`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX idx_processors_name ON processors (name);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating indexes on `sound_synths`..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX idx_sound_synths_name ON sound_synths (name);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 4..."); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('4')"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV5() - { - Console.WriteLine("Updating database to version 5"); - - Console.WriteLine("Creating foreign keys for table `computers`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = V5.ComputersForeignKeys; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - - Console.WriteLine("Creating foreign keys for table `consoles`"); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = V5.ConsolesForeignKeys; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 5..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('5')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV6() - { - Console.WriteLine("Updating database to version 6"); - - Console.WriteLine("Creating table `iso3166_1_numeric`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V6.Iso3166Numeric; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Filling table `iso3166_1_numeric`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V6.Iso3166NumericValues; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new columns to table `companies`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `companies` ADD COLUMN `founded` DATETIME NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `website` VARCHAR(255) NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `twitter` VARCHAR(45) NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `facebook` VARCHAR(45) NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `sold` DATETIME NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `sold_to` INT(11) NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `address` VARCHAR(80) NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `city` VARCHAR(80) NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `province` VARCHAR(80) NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `postal_code` VARCHAR(25) NULL;\n" + - "ALTER TABLE `companies` ADD COLUMN `country` SMALLINT(3) UNSIGNED ZEROFILL NULL;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new indexes to table `companies`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX `idx_companies_founded` ON `companies` (`founded`);\n" + - "CREATE INDEX `idx_companies_website` ON `companies` (`website`);\n" + - "CREATE INDEX `idx_companies_twitter` ON `companies` (`twitter`);\n" + - "CREATE INDEX `idx_companies_facebook` ON `companies` (`facebook`);\n" + - "CREATE INDEX `idx_companies_sold` ON `companies` (`sold`);\n" + - "CREATE INDEX `idx_companies_sold_to` ON `companies` (`sold_to`);\n" + - "CREATE INDEX `idx_companies_address` ON `companies` (`address`);\n" + - "CREATE INDEX `idx_companies_city` ON `companies` (`city`);\n" + - "CREATE INDEX `idx_companies_province` ON `companies` (`province`);\n" + - "CREATE INDEX `idx_companies_postal_code` ON `companies` (`postal_code`);\n" + - "CREATE INDEX `idx_companies_country` ON `companies` (`country`);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new foreign keys to table `companies`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_sold_to` (sold_to) REFERENCES `companies` (`id`);\n" + - "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_country` (country) REFERENCES `iso3166_1_numeric` (`id`);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 6..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('6')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV7() - { - Console.WriteLine("Updating database to version 7"); - - Console.WriteLine("Adding new columns to table `companies`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "ALTER TABLE `companies` ADD COLUMN `status` INT NOT NULL;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new indexes to table `companies`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX `idx_companies_status` ON `companies` (`status`);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 7..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('7')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV8() - { - Console.WriteLine("Updating database to version 8"); - - Console.WriteLine("Creating table `company_logos`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V8.CompanyLogos; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 8..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('8')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV9() - { - Console.WriteLine("Updating database to version 9"); - - Console.WriteLine("Creating table `company_descriptions`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V9.CompanyDescriptions; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 9..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('9')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV10() - { - Console.WriteLine("Updating database to version 10"); - - Console.WriteLine("Creating table `instruction_sets`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V10.InstructionSets; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating table `instruction_set_extensions`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V10.InstructionSetExtensions; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating table `instruction_set_extensions_by_processor`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V10.InstructionSetExtensionsByProcessor; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new columns to table `processors`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `processors` ADD COLUMN `company` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `model_code` VARCHAR(45) NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `introduced` DATETIME NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `instruction_set` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `speed` DOUBLE NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `package` VARCHAR(45) NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `GPRs` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `GPR_size` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `FPRs` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `FPR_size` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `cores` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `threads_per_core` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `process` VARCHAR(45) NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `process_nm` FLOAT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `die_size` FLOAT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `transistors` BIGINT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `data_bus` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `addr_bus` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `SIMD_registers` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `SIMD_size` INT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `L1_instruction` FLOAT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `L1_data` FLOAT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `L2` FLOAT NULL;\n" + - "ALTER TABLE `processors` ADD COLUMN `L3` FLOAT NULL;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new indexes to table `processors`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX `idx_processors_company` ON `processors` (`company`);\n" + - "CREATE INDEX `idx_processors_model_code` ON `processors` (`model_code`);\n" + - "CREATE INDEX `idx_processors_introduced` ON `processors` (`introduced`);\n" + - "CREATE INDEX `idx_processors_instruction_set` ON `processors` (`instruction_set`);\n" + - "CREATE INDEX `idx_processors_speed` ON `processors` (`speed`);\n" + - "CREATE INDEX `idx_processors_package` ON `processors` (`package`);\n" + - "CREATE INDEX `idx_processors_GPRs` ON `processors` (`GPRs`);\n" + - "CREATE INDEX `idx_processors_GPR_size` ON `processors` (`GPR_size`);\n" + - "CREATE INDEX `idx_processors_FPRs` ON `processors` (`FPRs`);\n" + - "CREATE INDEX `idx_processors_FPR_size` ON `processors` (`FPR_size`);\n" + - "CREATE INDEX `idx_processors_cores` ON `processors` (`cores`);\n" + - "CREATE INDEX `idx_processors_threads_per_core` ON `processors` (`threads_per_core`);\n" + - "CREATE INDEX `idx_processors_process` ON `processors` (`process`);\n" + - "CREATE INDEX `idx_processors_process_nm` ON `processors` (`process_nm`);\n" + - "CREATE INDEX `idx_processors_die_size` ON `processors` (`die_size`);\n" + - "CREATE INDEX `idx_processors_transistors` ON `processors` (`transistors`);\n" + - "CREATE INDEX `idx_processors_data_bus` ON `processors` (`data_bus`);\n" + - "CREATE INDEX `idx_processors_addr_bus` ON `processors` (`addr_bus`);\n" + - "CREATE INDEX `idx_processors_SIMD_registers` ON `processors` (`SIMD_registers`);\n" + - "CREATE INDEX `idx_processors_SIMD_size` ON `processors` (`SIMD_size`);\n" + - "CREATE INDEX `idx_processors_L1_instruction` ON `processors` (`L1_instruction`);\n" + - "CREATE INDEX `idx_processors_L1_data` ON `processors` (`L1_data`);\n" + - "CREATE INDEX `idx_processors_L2` ON `processors` (`L2`);\n" + - "CREATE INDEX `idx_processors_L3` ON `processors` (`L3`);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new foreign keys to table `processors`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `processors` ADD FOREIGN KEY `fk_processors_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `processors` ADD FOREIGN KEY `fk_processors_instruction_set` (instruction_set) REFERENCES `instruction_sets` (`id`) ON UPDATE CASCADE;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 10..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('10')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV11() - { - Console.WriteLine("Updating database to version 11"); - - Console.WriteLine("Adding new columns to table `gpus`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `gpus` ADD COLUMN `company` INT NULL;\n" + - "ALTER TABLE `gpus` ADD COLUMN `model_code` VARCHAR(45) NULL;\n" + - "ALTER TABLE `gpus` ADD COLUMN `introduced` DATETIME NULL;\n" + - "ALTER TABLE `gpus` ADD COLUMN `package` VARCHAR(45) NULL;\n" + - "ALTER TABLE `gpus` ADD COLUMN `process` VARCHAR(45) NULL;\n" + - "ALTER TABLE `gpus` ADD COLUMN `process_nm` FLOAT NULL;\n" + - "ALTER TABLE `gpus` ADD COLUMN `die_size` FLOAT NULL;\n" + - "ALTER TABLE `gpus` ADD COLUMN `transistors` BIGINT NULL;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new indexes to table `gpus`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX `idx_gpus_company` ON `gpus` (`company`);\n" + - "CREATE INDEX `idx_gpus_model_code` ON `gpus` (`model_code`);\n" + - "CREATE INDEX `idx_gpus_introduced` ON `gpus` (`introduced`);\n" + - "CREATE INDEX `idx_gpus_package` ON `gpus` (`package`);\n" + - "CREATE INDEX `idx_gpus_process` ON `gpus` (`process`);\n" + - "CREATE INDEX `idx_gpus_process_nm` ON `gpus` (`process_nm`);\n" + - "CREATE INDEX `idx_gpus_die_size` ON `gpus` (`die_size`);\n" + - "CREATE INDEX `idx_gpus_transistors` ON `gpus` (`transistors`);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new foreign keys to table `gpus`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `gpus` ADD FOREIGN KEY `fk_gpus_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 11..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('11')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV12() - { - Console.WriteLine("Updating database to version 12"); - - Console.WriteLine("Altering colums from table `computers`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `computers` CHANGE COLUMN `gpu` `gpu` INT DEFAULT NULL;\n" + - "ALTER TABLE `computers` CHANGE COLUMN `cpu1` `cpu1` INT DEFAULT NULL;\n" + - "ALTER TABLE `computers` CHANGE COLUMN `mhz1` `mhz1` INT DEFAULT NULL;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Altering colums from table `consoles`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `consoles` CHANGE COLUMN `gpu` `gpu` INT DEFAULT NULL;\n" + - "ALTER TABLE `consoles` CHANGE COLUMN `cpu1` `cpu1` INT DEFAULT NULL;\n" + - "ALTER TABLE `consoles` CHANGE COLUMN `mhz1` `mhz1` INT DEFAULT NULL;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new special items to table `gpus`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = $"INSERT INTO `gpus` (`id`, `name`) VALUES ({DB_NONE}, 'DB_NONE');\n" + - $"INSERT INTO `gpus` (`id`, `name`) VALUES ({DB_SOFTWARE}, 'DB_FRAMEBUFFER');"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Updating items from table `computers`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = $"UPDATE `computers` SET `gpu` = {DB_NONE} WHERE `gpu` = 1;\n" + - "UPDATE `computers` SET `gpu` = NULL WHERE `gpu` = 2;\n" + - $"UPDATE `computers` SET `gpu` = {DB_SOFTWARE} WHERE `gpu` = 3;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Updating items from table `consoles`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = $"UPDATE `consoles` SET `gpu` = {DB_NONE} WHERE `gpu` = 1;\n" + - "UPDATE `consoles` SET `gpu` = NULL WHERE `gpu` = 2;\n" + - $"UPDATE `consoles` SET `gpu` = {DB_SOFTWARE} WHERE `gpu` = 3;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Remocing old special items from table `gpus`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "DELETE FROM `gpus` WHERE `id` = 1;\n" + "DELETE FROM `gpus` WHERE `id` = 2;\n" + - "DELETE FROM `gpus` WHERE `id` = 3;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 12..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('12')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV13() - { - Console.WriteLine("Updating database to version 13"); - - Console.WriteLine("Adding new columns to table `sound_synths`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `sound_synths` ADD COLUMN `company` INT NULL;\n" + - "ALTER TABLE `sound_synths` ADD COLUMN `model_code` VARCHAR(45) NULL;\n" + - "ALTER TABLE `sound_synths` ADD COLUMN `introduced` DATETIME NULL;\n" + - "ALTER TABLE `sound_synths` ADD COLUMN `voices` INT NULL;\n" + - "ALTER TABLE `sound_synths` ADD COLUMN `frequency` DOUBLE NULL;\n" + - "ALTER TABLE `sound_synths` ADD COLUMN `depth` INT NULL;\n" + - "ALTER TABLE `sound_synths` ADD COLUMN `square_wave` INT NULL;\n" + - "ALTER TABLE `sound_synths` ADD COLUMN `white_noise` INT NULL;\n" + - "ALTER TABLE `sound_synths` ADD COLUMN `type` INT NULL;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating new indexes in table `sound_synths`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX `idx_sound_synths_company` ON `sound_synths` (`company`);\n" + - "CREATE INDEX `idx_sound_synths_model_code` ON `sound_synths` (`model_code`);\n" + - "CREATE INDEX `idx_sound_synths_introduced` ON `sound_synths` (`introduced`);\n" + - "CREATE INDEX `idx_sound_synths_voices` ON `sound_synths` (`voices`);\n" + - "CREATE INDEX `idx_sound_synths_frequency` ON `sound_synths` (`frequency`);\n" + - "CREATE INDEX `idx_sound_synths_depth` ON `sound_synths` (`depth`);\n" + - "CREATE INDEX `idx_sound_synths_square_wave` ON `sound_synths` (`square_wave`);\n" + - "CREATE INDEX `idx_sound_synths_white_noise` ON `sound_synths` (`white_noise`);\n" + - "CREATE INDEX `idx_sound_synths_type` ON `sound_synths` (`type`);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating foreign keys in table `sound_synths`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `sound_synths` ADD FOREIGN KEY `fk_sound_synths_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Dropping foreign keys from tables `computers` and `consoles`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `computers` DROP FOREIGN KEY `fk_computers_music_synth`;\n" + - "ALTER TABLE `consoles` DROP FOREIGN KEY `fk_consoles_music_synth`;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `music_synths`"); - - Dictionary musicSynths = new(); - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from music_synths"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - musicSynths.Add(int.Parse(dataRow["id"].ToString()), dataRow["name"].ToString()); - - Dictionary conversionEquivalents = new(); - - Console.WriteLine("Converting all items from `music_synths` to `sound_synths`"); - - foreach(KeyValuePair musicSynth in musicSynths) - { - dbCmd = dbCon.CreateCommand(); - dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = $"SELECT * from sound_synths WHERE name LIKE '{musicSynth.Value}'"; - dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - if(dataSet.Tables[0].Rows.Count == 1) - { - Console.WriteLine("Converting music synth `{0}` to sound synth `{1}`", musicSynth.Value, - dataSet.Tables[0].Rows[0]["name"]); - - conversionEquivalents.Add(musicSynth.Key, int.Parse(dataSet.Tables[0].Rows[0]["id"].ToString())); - } - else - { - Console.Write("Adding new sound synth `{0}`... ", musicSynth.Value); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = $"INSERT INTO sound_synths (name) VALUES ('{musicSynth.Value}')"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - long id = dbCore.LastInsertRowId; - Console.WriteLine("got id {0}", id); - conversionEquivalents.Add(musicSynth.Key, (int)id); - } - } - - Console.WriteLine("Getting all items from `consoles`"); - Dictionary consoleIdAndMusicSynthId = new(); - dbCmd = dbCon.CreateCommand(); - dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT id,music_synth from consoles"; - dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - consoleIdAndMusicSynthId.Add(int.Parse(dataRow["id"].ToString()), - int.Parse(dataRow["music_synth"].ToString())); - - trans = dbCon.BeginTransaction(); - - foreach(KeyValuePair keyValuePair in consoleIdAndMusicSynthId) - { - conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId); - - Console.WriteLine("Converting music synth {0} to sound synth {1} for console {2}... ", - keyValuePair.Value, newId, keyValuePair.Key); - - dbCmd = dbCon.CreateCommand(); - dbCmd.Transaction = trans; - dbCmd.CommandText = $"UPDATE consoles SET music_synth = {newId} WHERE id = {keyValuePair.Key}"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - Console.WriteLine("Comitting changes..."); - trans.Commit(); - - Console.WriteLine("Getting all items from `computers`"); - Dictionary computerIdAndMusicSynthId = new(); - dbCmd = dbCon.CreateCommand(); - dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT id,music_synth from computers"; - dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - computerIdAndMusicSynthId.Add(int.Parse(dataRow["id"].ToString()), - int.Parse(dataRow["music_synth"].ToString())); - - trans = dbCon.BeginTransaction(); - - foreach(KeyValuePair keyValuePair in computerIdAndMusicSynthId) - { - conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId); - - Console.WriteLine("Converting music synth {0} to sound synth {1} for computer {2}... ", - keyValuePair.Value, newId, keyValuePair.Key); - - dbCmd = dbCon.CreateCommand(); - dbCmd.Transaction = trans; - dbCmd.CommandText = $"UPDATE computers SET music_synth = {newId} WHERE id = {keyValuePair.Key}"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - Console.WriteLine("Comitting changes..."); - trans.Commit(); - - Console.WriteLine("Adding new foreign keys to table `computers`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `computers` ADD FOREIGN KEY `fk_computers_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new foreign keys to table `consoles`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `consoles` ADD FOREIGN KEY `fk_consoles_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Dropping table `music_synths`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "DROP TABLE `music_synths`;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 13..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('13')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV14() - { - Console.WriteLine("Updating database to version 14"); - - Console.WriteLine("Renaming table `computers` to `machines`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "ALTER TABLE `computers` RENAME TO `machines`;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Removing column `bits` from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `bits`;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating column `type` in table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - $"ALTER TABLE `machines` ADD COLUMN `type` INT NOT NULL DEFAULT '{(int)MachineType.Unknown}';"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Updating all entries in table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = $"UPDATE `machines` SET `type` = '{(int)MachineType.Computer}';"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Renaming all indexes on table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `machines` DROP INDEX `idx_computers_company`, ADD INDEX `idx_machines_company` (`company`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_year`, ADD INDEX `idx_machines_year` (`year`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_model`, ADD INDEX `idx_machines_model` (`model`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_cpu1`, ADD INDEX `idx_machines_cpu1` (`cpu1`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_cpu2`, ADD INDEX `idx_machines_cpu2` (`cpu2`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_mhz1`, ADD INDEX `idx_machines_mhz1` (`mhz1`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_mhz2`, ADD INDEX `idx_machines_mhz2` (`mhz2`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_ram`, ADD INDEX `idx_machines_ram` (`ram`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_rom`, ADD INDEX `idx_machines_rom` (`rom`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_gpu`, ADD INDEX `idx_machines_gpu` (`gpu`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_vram`, ADD INDEX `idx_machines_vram` (`vram`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_colors`, ADD INDEX `idx_machines_colors` (`colors`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_res`, ADD INDEX `idx_machines_res` (`res`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_sound_synth`, ADD INDEX `idx_machines_sound_synth` (`sound_synth`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_music_synth`, ADD INDEX `idx_machines_music_synth` (`music_synth`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_hdd1`, ADD INDEX `idx_machines_hdd1` (`hdd1`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_hdd2`, ADD INDEX `idx_machines_hdd2` (`hdd2`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_hdd3`, ADD INDEX `idx_machines_hdd3` (`hdd3`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_disk1`, ADD INDEX `idx_machines_disk1` (`disk1`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_disk2`, ADD INDEX `idx_machines_disk2` (`disk2`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_cap1`, ADD INDEX `idx_machines_cap1` (`cap1`);\n" + - "ALTER TABLE `machines` DROP INDEX `idx_computers_cap2`, ADD INDEX `idx_machines_cap2` (`cap2`);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Removing old foreign keys from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_company`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_cpu1`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_cpu2`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_disk1`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_disk2`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_gpu`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_hdd1`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_hdd2`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_hdd3`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_music_synth`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_sound_synth`;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding foreign keys in table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_cpu1` (cpu1) REFERENCES `processors` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_cpu2` (cpu2) REFERENCES `processors` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_gpu` (gpu) REFERENCES `gpus` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_sound_synth` (sound_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new index for `type` in table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "CREATE INDEX `idx_machines_type` ON `machines` (`type`);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `consoles`"); - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from consoles"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - IDbDataParameter param2 = dbcmd.CreateParameter(); - IDbDataParameter param3 = dbcmd.CreateParameter(); - IDbDataParameter param4 = dbcmd.CreateParameter(); - IDbDataParameter param5 = dbcmd.CreateParameter(); - IDbDataParameter param6 = dbcmd.CreateParameter(); - IDbDataParameter param7 = dbcmd.CreateParameter(); - IDbDataParameter param8 = dbcmd.CreateParameter(); - IDbDataParameter param9 = dbcmd.CreateParameter(); - IDbDataParameter param10 = dbcmd.CreateParameter(); - IDbDataParameter param11 = dbcmd.CreateParameter(); - IDbDataParameter param12 = dbcmd.CreateParameter(); - IDbDataParameter param13 = dbcmd.CreateParameter(); - IDbDataParameter param14 = dbcmd.CreateParameter(); - IDbDataParameter param15 = dbcmd.CreateParameter(); - IDbDataParameter param16 = dbcmd.CreateParameter(); - IDbDataParameter param17 = dbcmd.CreateParameter(); - IDbDataParameter param18 = dbcmd.CreateParameter(); - IDbDataParameter param19 = dbcmd.CreateParameter(); - IDbDataParameter param20 = dbcmd.CreateParameter(); - IDbDataParameter param21 = dbcmd.CreateParameter(); - - param1.ParameterName = "@company"; - param2.ParameterName = "@year"; - param3.ParameterName = "@model"; - param4.ParameterName = "@cpu1"; - param5.ParameterName = "@mhz1"; - param6.ParameterName = "@cpu2"; - param7.ParameterName = "@mhz2"; - param8.ParameterName = "@ram"; - param9.ParameterName = "@rom"; - param10.ParameterName = "@gpu"; - param11.ParameterName = "@vram"; - param12.ParameterName = "@colors"; - param13.ParameterName = "@res"; - param14.ParameterName = "@sound_synth"; - param15.ParameterName = "@music_synth"; - param16.ParameterName = "@sound_channels"; - param17.ParameterName = "@music_channels"; - param18.ParameterName = "@type"; - param19.ParameterName = "@hdd1"; - param20.ParameterName = "@disk1"; - param21.ParameterName = "@cap1"; - - param1.DbType = DbType.Int32; - param2.DbType = DbType.Int32; - param3.DbType = DbType.String; - param4.DbType = DbType.Int32; - param5.DbType = DbType.Double; - param6.DbType = DbType.Int32; - param7.DbType = DbType.Double; - param8.DbType = DbType.Int32; - param9.DbType = DbType.Int32; - param10.DbType = DbType.Int32; - param11.DbType = DbType.Int32; - param12.DbType = DbType.Int32; - param13.DbType = DbType.String; - param14.DbType = DbType.Int32; - param15.DbType = DbType.Int32; - param16.DbType = DbType.Int32; - param17.DbType = DbType.Int32; - param18.DbType = DbType.Int32; - param19.DbType = DbType.Int32; - param20.DbType = DbType.Int32; - param21.DbType = DbType.Int32; - - param1.Value = (int)dataRow["company"]; - param2.Value = (int)dataRow["year"]; - param3.Value = (string)dataRow["model"]; - param4.Value = dataRow["cpu1"] == DBNull.Value ? (object)null : (int)dataRow["cpu1"]; - - param5.Value = dataRow["mhz1"] == DBNull.Value ? (object)null : float.Parse(dataRow["mhz1"].ToString()); - - param6.Value = dataRow["cpu2"] == DBNull.Value ? (object)null : (int)dataRow["cpu2"]; - - param7.Value = dataRow["mhz2"] == DBNull.Value ? (object)null : float.Parse(dataRow["mhz2"].ToString()); - - param8.Value = (int)dataRow["ram"]; - param9.Value = (int)dataRow["rom"]; - param10.Value = dataRow["gpu"] == DBNull.Value ? (object)null : (int)dataRow["gpu"]; - param11.Value = (int)dataRow["vram"]; - param12.Value = (int)dataRow["colors"]; - param13.Value = (string)dataRow["res"]; - param14.Value = (int)dataRow["sound_synth"]; - param15.Value = (int)dataRow["music_synth"]; - param16.Value = (int)dataRow["schannels"]; - param17.Value = (int)dataRow["mchannels"]; - param18.Value = MachineType.Console; - param19.Value = 30; - param20.Value = 30; - param21.Value = 0; - - dbcmd.Parameters.Add(param1); - dbcmd.Parameters.Add(param2); - dbcmd.Parameters.Add(param3); - dbcmd.Parameters.Add(param4); - dbcmd.Parameters.Add(param5); - dbcmd.Parameters.Add(param6); - dbcmd.Parameters.Add(param7); - dbcmd.Parameters.Add(param8); - dbcmd.Parameters.Add(param9); - dbcmd.Parameters.Add(param10); - dbcmd.Parameters.Add(param11); - dbcmd.Parameters.Add(param12); - dbcmd.Parameters.Add(param13); - dbcmd.Parameters.Add(param14); - dbcmd.Parameters.Add(param15); - dbcmd.Parameters.Add(param16); - dbcmd.Parameters.Add(param17); - dbcmd.Parameters.Add(param18); - dbcmd.Parameters.Add(param19); - dbcmd.Parameters.Add(param20); - dbcmd.Parameters.Add(param21); - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Converting console \"{0}\" to machine", (string)param3.Value); - - const string SQL = - "INSERT INTO machines (company, year, model, cpu1, mhz1, cpu2, mhz2, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, sound_channels, music_channels, type, hdd1, disk1, cap1)" + - " VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, @sound_channels, @music_channels, @type, @hdd1, @disk1, @cap1)"; - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - dbcmd.Dispose(); - } - - Console.WriteLine("Dropping table `consoles`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "DROP TABLE `consoles`;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 14..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('14')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV15() - { - Console.WriteLine("Updating database to version 15"); - - Console.WriteLine("Creating table `processors_by_machine`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V15.ProcessorsByMachine; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `machines`"); - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from machines"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - IDbDataParameter param2 = dbcmd.CreateParameter(); - IDbDataParameter param3 = dbcmd.CreateParameter(); - - param1.ParameterName = "@machine"; - param2.ParameterName = "@processor"; - param3.ParameterName = "@speed"; - - param1.DbType = DbType.Int32; - param2.DbType = DbType.Int32; - param3.DbType = DbType.Double; - - param1.Value = (int)dataRow["id"]; - - const string SQL = - "INSERT INTO processors_by_machine (machine, processor, speed) VALUES (@machine, @processor, @speed)"; - - dbcmd.Parameters.Add(param1); - dbcmd.Parameters.Add(param2); - dbcmd.Parameters.Add(param3); - - if(dataRow["cpu1"] != DBNull.Value) - { - param2.Value = (int)dataRow["cpu1"]; - - param3.Value = dataRow["mhz1"] == DBNull.Value ? (object)null - : float.Parse(dataRow["mhz1"].ToString()); - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding processor {0} to machine {1}", (int)param2.Value, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - if(dataRow["cpu2"] != DBNull.Value) - { - param2.Value = (int)dataRow["cpu2"]; - - param3.Value = dataRow["mhz2"] == DBNull.Value ? (object)null - : float.Parse(dataRow["mhz2"].ToString()); - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding processor {0} to machine {1}", (int)param2.Value, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - dbcmd.Dispose(); - } - - Console.WriteLine("Removing processor columns from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_cpu1`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_cpu2`;\n" + - "ALTER TABLE `machines` DROP COLUMN `cpu1`;\n" + - "ALTER TABLE `machines` DROP COLUMN `cpu2`;\n" + - "ALTER TABLE `machines` DROP COLUMN `mhz1`;\n" + - "ALTER TABLE `machines` DROP COLUMN `mhz2`;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 15..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('15')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV16() - { - Console.WriteLine("Updating database to version 16"); - - Console.WriteLine("Creating table `gpus_by_machine`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V16.GpusByMachine; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `machines`"); - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from machines"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - IDbDataParameter param2 = dbcmd.CreateParameter(); - - param1.ParameterName = "@machine"; - param2.ParameterName = "@gpu"; - - param1.DbType = DbType.Int32; - param2.DbType = DbType.Int32; - - param1.Value = (int)dataRow["id"]; - - const string SQL = "INSERT INTO gpus_by_machine (machine, gpu) VALUES (@machine, @gpu)"; - - dbcmd.Parameters.Add(param1); - dbcmd.Parameters.Add(param2); - - if(dataRow["gpu"] != DBNull.Value) - { - param2.Value = (int)dataRow["gpu"]; - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding gpu {0} to machine {1}", (int)param2.Value, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - dbcmd.Dispose(); - } - - Console.WriteLine("Removing processor columns from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_gpu`;\n" + - "ALTER TABLE `machines` DROP COLUMN `gpu`;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 16..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('16')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV17() - { - Console.WriteLine("Updating database to version 17"); - - Console.WriteLine("Creating table `sound_by_machine`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V17.SoundByMachine; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new special items to table `sound_synths`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = $"INSERT INTO `sound_synths` (`id`, `name`) VALUES ({DB_SOFTWARE}, 'DB_SOFTWARE');"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Changing sound and music synths in machine from 27 to {0}", DB_SOFTWARE); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = $"UPDATE `machines` SET sound_synth = {DB_SOFTWARE} WHERE sound_synth = 27;\n" + - $"UPDATE `machines` SET music_synth = {DB_SOFTWARE} WHERE music_synth = 27;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `machines`"); - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from machines"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - IDbDataParameter param2 = dbcmd.CreateParameter(); - - param1.ParameterName = "@machine"; - param2.ParameterName = "@sound_synth"; - - param1.DbType = DbType.Int32; - param2.DbType = DbType.Int32; - - param1.Value = (int)dataRow["id"]; - - const string SQL = - "INSERT INTO sound_by_machine (machine, sound_synth) VALUES (@machine, @sound_synth)"; - - dbcmd.Parameters.Add(param1); - dbcmd.Parameters.Add(param2); - - if(dataRow["sound_synth"] != DBNull.Value && - (int)dataRow["sound_synth"] != 1 && - (int)dataRow["sound_synth"] != 2) - { - param2.Value = (int)dataRow["sound_synth"]; - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding sound {0} to machine {1}", (int)param2.Value, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - if(dataRow["music_synth"] != DBNull.Value && - (int)dataRow["music_synth"] != 1 && - (int)dataRow["music_synth"] != 2) - { - param2.Value = (int)dataRow["music_synth"]; - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding sound {0} to machine {1}", (int)param2.Value, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - dbcmd.Dispose(); - } - - Console.WriteLine("Removing sound columns from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_sound_synth`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_music_synth`;\n" + - "ALTER TABLE `machines` DROP COLUMN `sound_channels`;\n" + - "ALTER TABLE `machines` DROP COLUMN `music_channels`;\n" + - "ALTER TABLE `machines` DROP COLUMN `sound_synth`;\n" + - "ALTER TABLE `machines` DROP COLUMN `music_synth`;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Removing old sound items `sound_synths`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "DELETE FROM sound_synths WHERE id = 1;\n" + - "DELETE FROM sound_synths WHERE id = 2;\n" + "DELETE FROM sound_synths WHERE id = 27;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 17..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('17')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV18() - { - Console.WriteLine("Updating database to version 18"); - - Console.WriteLine("Creating table `memory_by_machine`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V18.MemoryByMachine; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `machines`"); - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from machines"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - IDbDataParameter param2 = dbcmd.CreateParameter(); - IDbDataParameter param3 = dbcmd.CreateParameter(); - - param1.ParameterName = "@machine"; - param2.ParameterName = "@usage"; - param3.ParameterName = "@size"; - - param1.DbType = DbType.Int32; - param2.DbType = DbType.Int32; - param3.DbType = DbType.Int64; - - param1.Value = (int)dataRow["id"]; - - const string SQL = - "INSERT INTO `memory_by_machine` (`machine`, `usage`, `size`) VALUES (@machine, @usage, @size)"; - - dbcmd.Parameters.Add(param1); - dbcmd.Parameters.Add(param2); - dbcmd.Parameters.Add(param3); - - if(dataRow["ram"] != DBNull.Value && - (int)dataRow["ram"] > 0) - { - param2.Value = MemoryUsage.Work; - param3.Value = (int)dataRow["ram"] * 1024; - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", (int)param3.Value, - MemoryUsage.Work, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - if(dataRow["rom"] != DBNull.Value && - (int)dataRow["rom"] > 0) - { - param2.Value = MemoryUsage.Firmware; - param3.Value = (int)dataRow["rom"] * 1024; - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", (int)param3.Value, - MemoryUsage.Firmware, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - if(dataRow["vram"] != DBNull.Value && - (int)dataRow["vram"] > 0) - { - param2.Value = MemoryUsage.Video; - param3.Value = (int)dataRow["vram"] * 1024; - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", (int)param3.Value, - MemoryUsage.Video, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - dbcmd.Dispose(); - } - - Console.WriteLine("Removing memory columns from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `ram`;\n" + - "ALTER TABLE `machines` DROP COLUMN `rom`;\n" + - "ALTER TABLE `machines` DROP COLUMN `vram`;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 18..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('18')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV19() - { - Console.WriteLine("Updating database to version 19"); - - Console.WriteLine("Creating table `resolutions`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V19.Resolutions; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Creating table `resolutions_by_gpu`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V19.ResolutionsByGpu; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `machines`"); - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from machines"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - if(dataRow["colors"] == DBNull.Value || - dataRow["res"] == DBNull.Value || - (int)dataRow["colors"] == 0 || - (string)dataRow["res"] == "???") - continue; - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter2 = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = $"SELECT * FROM gpus_by_machine WHERE machine = {(int)dataRow["id"]}"; - var dataSet2 = new DataSet(); - dataAdapter2.SelectCommand = dbCmd; - dataAdapter2.Fill(dataSet2); - - if(dataSet2.Tables[0].Rows.Count == 0) - continue; - - int gpuId = (int)dataSet2.Tables[0].Rows[0]["gpu"]; - - string[] resPieces = ((string)dataRow["res"]).Split('x'); - - if(!int.TryParse(resPieces[0], out int width)) - continue; - - if(!int.TryParse(resPieces[1], out int height)) - continue; - - dbCmd = dbCon.CreateCommand(); - dataAdapter2 = dbCore.GetNewDataAdapter(); - - dbCmd.CommandText = - $"SELECT * FROM resolutions WHERE width = {width} AND height = {height} AND colors = {(int)dataRow["colors"]}"; - - dataSet2 = new DataSet(); - dataAdapter2.SelectCommand = dbCmd; - dataAdapter2.Fill(dataSet2); - - int resId; - string sql; - - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - IDbDataParameter param2 = dbcmd.CreateParameter(); - IDbDataParameter param3 = dbcmd.CreateParameter(); - - if(dataSet2.Tables[0].Rows.Count == 0) - { - param1.ParameterName = "@width"; - param2.ParameterName = "@height"; - param3.ParameterName = "@colors"; - - param1.DbType = DbType.Int32; - param2.DbType = DbType.Int32; - param3.DbType = DbType.Int64; - - param1.Value = width; - param2.Value = height; - param3.Value = (int)dataRow["colors"]; - - sql = "INSERT INTO `resolutions` (`width`, `height`, `colors`) VALUES (@width, @height, @colors)"; - - dbcmd.Parameters.Add(param1); - dbcmd.Parameters.Add(param2); - dbcmd.Parameters.Add(param3); - - dbcmd.CommandText = sql; - - dbcmd.ExecuteNonQuery(); - dbcmd.Dispose(); - - resId = (int)dbCore.LastInsertRowId; - } - else - resId = (int)dataSet2.Tables[0].Rows[0]["id"]; - - dbcmd = dbCon.CreateCommand(); - - param1 = dbcmd.CreateParameter(); - param2 = dbcmd.CreateParameter(); - - param1.ParameterName = "@gpu"; - param2.ParameterName = "@resolution"; - - param1.DbType = DbType.Int32; - param2.DbType = DbType.Int32; - - param1.Value = gpuId; - param2.Value = resId; - - sql = "INSERT INTO `resolutions_by_gpu` (`gpu`, `resolution`) VALUES (@gpu, @resolution)"; - - dbcmd.Parameters.Add(param1); - dbcmd.Parameters.Add(param2); - - dbcmd.CommandText = sql; - - dbcmd.ExecuteNonQuery(); - dbcmd.Dispose(); - } - - Console.WriteLine("Removing resolution columns from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `res`;\n" + - "ALTER TABLE `machines` DROP COLUMN `colors`;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 19..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('19')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV20() - { - Console.WriteLine("Updating database to version 20"); - - Console.WriteLine("Creating table `storage_by_machine`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V20.StorageByMachine; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `machines`"); - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from machines"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - IDbDataParameter param2 = dbcmd.CreateParameter(); - IDbDataParameter param3 = dbcmd.CreateParameter(); - IDbDataParameter param4 = dbcmd.CreateParameter(); - - param1.ParameterName = "@machine"; - param2.ParameterName = "@type"; - param3.ParameterName = "@interface"; - param4.ParameterName = "@capacity"; - - param1.DbType = DbType.Int32; - param2.DbType = DbType.Int32; - param3.DbType = DbType.Int32; - param4.DbType = DbType.Int64; - - param1.Value = (int)dataRow["id"]; - - const string SQL = - "INSERT INTO `storage_by_machine` (`machine`, `type`, `interface`, `capacity`) VALUES (@machine, @type, @interface, @capacity)"; - - dbcmd.Parameters.Add(param1); - dbcmd.Parameters.Add(param2); - dbcmd.Parameters.Add(param3); - dbcmd.Parameters.Add(param4); - - foreach(string media in new[] - { - "hdd1", "hdd2", "hdd3", "disk1", "disk2" - }) - { - if(dataRow[media] == DBNull.Value || - (int)dataRow[media] == 30) - continue; - - param3.Value = StorageInterface.Unknown; - - switch((int)dataRow[media]) - { - case 1: - param2.Value = StorageType.CompactFloppy; - - break; - case 3: - case 5: - param2.Value = StorageType.Microfloppy; - - break; - case 4: - param2.Value = StorageType.Minifloppy; - - break; - case 7: - param2.Value = StorageType.CompactDisc; - - break; - case 8: - param2.Value = StorageType.CompactCassette; - - break; - case 9: - param2.Value = StorageType.CompactFlash; - - break; - case 11: - param2.Value = StorageType.Dvd; - - break; - case 12: - param2.Value = StorageType.GDROM; - - break; - case 13: - param2.Value = StorageType.ZIP100; - - break; - case 14: - param2.Value = StorageType.LS120; - - break; - case 15: - param2.Value = StorageType.MagnetoOptical; - - break; - case 17: - param2.Value = StorageType.Microdrive; - - break; - case 18: - param2.Value = StorageType.MMC; - - break; - case 20: - param2.Value = StorageType.SecureDigital; - - break; - case 21: - param2.Value = StorageType.SmartMedia; - - break; - case 23: - param2.Value = StorageType.PunchedCard; - - break; - case 24: - param2.Value = StorageType.HardDisk; - param3.Value = StorageInterface.ACSI; - - break; - case 25: - case 29: - param2.Value = StorageType.HardDisk; - param3.Value = StorageInterface.ATA; - - break; - case 26: - param2.Value = StorageType.HardDisk; - param3.Value = StorageInterface.ESDI; - - break; - case 27: - param2.Value = StorageType.HardDisk; - param3.Value = StorageInterface.FireWire; - - break; - case 28: - param2.Value = StorageType.CompactFloppy; - - break; - case 32: - case 35: - param2.Value = StorageType.HardDisk; - param3.Value = StorageInterface.ST506; - - break; - case 33: - param2.Value = StorageType.HardDisk; - param3.Value = StorageInterface.SASI; - - break; - case 34: - case 41: - param2.Value = StorageType.HardDisk; - param3.Value = StorageInterface.SCSI; - - break; - case 40: - param2.Value = StorageType.Floppy; - - break; - case 43: - param2.Value = StorageType.Bluray; - - break; - case 44: - param2.Value = StorageType.GOD; - - break; - case 45: - param2.Value = StorageType.WOD; - - break; - default: - param2.Value = StorageType.Unknown; - - break; - } - - param4.Value = null; - - switch(media) - { - case "disk1": - if(dataRow["cap1"] != DBNull.Value) - if(int.TryParse((string)dataRow["cap1"], out int cap)) - param4.Value = cap == 0 - ? (object)null - : (StorageType)param2.Value == StorageType.CompactCassette - ? cap - : cap * 1024; - - break; - case "disk2": - if(dataRow["cap2"] != DBNull.Value) - if(int.TryParse((string)dataRow["cap2"], out int cap)) - param4.Value = cap == 0 - ? (object)null - : (StorageType)param2.Value == StorageType.CompactCassette - ? cap - : cap * 1024; - - break; - } - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding storage type {0} with interface {1} to machine {2}", - (StorageType)param2.Value, (StorageInterface)param3.Value, (int)param1.Value); - - dbcmd.CommandText = SQL; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - } - - dbcmd.Dispose(); - } - - Console.WriteLine("Removing memory columns from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_disk1`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_disk2`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd1`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd2`;\n" + - "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd3`;\n" + - "ALTER TABLE `machines` DROP COLUMN `hdd1`;\n" + - "ALTER TABLE `machines` DROP COLUMN `hdd2`;\n" + - "ALTER TABLE `machines` DROP COLUMN `hdd3`;\n" + - "ALTER TABLE `machines` DROP COLUMN `disk1`;\n" + - "ALTER TABLE `machines` DROP COLUMN `cap1`;\n" + - "ALTER TABLE `machines` DROP COLUMN `disk2`;\n" + - "ALTER TABLE `machines` DROP COLUMN `cap2`;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Removing table `disk_formats`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "DROP TABLE `disk_formats`;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 20..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('20')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV21() - { - Console.WriteLine("Updating database to version 21"); - - Console.WriteLine("Adding new columns to table `machines`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` ADD COLUMN `introduced` DATETIME NULL;\n" + - "CREATE INDEX idx_machines_introduced ON machines (introduced);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Getting all items from `machines`"); - - dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SELECT * from machines"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - IDbCommand dbcmd = dbCon.CreateCommand(); - - IDbDataParameter param1 = dbcmd.CreateParameter(); - - param1.ParameterName = "@introduced"; - - param1.DbType = DbType.DateTime; - - if((int)dataRow["year"] > 0) - param1.Value = new DateTime((int)dataRow["year"], 1, 1); - else - param1.Value = null; - - string sql = $"UPDATE `machines` SET introduced = @introduced WHERE id = {(int)dataRow["id"]}"; - - dbcmd.Parameters.Add(param1); - - trans = dbCon.BeginTransaction(); - dbcmd.Transaction = trans; - - Console.WriteLine("Adding introduction date {0} to machine {1}", (int)dataRow["year"], - (int)dataRow["id"]); - - dbcmd.CommandText = sql; - - dbcmd.ExecuteNonQuery(); - trans.Commit(); - - dbcmd.Dispose(); - } - - Console.WriteLine("Removing year column from table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `year`;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 21..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('21')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV22() - { - Console.WriteLine("Updating database to version 22"); - - Console.WriteLine("Creating new table table `machine_families`"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = V22.MachineFamilies; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new columns to table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "ALTER TABLE `machines` ADD COLUMN `family` INT DEFAULT NULL;\n" + - "ALTER TABLE `machines` CHANGE COLUMN `model` `name` VARCHAR(255) NOT NULL;\n" + - "ALTER TABLE `machines` DROP INDEX `idx_machines_model`;\n" + - "ALTER TABLE `machines` ADD COLUMN `model` VARCHAR(50) DEFAULT NULL;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new indexes to table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = "CREATE INDEX `idx_machines_family` ON `machines` (`family`);\n" + - "CREATE INDEX `idx_machines_name` ON `machines` (`name`);\n" + - "CREATE INDEX `idx_machines_model` ON `machines` (`model`);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding new foreign keys to table `machines`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_family` (family) REFERENCES machine_families (`id`) ON UPDATE CASCADE"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 22..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('22')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void UpdateDatabaseToV23() - { - Console.WriteLine("Updating database to version 23"); - - Console.WriteLine("Altering `browser_tests` primary key"); - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbTransaction trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "ALTER TABLE browser_tests MODIFY id int NOT NULL auto_increment;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Dropping foreign key between `iso3166_1_numeric` and `companies`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "ALTER TABLE companies DROP FOREIGN KEY `fk_companies_country`;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Altering `iso3166_1_numeric` primary key"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "ALTER TABLE iso3166_1_numeric MODIFY id smallint(3) NOT NULL;"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Altering `country` column in `companies`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - dbCmd.CommandText = "ALTER TABLE companies MODIFY country smallint(3);"; - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Re-adding new foreign keys to table `companies`"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_country` (country) REFERENCES `iso3166_1_numeric` (`id`);"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Adding primary keys to several tables"); - dbCmd = dbCon.CreateCommand(); - trans = dbCon.BeginTransaction(); - dbCmd.Transaction = trans; - - dbCmd.CommandText = - "ALTER TABLE gpus_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + - "ALTER TABLE memory_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + - "ALTER TABLE processors_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + - "ALTER TABLE resolutions_by_gpu ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + - "ALTER TABLE sound_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + - "ALTER TABLE storage_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;"; - - dbCmd.ExecuteNonQuery(); - trans.Commit(); - dbCmd.Dispose(); - - Console.WriteLine("Setting new database version to 23..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('23')"; - dbCmd.ExecuteNonQuery(); - dbCmd.Dispose(); - } - - void OptimizeDatabase() - { - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = "SHOW TABLES"; - var dataSet = new DataSet(); - dataAdapter.SelectCommand = dbCmd; - dataAdapter.Fill(dataSet); - - foreach(DataRow dataRow in dataSet.Tables[0].Rows) - { - string tableName = dataRow[0].ToString(); - - Console.WriteLine("Optimizing table `{0}`", tableName); - dbCmd = dbCon.CreateCommand(); - dataAdapter = dbCore.GetNewDataAdapter(); - dbCmd.CommandText = $"OPTIMIZE TABLE '{tableName}'"; - } - } - - public int GetVersion() - { - int currentDbVersion = 2; - IDbCommand dbCmd = dbCon.CreateCommand(); - IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + IDbCommand dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); dbCmd.CommandText = "SELECT * FROM marechai_db"; var dataSet = new DataSet(); dataAdapter.SelectCommand = dbCmd; @@ -2862,41 +51,2862 @@ namespace Marechai.Database foreach(DataRow dataRow in dataSet.Tables[0].Rows) { - int newId = int.Parse(dataRow["version"].ToString()); + var newId = int.Parse(dataRow["version"].ToString()); - if(newId > currentDbVersion) - currentDbVersion = newId; + if(newId > currentDbVersion) currentDbVersion = newId; + } + } + + Console.WriteLine("Database version: {0}", currentDbVersion); + + if(currentDbVersion > DB_VERSION) + { + Console.WriteLine("Current database version is higher than last supported version {0}, cannot continue...", + DB_VERSION); + + return false; + } + + if(currentDbVersion == DB_VERSION) return true; + + for(int i = currentDbVersion; i < DB_VERSION; i++) + { + switch(i) + { + case 2: + { + UpdateDatabaseToV3(); + + break; + } + case 3: + { + UpdateDatabaseToV4(); + + break; + } + case 4: + { + UpdateDatabaseToV5(); + + break; + } + case 5: + { + UpdateDatabaseToV6(); + + break; + } + case 6: + { + UpdateDatabaseToV7(); + + break; + } + case 7: + { + UpdateDatabaseToV8(); + + break; + } + case 8: + { + UpdateDatabaseToV9(); + + break; + } + case 9: + { + UpdateDatabaseToV10(); + + break; + } + case 10: + { + UpdateDatabaseToV11(); + + break; + } + case 11: + { + UpdateDatabaseToV12(); + + break; + } + case 12: + { + UpdateDatabaseToV13(); + + break; + } + case 13: + { + UpdateDatabaseToV14(); + + break; + } + case 14: + { + UpdateDatabaseToV15(); + + break; + } + case 15: + { + UpdateDatabaseToV16(); + + break; + } + case 16: + { + UpdateDatabaseToV17(); + + break; + } + case 17: + { + UpdateDatabaseToV18(); + + break; + } + case 18: + { + UpdateDatabaseToV19(); + + break; + } + case 19: + { + UpdateDatabaseToV20(); + + break; + } + case 20: + { + UpdateDatabaseToV21(); + + break; + } + case 21: + { + UpdateDatabaseToV22(); + + break; + } + case 22: + { + UpdateDatabaseToV23(); + + break; + } + case 23: + { + UpdateVersionToEntityFramework(); + + break; + } + } + } + + OptimizeDatabase(); + + return true; + } + + void UpdateDatabaseToV3() + { + Console.WriteLine("Updating database to version 3"); + + Console.WriteLine("Creating versioning table"); + IDbCommand dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = @"CREATE TABLE `marechai_db` ( + `id` INT NOT NULL AUTO_INCREMENT, + `version` INT NOT NULL, + `updated` DATETIME DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) )"; + + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming table `admin` to `admins`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `admin` RENAME TO `admins`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `browser_test.idstring` to `browser_test.user_agent`"); + dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = + @"ALTER TABLE `browser_test` CHANGE COLUMN `idstring` `user_agent` varchar(128) NOT NULL DEFAULT '';"; + + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming table `browser_test` to `browser_tests`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `browser_test` RENAME TO `browser_tests`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `Companias.Compania` to `Companias.name`"); + dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = + @"ALTER TABLE `Companias` CHANGE COLUMN `Compania` `name` varchar(128) NOT NULL DEFAULT '';"; + + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming table `Companias` to `companies`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `Companias` RENAME TO `companies`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `computers.spu` to `computers.sound_synth`"); + dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = @"ALTER TABLE `computers` CHANGE COLUMN `spu` `sound_synth` int(11) NOT NULL DEFAULT '0'"; + + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming column `computers.mpu` to `music_synth.name`"); + dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = @"ALTER TABLE `computers` CHANGE COLUMN `mpu` `music_synth` int(11) NOT NULL DEFAULT '0'"; + + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Dropping column `computers.comment`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `computers` DROP COLUMN `comment`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `consoles.name` to `consoles.model`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `consoles` CHANGE COLUMN `name` `model` char(50) NOT NULL DEFAULT ''"; + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming column `consoles.spu` to `consoles.sound_synth`"); + dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = @"ALTER TABLE `consoles` CHANGE COLUMN `spu` `sound_synth` int(11) NOT NULL DEFAULT '0'"; + + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming column `consoles.mpu` to `consoles.music_synth`"); + dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = @"ALTER TABLE `consoles` CHANGE COLUMN `mpu` `music_synth` int(11) NOT NULL DEFAULT '0'"; + + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Dropping column `consoles.comments`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `consoles` DROP COLUMN `comments`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `cpu.cpu` to `cpu.name`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `cpu` CHANGE COLUMN `cpu` `name` char(50) NOT NULL DEFAULT ''"; + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming table `cpu` to `processors`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `cpu` RENAME TO `processors`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `DSPs.DSP` to `DSPs.name`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `DSPs` CHANGE COLUMN `DSP` `name` char(50) NOT NULL DEFAULT ''"; + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming table `DSPs` to `sound_synths`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `DSPs` RENAME TO `sound_synths`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `Formatos_de_disco.Format` to `Formatos_de_disco.description`"); + dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = + @"ALTER TABLE `Formatos_de_disco` CHANGE COLUMN `Format` `description` char(50) NOT NULL DEFAULT ''"; + + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming table `Formatos_de_disco` to `disk_formats`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `Formatos_de_disco` RENAME TO `disk_formats`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `gpus.gpu` to `gpus.name`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `gpus` CHANGE COLUMN `gpu` `name` char(128) NOT NULL DEFAULT ''"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming table `money_donation` to `money_donations`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `money_donation` RENAME TO `money_donations`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming column `mpus.mpu` to `mpus.name`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `mpus` CHANGE COLUMN `mpu` `name` char(50) NOT NULL DEFAULT ''"; + dbCmd.ExecuteNonQuery(); + Console.WriteLine("Renaming table `mpus` to `music_synths`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `mpus` RENAME TO `music_synths`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming table `own_computer` to `owned_computers`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `own_computer` RENAME TO `owned_computers`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Renaming table `own_consoles` to `owned_consoles`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"ALTER TABLE `own_consoles` RENAME TO `owned_consoles`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Dropping table `procesadores_principales`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"DROP TABLE `procesadores_principales`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Getting all items from `console_company`"); + + Dictionary consoleCompanies = new(); + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from console_company"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + consoleCompanies.Add(int.Parse(dataRow["id"].ToString()), dataRow["company"].ToString()); + + Dictionary conversionEquivalents = new(); + IDbTransaction trans; + + Console.WriteLine("Converting all items from `console_company` to `companies`"); + + foreach(KeyValuePair consoleCompany in consoleCompanies) + { + dbCmd = connection.CreateCommand(); + dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = $"SELECT * from companies WHERE name LIKE '{consoleCompany.Value}'"; + dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + if(dataSet.Tables[0].Rows.Count == 1) + { + Console.WriteLine("Converting console company `{0}` to company `{1}`", + consoleCompany.Value, + dataSet.Tables[0].Rows[0]["name"]); + + conversionEquivalents.Add(consoleCompany.Key, int.Parse(dataSet.Tables[0].Rows[0]["id"].ToString())); + } + else + { + Console.Write("Adding new company `{0}`... ", consoleCompany.Value); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"INSERT INTO companies (name) VALUES ('{consoleCompany.Value}')"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + long id = core.LastInsertRowId; + Console.WriteLine("got id {0}", id); + conversionEquivalents.Add(consoleCompany.Key, (int)id); + } + } + + Console.WriteLine("Getting all items from `consoles`"); + Dictionary consoleIdAndCompanyId = new(); + dbCmd = connection.CreateCommand(); + dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT id,company from consoles"; + dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + consoleIdAndCompanyId.Add(int.Parse(dataRow["id"].ToString()), int.Parse(dataRow["company"].ToString())); + } + + trans = connection.BeginTransaction(); + + foreach(KeyValuePair keyValuePair in consoleIdAndCompanyId) + { + conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId); + + Console.WriteLine("Converting console company {0} to company {1} for console {2}... ", + keyValuePair.Value, + newId, + keyValuePair.Key); + + dbCmd = connection.CreateCommand(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"UPDATE consoles SET company = {newId} WHERE id = {keyValuePair.Key}"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + Console.WriteLine("Comitting changes..."); + trans.Commit(); + + Console.WriteLine("Moving company logos..."); + + foreach(string file in + Directory.GetFiles("wwwroot/assets/logos/computers/", "*", SearchOption.TopDirectoryOnly)) + { + string newPath = Path.Combine("wwwroot/assets/logos/", Path.GetFileName(file)); + Console.WriteLine("Moving {0} to {1}...", file, newPath); + File.Move(file, newPath); + } + + Console.WriteLine("Removing old computer company logos directory..."); + Directory.Delete("wwwroot/assets/logos/computers"); + + Console.WriteLine("Moving console company logos..."); + + foreach(string file in Directory.GetFiles("wwwroot/assets/logos/consoles/", "*", SearchOption.TopDirectoryOnly)) + { + string oldNameWithoutExtension = Path.GetFileNameWithoutExtension(file); + + if(!int.TryParse(oldNameWithoutExtension, out int oldId)) + { + Console.WriteLine("Removing stray file {0}...", file); + File.Delete(file); + + continue; } - return currentDbVersion; + conversionEquivalents.TryGetValue(oldId, out int newId); + string extension = Path.GetExtension(file); + + string newPath = Path.Combine("wwwroot/assets/logos/", $"{newId}{extension}"); + + if(File.Exists(newPath)) + { + Console.WriteLine("Removing duplicate file {0}...", file); + File.Delete(file); + } + else + { + Console.WriteLine("Moving {0} to {1}...", file, newPath); + File.Move(file, newPath); + } } - public void UpdateVersionToEntityFramework() + Console.WriteLine("Removing old console company logos directory..."); + Directory.Delete("wwwroot/assets/logos/consoles"); + + Console.WriteLine("Dropping table `console_company`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = @"DROP TABLE `console_company`;"; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Setting new database version to 3..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = @"INSERT INTO marechai_db (version) VALUES ('3')"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Finished update version to 3..."); + } + + void UpdateDatabaseToV4() + { + Console.WriteLine("Updating database to version 4"); + IDbCommand dbCmd; + IDbTransaction trans; + + if(core is Mysql) { - Console.WriteLine("Adding Entity Framework table..."); - IDbCommand dbCmd = dbCon.CreateCommand(); + Console.WriteLine("Changing table formats..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; - dbCmd.CommandText = "create table `__EFMigrationsHistory`\n" + - "(MigrationId varchar(95) not null primary key,\n" + - "ProductVersion varchar(32) not null);"; + dbCmd.CommandText = "ALTER TABLE `admins` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `browser_tests` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `marechai_db` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `companies` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `computers` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `consoles` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `disk_formats` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `forbidden` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `gpus` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `log` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `money_donations` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `music_synths` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `news` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `owned_computers` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `owned_consoles` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `processors` ROW_FORMAT = DYNAMIC;\n" + + "ALTER TABLE `sound_synths` ROW_FORMAT = DYNAMIC;\n"; dbCmd.ExecuteNonQuery(); + trans.Commit(); dbCmd.Dispose(); + } - Console.WriteLine("Adding Entity Framework first migration..."); - dbCmd = dbCon.CreateCommand(); + Console.WriteLine("Correcting primary key on table `processors`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "ALTER TABLE `processors` ADD PRIMARY KEY (id);\n" + "DROP INDEX id ON processors"; + dbCmd.ExecuteNonQuery(); - dbCmd.CommandText = "INSERT INTO marechai.`__EFMigrationsHistory` (MigrationId, ProductVersion)" + - " VALUES ('20180805214952_InitialMigration', '2.1.1-rtm-30846');"; + Console.WriteLine("Creating indexes on `admins`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX idx_admins_user ON admins (user);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + Console.WriteLine("Creating indexes on `browser_tests`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_browser_tests_user_agent ON browser_tests (user_agent);\n" + + "CREATE INDEX idx_browser_tests_browser ON browser_tests (browser);\n" + + "CREATE INDEX idx_browser_tests_version ON browser_tests (version);\n" + + "CREATE INDEX idx_browser_tests_os ON browser_tests (os);\n" + + "CREATE INDEX idx_browser_tests_platform ON browser_tests (platform);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `companies`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX idx_companies_name ON companies (name);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `computers`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_computers_company ON computers (company);\n" + + "CREATE INDEX idx_computers_year ON computers (year);\n" + + "CREATE INDEX idx_computers_model ON computers (model);\n" + + "CREATE INDEX idx_computers_cpu1 ON computers (cpu1);\n" + + "CREATE INDEX idx_computers_cpu2 ON computers (cpu2);\n" + + "CREATE INDEX idx_computers_mhz1 ON computers (mhz1);\n" + + "CREATE INDEX idx_computers_mhz2 ON computers (mhz2);\n" + + "CREATE INDEX idx_computers_bits ON computers (bits);\n" + + "CREATE INDEX idx_computers_ram ON computers (ram);\n" + + "CREATE INDEX idx_computers_rom ON computers (rom);\n" + + "CREATE INDEX idx_computers_gpu ON computers (gpu);\n" + + "CREATE INDEX idx_computers_vram ON computers (vram);\n" + + "CREATE INDEX idx_computers_colors ON computers (colors);\n" + + "CREATE INDEX idx_computers_res ON computers (res);\n" + + "CREATE INDEX idx_computers_sound_synth ON computers (sound_synth);\n" + + "CREATE INDEX idx_computers_music_synth ON computers (music_synth);\n" + + "CREATE INDEX idx_computers_hdd1 ON computers (hdd1);\n" + + "CREATE INDEX idx_computers_hdd2 ON computers (hdd2);\n" + + "CREATE INDEX idx_computers_hdd3 ON computers (hdd3);\n" + + "CREATE INDEX idx_computers_disk1 ON computers (disk1);\n" + + "CREATE INDEX idx_computers_disk2 ON computers (disk2);\n" + + "CREATE INDEX idx_computers_cap1 ON computers (cap1);\n" + + "CREATE INDEX idx_computers_cap2 ON computers (cap2);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `consoles`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_consoles_company ON consoles (company);\n" + + "CREATE INDEX idx_consoles_year ON consoles (year);\n" + + "CREATE INDEX idx_consoles_model ON consoles (model);\n" + + "CREATE INDEX idx_consoles_cpu1 ON consoles (cpu1);\n" + + "CREATE INDEX idx_consoles_cpu2 ON consoles (cpu2);\n" + + "CREATE INDEX idx_consoles_mhz1 ON consoles (mhz1);\n" + + "CREATE INDEX idx_consoles_mhz2 ON consoles (mhz2);\n" + + "CREATE INDEX idx_consoles_bits ON consoles (bits);\n" + + "CREATE INDEX idx_consoles_ram ON consoles (ram);\n" + + "CREATE INDEX idx_consoles_rom ON consoles (rom);\n" + + "CREATE INDEX idx_consoles_gpu ON consoles (gpu);\n" + + "CREATE INDEX idx_consoles_vram ON consoles (vram);\n" + + "CREATE INDEX idx_consoles_colors ON consoles (colors);\n" + + "CREATE INDEX idx_consoles_res ON consoles (res);\n" + + "CREATE INDEX idx_consoles_sound_synth ON consoles (sound_synth);\n" + + "CREATE INDEX idx_consoles_music_synth ON consoles (music_synth);\n" + + "CREATE INDEX idx_consoles_palette ON consoles (palette);\n" + + "CREATE INDEX idx_consoles_format ON consoles (format);\n" + + "CREATE INDEX idx_consoles_cap ON consoles (cap);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `disk_formats`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX idx_disk_formats_description ON disk_formats (description);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `forbidden`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_forbidden_browser ON forbidden (browser);\n" + + "CREATE INDEX idx_forbidden_date ON forbidden (date);\n" + + "CREATE INDEX idx_forbidden_ip ON forbidden (ip);\n" + + "CREATE INDEX idx_forbidden_referer ON forbidden (referer);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `gpus`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX idx_gpus_name ON gpus (name);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `log`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_log_browser ON log (browser);\n" + + "CREATE INDEX idx_log_date ON log (date);\n" + + "CREATE INDEX idx_log_ip ON log (ip);\n" + + "CREATE INDEX idx_log_referer ON log (referer);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `money_donations`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_money_donations_donator ON money_donations (donator);\n" + + "CREATE INDEX idx_money_donations_quantity ON money_donations (quantity);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `music_synths`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX idx_music_synts_name ON music_synths (name);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `news`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_news_date ON news (date);\n" + + "CREATE INDEX idx_news_type ON news (type);\n" + + "CREATE INDEX idx_news_ip ON news (added_id);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `owned_computers`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_owned_computers_db_id ON owned_computers (db_id);\n" + + "CREATE INDEX idx_owned_computers_date ON owned_computers (date);\n" + + "CREATE INDEX idx_owned_computers_status ON owned_computers (status);\n" + + "CREATE INDEX idx_owned_computers_trade ON owned_computers (trade);\n" + + "CREATE INDEX idx_owned_computers_boxed ON owned_computers (boxed);\n" + + "CREATE INDEX idx_owned_computers_manuals ON owned_computers (manuals);\n" + + "CREATE INDEX idx_owned_computers_cpu1 ON owned_computers (cpu1);\n" + + "CREATE INDEX idx_owned_computers_cpu2 ON owned_computers (cpu2);\n" + + "CREATE INDEX idx_owned_computers_mhz1 ON owned_computers (mhz1);\n" + + "CREATE INDEX idx_owned_computers_mhz2 ON owned_computers (mhz2);\n" + + "CREATE INDEX idx_owned_computers_ram ON owned_computers (ram);\n" + + "CREATE INDEX idx_owned_computers_vram ON owned_computers (vram);\n" + + "CREATE INDEX idx_owned_computers_rigid ON owned_computers (rigid);\n" + + "CREATE INDEX idx_owned_computers_disk1 ON owned_computers (disk1);\n" + + "CREATE INDEX idx_owned_computers_disk2 ON owned_computers (disk2);\n" + + "CREATE INDEX idx_owned_computers_cap1 ON owned_computers (cap1);\n" + + "CREATE INDEX idx_owned_computers_cap2 ON owned_computers (cap2);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `owned_consoles`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX idx_owned_consoles_db_id ON owned_consoles (db_id);\n" + + "CREATE INDEX idx_owned_consoles_date ON owned_consoles (date);\n" + + "CREATE INDEX idx_owned_consoles_status ON owned_consoles (status);\n" + + "CREATE INDEX idx_owned_consoles_trade ON owned_consoles (trade);\n" + + "CREATE INDEX idx_owned_consoles_boxed ON owned_consoles (boxed);\n" + + "CREATE INDEX idx_owned_consoles_manuals ON owned_consoles (manuals);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `processors`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX idx_processors_name ON processors (name);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating indexes on `sound_synths`..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX idx_sound_synths_name ON sound_synths (name);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 4..."); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('4')"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV5() + { + Console.WriteLine("Updating database to version 5"); + + Console.WriteLine("Creating foreign keys for table `computers`"); + IDbCommand dbCmd = connection.CreateCommand(); + dbCmd.CommandText = V5.ComputersForeignKeys; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + + Console.WriteLine("Creating foreign keys for table `consoles`"); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = V5.ConsolesForeignKeys; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 5..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('5')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV6() + { + Console.WriteLine("Updating database to version 6"); + + Console.WriteLine("Creating table `iso3166_1_numeric`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V6.Iso3166Numeric; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Filling table `iso3166_1_numeric`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V6.Iso3166NumericValues; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new columns to table `companies`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `companies` ADD COLUMN `founded` DATETIME NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `website` VARCHAR(255) NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `twitter` VARCHAR(45) NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `facebook` VARCHAR(45) NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `sold` DATETIME NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `sold_to` INT(11) NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `address` VARCHAR(80) NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `city` VARCHAR(80) NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `province` VARCHAR(80) NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `postal_code` VARCHAR(25) NULL;\n" + + "ALTER TABLE `companies` ADD COLUMN `country` SMALLINT(3) UNSIGNED ZEROFILL NULL;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new indexes to table `companies`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX `idx_companies_founded` ON `companies` (`founded`);\n" + + "CREATE INDEX `idx_companies_website` ON `companies` (`website`);\n" + + "CREATE INDEX `idx_companies_twitter` ON `companies` (`twitter`);\n" + + "CREATE INDEX `idx_companies_facebook` ON `companies` (`facebook`);\n" + + "CREATE INDEX `idx_companies_sold` ON `companies` (`sold`);\n" + + "CREATE INDEX `idx_companies_sold_to` ON `companies` (`sold_to`);\n" + + "CREATE INDEX `idx_companies_address` ON `companies` (`address`);\n" + + "CREATE INDEX `idx_companies_city` ON `companies` (`city`);\n" + + "CREATE INDEX `idx_companies_province` ON `companies` (`province`);\n" + + "CREATE INDEX `idx_companies_postal_code` ON `companies` (`postal_code`);\n" + + "CREATE INDEX `idx_companies_country` ON `companies` (`country`);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new foreign keys to table `companies`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_sold_to` (sold_to) REFERENCES `companies` (`id`);\n" + + "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_country` (country) REFERENCES `iso3166_1_numeric` (`id`);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 6..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('6')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV7() + { + Console.WriteLine("Updating database to version 7"); + + Console.WriteLine("Adding new columns to table `companies`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `companies` ADD COLUMN `status` INT NOT NULL;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new indexes to table `companies`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX `idx_companies_status` ON `companies` (`status`);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 7..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('7')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV8() + { + Console.WriteLine("Updating database to version 8"); + + Console.WriteLine("Creating table `company_logos`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V8.CompanyLogos; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 8..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('8')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV9() + { + Console.WriteLine("Updating database to version 9"); + + Console.WriteLine("Creating table `company_descriptions`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V9.CompanyDescriptions; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 9..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('9')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV10() + { + Console.WriteLine("Updating database to version 10"); + + Console.WriteLine("Creating table `instruction_sets`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V10.InstructionSets; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating table `instruction_set_extensions`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V10.InstructionSetExtensions; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating table `instruction_set_extensions_by_processor`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V10.InstructionSetExtensionsByProcessor; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new columns to table `processors`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `processors` ADD COLUMN `company` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `model_code` VARCHAR(45) NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `introduced` DATETIME NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `instruction_set` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `speed` DOUBLE NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `package` VARCHAR(45) NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `GPRs` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `GPR_size` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `FPRs` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `FPR_size` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `cores` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `threads_per_core` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `process` VARCHAR(45) NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `process_nm` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `die_size` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `transistors` BIGINT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `data_bus` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `addr_bus` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `SIMD_registers` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `SIMD_size` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `L1_instruction` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `L1_data` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `L2` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `L3` FLOAT NULL;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new indexes to table `processors`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX `idx_processors_company` ON `processors` (`company`);\n" + + "CREATE INDEX `idx_processors_model_code` ON `processors` (`model_code`);\n" + + "CREATE INDEX `idx_processors_introduced` ON `processors` (`introduced`);\n" + + "CREATE INDEX `idx_processors_instruction_set` ON `processors` (`instruction_set`);\n" + + "CREATE INDEX `idx_processors_speed` ON `processors` (`speed`);\n" + + "CREATE INDEX `idx_processors_package` ON `processors` (`package`);\n" + + "CREATE INDEX `idx_processors_GPRs` ON `processors` (`GPRs`);\n" + + "CREATE INDEX `idx_processors_GPR_size` ON `processors` (`GPR_size`);\n" + + "CREATE INDEX `idx_processors_FPRs` ON `processors` (`FPRs`);\n" + + "CREATE INDEX `idx_processors_FPR_size` ON `processors` (`FPR_size`);\n" + + "CREATE INDEX `idx_processors_cores` ON `processors` (`cores`);\n" + + "CREATE INDEX `idx_processors_threads_per_core` ON `processors` (`threads_per_core`);\n" + + "CREATE INDEX `idx_processors_process` ON `processors` (`process`);\n" + + "CREATE INDEX `idx_processors_process_nm` ON `processors` (`process_nm`);\n" + + "CREATE INDEX `idx_processors_die_size` ON `processors` (`die_size`);\n" + + "CREATE INDEX `idx_processors_transistors` ON `processors` (`transistors`);\n" + + "CREATE INDEX `idx_processors_data_bus` ON `processors` (`data_bus`);\n" + + "CREATE INDEX `idx_processors_addr_bus` ON `processors` (`addr_bus`);\n" + + "CREATE INDEX `idx_processors_SIMD_registers` ON `processors` (`SIMD_registers`);\n" + + "CREATE INDEX `idx_processors_SIMD_size` ON `processors` (`SIMD_size`);\n" + + "CREATE INDEX `idx_processors_L1_instruction` ON `processors` (`L1_instruction`);\n" + + "CREATE INDEX `idx_processors_L1_data` ON `processors` (`L1_data`);\n" + + "CREATE INDEX `idx_processors_L2` ON `processors` (`L2`);\n" + + "CREATE INDEX `idx_processors_L3` ON `processors` (`L3`);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new foreign keys to table `processors`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `processors` ADD FOREIGN KEY `fk_processors_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `processors` ADD FOREIGN KEY `fk_processors_instruction_set` (instruction_set) REFERENCES `instruction_sets` (`id`) ON UPDATE CASCADE;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 10..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('10')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV11() + { + Console.WriteLine("Updating database to version 11"); + + Console.WriteLine("Adding new columns to table `gpus`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `gpus` ADD COLUMN `company` INT NULL;\n" + + "ALTER TABLE `gpus` ADD COLUMN `model_code` VARCHAR(45) NULL;\n" + + "ALTER TABLE `gpus` ADD COLUMN `introduced` DATETIME NULL;\n" + + "ALTER TABLE `gpus` ADD COLUMN `package` VARCHAR(45) NULL;\n" + + "ALTER TABLE `gpus` ADD COLUMN `process` VARCHAR(45) NULL;\n" + + "ALTER TABLE `gpus` ADD COLUMN `process_nm` FLOAT NULL;\n" + + "ALTER TABLE `gpus` ADD COLUMN `die_size` FLOAT NULL;\n" + + "ALTER TABLE `gpus` ADD COLUMN `transistors` BIGINT NULL;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new indexes to table `gpus`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX `idx_gpus_company` ON `gpus` (`company`);\n" + + "CREATE INDEX `idx_gpus_model_code` ON `gpus` (`model_code`);\n" + + "CREATE INDEX `idx_gpus_introduced` ON `gpus` (`introduced`);\n" + + "CREATE INDEX `idx_gpus_package` ON `gpus` (`package`);\n" + + "CREATE INDEX `idx_gpus_process` ON `gpus` (`process`);\n" + + "CREATE INDEX `idx_gpus_process_nm` ON `gpus` (`process_nm`);\n" + + "CREATE INDEX `idx_gpus_die_size` ON `gpus` (`die_size`);\n" + + "CREATE INDEX `idx_gpus_transistors` ON `gpus` (`transistors`);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new foreign keys to table `gpus`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `gpus` ADD FOREIGN KEY `fk_gpus_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 11..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('11')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV12() + { + Console.WriteLine("Updating database to version 12"); + + Console.WriteLine("Altering colums from table `computers`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `computers` CHANGE COLUMN `gpu` `gpu` INT DEFAULT NULL;\n" + + "ALTER TABLE `computers` CHANGE COLUMN `cpu1` `cpu1` INT DEFAULT NULL;\n" + + "ALTER TABLE `computers` CHANGE COLUMN `mhz1` `mhz1` INT DEFAULT NULL;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Altering colums from table `consoles`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `consoles` CHANGE COLUMN `gpu` `gpu` INT DEFAULT NULL;\n" + + "ALTER TABLE `consoles` CHANGE COLUMN `cpu1` `cpu1` INT DEFAULT NULL;\n" + + "ALTER TABLE `consoles` CHANGE COLUMN `mhz1` `mhz1` INT DEFAULT NULL;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new special items to table `gpus`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = $"INSERT INTO `gpus` (`id`, `name`) VALUES ({DbNone}, 'DB_NONE');\n" + + $"INSERT INTO `gpus` (`id`, `name`) VALUES ({DbSoftware}, 'DB_FRAMEBUFFER');"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Updating items from table `computers`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = $"UPDATE `computers` SET `gpu` = {DbNone} WHERE `gpu` = 1;\n" + + "UPDATE `computers` SET `gpu` = NULL WHERE `gpu` = 2;\n" + + $"UPDATE `computers` SET `gpu` = {DbSoftware} WHERE `gpu` = 3;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Updating items from table `consoles`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = $"UPDATE `consoles` SET `gpu` = {DbNone} WHERE `gpu` = 1;\n" + + "UPDATE `consoles` SET `gpu` = NULL WHERE `gpu` = 2;\n" + + $"UPDATE `consoles` SET `gpu` = {DbSoftware} WHERE `gpu` = 3;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Remocing old special items from table `gpus`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "DELETE FROM `gpus` WHERE `id` = 1;\n" + + "DELETE FROM `gpus` WHERE `id` = 2;\n" + + "DELETE FROM `gpus` WHERE `id` = 3;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 12..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('12')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV13() + { + Console.WriteLine("Updating database to version 13"); + + Console.WriteLine("Adding new columns to table `sound_synths`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `sound_synths` ADD COLUMN `company` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `model_code` VARCHAR(45) NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `introduced` DATETIME NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `voices` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `frequency` DOUBLE NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `depth` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `square_wave` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `white_noise` INT NULL;\n" + + "ALTER TABLE `sound_synths` ADD COLUMN `type` INT NULL;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating new indexes in table `sound_synths`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX `idx_sound_synths_company` ON `sound_synths` (`company`);\n" + + "CREATE INDEX `idx_sound_synths_model_code` ON `sound_synths` (`model_code`);\n" + + "CREATE INDEX `idx_sound_synths_introduced` ON `sound_synths` (`introduced`);\n" + + "CREATE INDEX `idx_sound_synths_voices` ON `sound_synths` (`voices`);\n" + + "CREATE INDEX `idx_sound_synths_frequency` ON `sound_synths` (`frequency`);\n" + + "CREATE INDEX `idx_sound_synths_depth` ON `sound_synths` (`depth`);\n" + + "CREATE INDEX `idx_sound_synths_square_wave` ON `sound_synths` (`square_wave`);\n" + + "CREATE INDEX `idx_sound_synths_white_noise` ON `sound_synths` (`white_noise`);\n" + + "CREATE INDEX `idx_sound_synths_type` ON `sound_synths` (`type`);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating foreign keys in table `sound_synths`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `sound_synths` ADD FOREIGN KEY `fk_sound_synths_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Dropping foreign keys from tables `computers` and `consoles`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `computers` DROP FOREIGN KEY `fk_computers_music_synth`;\n" + + "ALTER TABLE `consoles` DROP FOREIGN KEY `fk_consoles_music_synth`;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `music_synths`"); + + Dictionary musicSynths = new(); + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from music_synths"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + musicSynths.Add(int.Parse(dataRow["id"].ToString()), dataRow["name"].ToString()); + + Dictionary conversionEquivalents = new(); + + Console.WriteLine("Converting all items from `music_synths` to `sound_synths`"); + + foreach(KeyValuePair musicSynth in musicSynths) + { + dbCmd = connection.CreateCommand(); + dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = $"SELECT * from sound_synths WHERE name LIKE '{musicSynth.Value}'"; + dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + if(dataSet.Tables[0].Rows.Count == 1) + { + Console.WriteLine("Converting music synth `{0}` to sound synth `{1}`", + musicSynth.Value, + dataSet.Tables[0].Rows[0]["name"]); + + conversionEquivalents.Add(musicSynth.Key, int.Parse(dataSet.Tables[0].Rows[0]["id"].ToString())); + } + else + { + Console.Write("Adding new sound synth `{0}`... ", musicSynth.Value); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"INSERT INTO sound_synths (name) VALUES ('{musicSynth.Value}')"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + long id = core.LastInsertRowId; + Console.WriteLine("got id {0}", id); + conversionEquivalents.Add(musicSynth.Key, (int)id); + } + } + + Console.WriteLine("Getting all items from `consoles`"); + Dictionary consoleIdAndMusicSynthId = new(); + dbCmd = connection.CreateCommand(); + dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT id,music_synth from consoles"; + dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + consoleIdAndMusicSynthId.Add(int.Parse(dataRow["id"].ToString()), + int.Parse(dataRow["music_synth"].ToString())); + } + + trans = connection.BeginTransaction(); + + foreach(KeyValuePair keyValuePair in consoleIdAndMusicSynthId) + { + conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId); + + Console.WriteLine("Converting music synth {0} to sound synth {1} for console {2}... ", + keyValuePair.Value, + newId, + keyValuePair.Key); + + dbCmd = connection.CreateCommand(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"UPDATE consoles SET music_synth = {newId} WHERE id = {keyValuePair.Key}"; dbCmd.ExecuteNonQuery(); dbCmd.Dispose(); + } - Console.WriteLine("Setting new database version to 1984 (Entity Framework)..."); - dbCmd = dbCon.CreateCommand(); - dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('1984')"; + Console.WriteLine("Comitting changes..."); + trans.Commit(); + + Console.WriteLine("Getting all items from `computers`"); + Dictionary computerIdAndMusicSynthId = new(); + dbCmd = connection.CreateCommand(); + dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT id,music_synth from computers"; + dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + computerIdAndMusicSynthId.Add(int.Parse(dataRow["id"].ToString()), + int.Parse(dataRow["music_synth"].ToString())); + } + + trans = connection.BeginTransaction(); + + foreach(KeyValuePair keyValuePair in computerIdAndMusicSynthId) + { + conversionEquivalents.TryGetValue(keyValuePair.Value, out int newId); + + Console.WriteLine("Converting music synth {0} to sound synth {1} for computer {2}... ", + keyValuePair.Value, + newId, + keyValuePair.Key); + + dbCmd = connection.CreateCommand(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"UPDATE computers SET music_synth = {newId} WHERE id = {keyValuePair.Key}"; dbCmd.ExecuteNonQuery(); dbCmd.Dispose(); } + + Console.WriteLine("Comitting changes..."); + trans.Commit(); + + Console.WriteLine("Adding new foreign keys to table `computers`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `computers` ADD FOREIGN KEY `fk_computers_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new foreign keys to table `consoles`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `consoles` ADD FOREIGN KEY `fk_consoles_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Dropping table `music_synths`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "DROP TABLE `music_synths`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 13..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('13')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV14() + { + Console.WriteLine("Updating database to version 14"); + + Console.WriteLine("Renaming table `computers` to `machines`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `computers` RENAME TO `machines`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Removing column `bits` from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `bits`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating column `type` in table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + $"ALTER TABLE `machines` ADD COLUMN `type` INT NOT NULL DEFAULT '{(int)MachineType.Unknown}';"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Updating all entries in table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"UPDATE `machines` SET `type` = '{(int)MachineType.Computer}';"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Renaming all indexes on table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `machines` DROP INDEX `idx_computers_company`, ADD INDEX `idx_machines_company` (`company`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_year`, ADD INDEX `idx_machines_year` (`year`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_model`, ADD INDEX `idx_machines_model` (`model`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_cpu1`, ADD INDEX `idx_machines_cpu1` (`cpu1`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_cpu2`, ADD INDEX `idx_machines_cpu2` (`cpu2`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_mhz1`, ADD INDEX `idx_machines_mhz1` (`mhz1`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_mhz2`, ADD INDEX `idx_machines_mhz2` (`mhz2`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_ram`, ADD INDEX `idx_machines_ram` (`ram`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_rom`, ADD INDEX `idx_machines_rom` (`rom`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_gpu`, ADD INDEX `idx_machines_gpu` (`gpu`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_vram`, ADD INDEX `idx_machines_vram` (`vram`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_colors`, ADD INDEX `idx_machines_colors` (`colors`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_res`, ADD INDEX `idx_machines_res` (`res`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_sound_synth`, ADD INDEX `idx_machines_sound_synth` (`sound_synth`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_music_synth`, ADD INDEX `idx_machines_music_synth` (`music_synth`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_hdd1`, ADD INDEX `idx_machines_hdd1` (`hdd1`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_hdd2`, ADD INDEX `idx_machines_hdd2` (`hdd2`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_hdd3`, ADD INDEX `idx_machines_hdd3` (`hdd3`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_disk1`, ADD INDEX `idx_machines_disk1` (`disk1`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_disk2`, ADD INDEX `idx_machines_disk2` (`disk2`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_cap1`, ADD INDEX `idx_machines_cap1` (`cap1`);\n" + + "ALTER TABLE `machines` DROP INDEX `idx_computers_cap2`, ADD INDEX `idx_machines_cap2` (`cap2`);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Removing old foreign keys from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_company`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_cpu1`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_cpu2`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_disk1`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_disk2`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_gpu`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_hdd1`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_hdd2`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_hdd3`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_music_synth`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_computers_sound_synth`;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding foreign keys in table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_cpu1` (cpu1) REFERENCES `processors` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_cpu2` (cpu2) REFERENCES `processors` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_gpu` (gpu) REFERENCES `gpus` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_sound_synth` (sound_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new index for `type` in table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "CREATE INDEX `idx_machines_type` ON `machines` (`type`);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `consoles`"); + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from consoles"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + IDbCommand dbcmd = connection.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + IDbDataParameter param3 = dbcmd.CreateParameter(); + IDbDataParameter param4 = dbcmd.CreateParameter(); + IDbDataParameter param5 = dbcmd.CreateParameter(); + IDbDataParameter param6 = dbcmd.CreateParameter(); + IDbDataParameter param7 = dbcmd.CreateParameter(); + IDbDataParameter param8 = dbcmd.CreateParameter(); + IDbDataParameter param9 = dbcmd.CreateParameter(); + IDbDataParameter param10 = dbcmd.CreateParameter(); + IDbDataParameter param11 = dbcmd.CreateParameter(); + IDbDataParameter param12 = dbcmd.CreateParameter(); + IDbDataParameter param13 = dbcmd.CreateParameter(); + IDbDataParameter param14 = dbcmd.CreateParameter(); + IDbDataParameter param15 = dbcmd.CreateParameter(); + IDbDataParameter param16 = dbcmd.CreateParameter(); + IDbDataParameter param17 = dbcmd.CreateParameter(); + IDbDataParameter param18 = dbcmd.CreateParameter(); + IDbDataParameter param19 = dbcmd.CreateParameter(); + IDbDataParameter param20 = dbcmd.CreateParameter(); + IDbDataParameter param21 = dbcmd.CreateParameter(); + + param1.ParameterName = "@company"; + param2.ParameterName = "@year"; + param3.ParameterName = "@model"; + param4.ParameterName = "@cpu1"; + param5.ParameterName = "@mhz1"; + param6.ParameterName = "@cpu2"; + param7.ParameterName = "@mhz2"; + param8.ParameterName = "@ram"; + param9.ParameterName = "@rom"; + param10.ParameterName = "@gpu"; + param11.ParameterName = "@vram"; + param12.ParameterName = "@colors"; + param13.ParameterName = "@res"; + param14.ParameterName = "@sound_synth"; + param15.ParameterName = "@music_synth"; + param16.ParameterName = "@sound_channels"; + param17.ParameterName = "@music_channels"; + param18.ParameterName = "@type"; + param19.ParameterName = "@hdd1"; + param20.ParameterName = "@disk1"; + param21.ParameterName = "@cap1"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + param3.DbType = DbType.String; + param4.DbType = DbType.Int32; + param5.DbType = DbType.Double; + param6.DbType = DbType.Int32; + param7.DbType = DbType.Double; + param8.DbType = DbType.Int32; + param9.DbType = DbType.Int32; + param10.DbType = DbType.Int32; + param11.DbType = DbType.Int32; + param12.DbType = DbType.Int32; + param13.DbType = DbType.String; + param14.DbType = DbType.Int32; + param15.DbType = DbType.Int32; + param16.DbType = DbType.Int32; + param17.DbType = DbType.Int32; + param18.DbType = DbType.Int32; + param19.DbType = DbType.Int32; + param20.DbType = DbType.Int32; + param21.DbType = DbType.Int32; + + param1.Value = (int)dataRow["company"]; + param2.Value = (int)dataRow["year"]; + param3.Value = (string)dataRow["model"]; + param4.Value = dataRow["cpu1"] == DBNull.Value ? null : (int)dataRow["cpu1"]; + + param5.Value = dataRow["mhz1"] == DBNull.Value ? null : float.Parse(dataRow["mhz1"].ToString()); + + param6.Value = dataRow["cpu2"] == DBNull.Value ? null : (int)dataRow["cpu2"]; + + param7.Value = dataRow["mhz2"] == DBNull.Value ? null : float.Parse(dataRow["mhz2"].ToString()); + + param8.Value = (int)dataRow["ram"]; + param9.Value = (int)dataRow["rom"]; + param10.Value = dataRow["gpu"] == DBNull.Value ? null : (int)dataRow["gpu"]; + param11.Value = (int)dataRow["vram"]; + param12.Value = (int)dataRow["colors"]; + param13.Value = (string)dataRow["res"]; + param14.Value = (int)dataRow["sound_synth"]; + param15.Value = (int)dataRow["music_synth"]; + param16.Value = (int)dataRow["schannels"]; + param17.Value = (int)dataRow["mchannels"]; + param18.Value = MachineType.Console; + param19.Value = 30; + param20.Value = 30; + param21.Value = 0; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + dbcmd.Parameters.Add(param3); + dbcmd.Parameters.Add(param4); + dbcmd.Parameters.Add(param5); + dbcmd.Parameters.Add(param6); + dbcmd.Parameters.Add(param7); + dbcmd.Parameters.Add(param8); + dbcmd.Parameters.Add(param9); + dbcmd.Parameters.Add(param10); + dbcmd.Parameters.Add(param11); + dbcmd.Parameters.Add(param12); + dbcmd.Parameters.Add(param13); + dbcmd.Parameters.Add(param14); + dbcmd.Parameters.Add(param15); + dbcmd.Parameters.Add(param16); + dbcmd.Parameters.Add(param17); + dbcmd.Parameters.Add(param18); + dbcmd.Parameters.Add(param19); + dbcmd.Parameters.Add(param20); + dbcmd.Parameters.Add(param21); + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Converting console \"{0}\" to machine", (string)param3.Value); + + const string sql = + "INSERT INTO machines (company, year, model, cpu1, mhz1, cpu2, mhz2, ram, rom, gpu, vram, colors, res, sound_synth, music_synth, sound_channels, music_channels, type, hdd1, disk1, cap1)" + + " VALUES (@company, @year, @model, @cpu1, @mhz1, @cpu2, @mhz2, @ram, @rom, @gpu, @vram, @colors, @res, @sound_synth, @music_synth, @sound_channels, @music_channels, @type, @hdd1, @disk1, @cap1)"; + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + } + + Console.WriteLine("Dropping table `consoles`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "DROP TABLE `consoles`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 14..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('14')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV15() + { + Console.WriteLine("Updating database to version 15"); + + Console.WriteLine("Creating table `processors_by_machine`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V15.ProcessorsByMachine; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `machines`"); + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from machines"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + IDbCommand dbcmd = connection.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + IDbDataParameter param3 = dbcmd.CreateParameter(); + + param1.ParameterName = "@machine"; + param2.ParameterName = "@processor"; + param3.ParameterName = "@speed"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + param3.DbType = DbType.Double; + + param1.Value = (int)dataRow["id"]; + + const string sql = + "INSERT INTO processors_by_machine (machine, processor, speed) VALUES (@machine, @processor, @speed)"; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + dbcmd.Parameters.Add(param3); + + if(dataRow["cpu1"] != DBNull.Value) + { + param2.Value = (int)dataRow["cpu1"]; + + param3.Value = dataRow["mhz1"] == DBNull.Value ? null : float.Parse(dataRow["mhz1"].ToString()); + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding processor {0} to machine {1}", (int)param2.Value, (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + if(dataRow["cpu2"] != DBNull.Value) + { + param2.Value = (int)dataRow["cpu2"]; + + param3.Value = dataRow["mhz2"] == DBNull.Value ? null : float.Parse(dataRow["mhz2"].ToString()); + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding processor {0} to machine {1}", (int)param2.Value, (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + dbcmd.Dispose(); + } + + Console.WriteLine("Removing processor columns from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_cpu1`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_cpu2`;\n" + + "ALTER TABLE `machines` DROP COLUMN `cpu1`;\n" + + "ALTER TABLE `machines` DROP COLUMN `cpu2`;\n" + + "ALTER TABLE `machines` DROP COLUMN `mhz1`;\n" + + "ALTER TABLE `machines` DROP COLUMN `mhz2`;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 15..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('15')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV16() + { + Console.WriteLine("Updating database to version 16"); + + Console.WriteLine("Creating table `gpus_by_machine`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V16.GpusByMachine; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `machines`"); + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from machines"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + IDbCommand dbcmd = connection.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + + param1.ParameterName = "@machine"; + param2.ParameterName = "@gpu"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + + param1.Value = (int)dataRow["id"]; + + const string sql = "INSERT INTO gpus_by_machine (machine, gpu) VALUES (@machine, @gpu)"; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + + if(dataRow["gpu"] != DBNull.Value) + { + param2.Value = (int)dataRow["gpu"]; + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding gpu {0} to machine {1}", (int)param2.Value, (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + dbcmd.Dispose(); + } + + Console.WriteLine("Removing processor columns from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_gpu`;\n" + + "ALTER TABLE `machines` DROP COLUMN `gpu`;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 16..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('16')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV17() + { + Console.WriteLine("Updating database to version 17"); + + Console.WriteLine("Creating table `sound_by_machine`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V17.SoundByMachine; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new special items to table `sound_synths`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = $"INSERT INTO `sound_synths` (`id`, `name`) VALUES ({DbSoftware}, 'DB_SOFTWARE');"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Changing sound and music synths in machine from 27 to {0}", DbSoftware); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = $"UPDATE `machines` SET sound_synth = {DbSoftware} WHERE sound_synth = 27;\n" + + $"UPDATE `machines` SET music_synth = {DbSoftware} WHERE music_synth = 27;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `machines`"); + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from machines"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + IDbCommand dbcmd = connection.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + + param1.ParameterName = "@machine"; + param2.ParameterName = "@sound_synth"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + + param1.Value = (int)dataRow["id"]; + + const string sql = "INSERT INTO sound_by_machine (machine, sound_synth) VALUES (@machine, @sound_synth)"; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + + if(dataRow["sound_synth"] != DBNull.Value && + (int)dataRow["sound_synth"] != 1 && + (int)dataRow["sound_synth"] != 2) + { + param2.Value = (int)dataRow["sound_synth"]; + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding sound {0} to machine {1}", (int)param2.Value, (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + if(dataRow["music_synth"] != DBNull.Value && + (int)dataRow["music_synth"] != 1 && + (int)dataRow["music_synth"] != 2) + { + param2.Value = (int)dataRow["music_synth"]; + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding sound {0} to machine {1}", (int)param2.Value, (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + dbcmd.Dispose(); + } + + Console.WriteLine("Removing sound columns from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_sound_synth`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_music_synth`;\n" + + "ALTER TABLE `machines` DROP COLUMN `sound_channels`;\n" + + "ALTER TABLE `machines` DROP COLUMN `music_channels`;\n" + + "ALTER TABLE `machines` DROP COLUMN `sound_synth`;\n" + + "ALTER TABLE `machines` DROP COLUMN `music_synth`;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Removing old sound items `sound_synths`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "DELETE FROM sound_synths WHERE id = 1;\n" + + "DELETE FROM sound_synths WHERE id = 2;\n" + + "DELETE FROM sound_synths WHERE id = 27;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 17..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('17')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV18() + { + Console.WriteLine("Updating database to version 18"); + + Console.WriteLine("Creating table `memory_by_machine`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V18.MemoryByMachine; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `machines`"); + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from machines"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + IDbCommand dbcmd = connection.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + IDbDataParameter param3 = dbcmd.CreateParameter(); + + param1.ParameterName = "@machine"; + param2.ParameterName = "@usage"; + param3.ParameterName = "@size"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + param3.DbType = DbType.Int64; + + param1.Value = (int)dataRow["id"]; + + const string sql = + "INSERT INTO `memory_by_machine` (`machine`, `usage`, `size`) VALUES (@machine, @usage, @size)"; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + dbcmd.Parameters.Add(param3); + + if(dataRow["ram"] != DBNull.Value && (int)dataRow["ram"] > 0) + { + param2.Value = MemoryUsage.Work; + param3.Value = (int)dataRow["ram"] * 1024; + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", + (int)param3.Value, + MemoryUsage.Work, + (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + if(dataRow["rom"] != DBNull.Value && (int)dataRow["rom"] > 0) + { + param2.Value = MemoryUsage.Firmware; + param3.Value = (int)dataRow["rom"] * 1024; + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", + (int)param3.Value, + MemoryUsage.Firmware, + (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + if(dataRow["vram"] != DBNull.Value && (int)dataRow["vram"] > 0) + { + param2.Value = MemoryUsage.Video; + param3.Value = (int)dataRow["vram"] * 1024; + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding {0} bytes of {1} memory to machine {2}", + (int)param3.Value, + MemoryUsage.Video, + (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + dbcmd.Dispose(); + } + + Console.WriteLine("Removing memory columns from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `ram`;\n" + + "ALTER TABLE `machines` DROP COLUMN `rom`;\n" + + "ALTER TABLE `machines` DROP COLUMN `vram`;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 18..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('18')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV19() + { + Console.WriteLine("Updating database to version 19"); + + Console.WriteLine("Creating table `resolutions`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V19.Resolutions; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating table `resolutions_by_gpu`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V19.ResolutionsByGpu; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `machines`"); + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from machines"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + if(dataRow["colors"] == DBNull.Value || + dataRow["res"] == DBNull.Value || + (int)dataRow["colors"] == 0 || + (string)dataRow["res"] == "???") + continue; + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter2 = core.GetNewDataAdapter(); + dbCmd.CommandText = $"SELECT * FROM gpus_by_machine WHERE machine = {(int)dataRow["id"]}"; + var dataSet2 = new DataSet(); + dataAdapter2.SelectCommand = dbCmd; + dataAdapter2.Fill(dataSet2); + + if(dataSet2.Tables[0].Rows.Count == 0) continue; + + var gpuId = (int)dataSet2.Tables[0].Rows[0]["gpu"]; + + string[] resPieces = ((string)dataRow["res"]).Split('x'); + + if(!int.TryParse(resPieces[0], out int width)) continue; + + if(!int.TryParse(resPieces[1], out int height)) continue; + + dbCmd = connection.CreateCommand(); + dataAdapter2 = core.GetNewDataAdapter(); + + dbCmd.CommandText = + $"SELECT * FROM resolutions WHERE width = {width} AND height = {height} AND colors = {(int)dataRow["colors"]}"; + + dataSet2 = new DataSet(); + dataAdapter2.SelectCommand = dbCmd; + dataAdapter2.Fill(dataSet2); + + int resId; + string sql; + + IDbCommand dbcmd = connection.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + IDbDataParameter param3 = dbcmd.CreateParameter(); + + if(dataSet2.Tables[0].Rows.Count == 0) + { + param1.ParameterName = "@width"; + param2.ParameterName = "@height"; + param3.ParameterName = "@colors"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + param3.DbType = DbType.Int64; + + param1.Value = width; + param2.Value = height; + param3.Value = (int)dataRow["colors"]; + + sql = "INSERT INTO `resolutions` (`width`, `height`, `colors`) VALUES (@width, @height, @colors)"; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + dbcmd.Parameters.Add(param3); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + dbcmd.Dispose(); + + resId = (int)core.LastInsertRowId; + } + else + resId = (int)dataSet2.Tables[0].Rows[0]["id"]; + + dbcmd = connection.CreateCommand(); + + param1 = dbcmd.CreateParameter(); + param2 = dbcmd.CreateParameter(); + + param1.ParameterName = "@gpu"; + param2.ParameterName = "@resolution"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + + param1.Value = gpuId; + param2.Value = resId; + + sql = "INSERT INTO `resolutions_by_gpu` (`gpu`, `resolution`) VALUES (@gpu, @resolution)"; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + dbcmd.Dispose(); + } + + Console.WriteLine("Removing resolution columns from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `res`;\n" + + "ALTER TABLE `machines` DROP COLUMN `colors`;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 19..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('19')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV20() + { + Console.WriteLine("Updating database to version 20"); + + Console.WriteLine("Creating table `storage_by_machine`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V20.StorageByMachine; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `machines`"); + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from machines"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + IDbCommand dbcmd = connection.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + IDbDataParameter param3 = dbcmd.CreateParameter(); + IDbDataParameter param4 = dbcmd.CreateParameter(); + + param1.ParameterName = "@machine"; + param2.ParameterName = "@type"; + param3.ParameterName = "@interface"; + param4.ParameterName = "@capacity"; + + param1.DbType = DbType.Int32; + param2.DbType = DbType.Int32; + param3.DbType = DbType.Int32; + param4.DbType = DbType.Int64; + + param1.Value = (int)dataRow["id"]; + + const string sql = + "INSERT INTO `storage_by_machine` (`machine`, `type`, `interface`, `capacity`) VALUES (@machine, @type, @interface, @capacity)"; + + dbcmd.Parameters.Add(param1); + dbcmd.Parameters.Add(param2); + dbcmd.Parameters.Add(param3); + dbcmd.Parameters.Add(param4); + + foreach(string media in new[] + { + "hdd1", "hdd2", "hdd3", "disk1", "disk2" + }) + { + if(dataRow[media] == DBNull.Value || (int)dataRow[media] == 30) continue; + + param3.Value = StorageInterface.Unknown; + + switch((int)dataRow[media]) + { + case 1: + param2.Value = StorageType.CompactFloppy; + + break; + case 3: + case 5: + param2.Value = StorageType.Microfloppy; + + break; + case 4: + param2.Value = StorageType.Minifloppy; + + break; + case 7: + param2.Value = StorageType.CompactDisc; + + break; + case 8: + param2.Value = StorageType.CompactCassette; + + break; + case 9: + param2.Value = StorageType.CompactFlash; + + break; + case 11: + param2.Value = StorageType.Dvd; + + break; + case 12: + param2.Value = StorageType.GDROM; + + break; + case 13: + param2.Value = StorageType.ZIP100; + + break; + case 14: + param2.Value = StorageType.LS120; + + break; + case 15: + param2.Value = StorageType.MagnetoOptical; + + break; + case 17: + param2.Value = StorageType.Microdrive; + + break; + case 18: + param2.Value = StorageType.MMC; + + break; + case 20: + param2.Value = StorageType.SecureDigital; + + break; + case 21: + param2.Value = StorageType.SmartMedia; + + break; + case 23: + param2.Value = StorageType.PunchedCard; + + break; + case 24: + param2.Value = StorageType.HardDisk; + param3.Value = StorageInterface.ACSI; + + break; + case 25: + case 29: + param2.Value = StorageType.HardDisk; + param3.Value = StorageInterface.ATA; + + break; + case 26: + param2.Value = StorageType.HardDisk; + param3.Value = StorageInterface.ESDI; + + break; + case 27: + param2.Value = StorageType.HardDisk; + param3.Value = StorageInterface.FireWire; + + break; + case 28: + param2.Value = StorageType.CompactFloppy; + + break; + case 32: + case 35: + param2.Value = StorageType.HardDisk; + param3.Value = StorageInterface.ST506; + + break; + case 33: + param2.Value = StorageType.HardDisk; + param3.Value = StorageInterface.SASI; + + break; + case 34: + case 41: + param2.Value = StorageType.HardDisk; + param3.Value = StorageInterface.SCSI; + + break; + case 40: + param2.Value = StorageType.Floppy; + + break; + case 43: + param2.Value = StorageType.Bluray; + + break; + case 44: + param2.Value = StorageType.GOD; + + break; + case 45: + param2.Value = StorageType.WOD; + + break; + default: + param2.Value = StorageType.Unknown; + + break; + } + + param4.Value = null; + + switch(media) + { + case "disk1": + if(dataRow["cap1"] != DBNull.Value) + { + if(int.TryParse((string)dataRow["cap1"], out int cap)) + { + param4.Value = cap == 0 + ? null + : (StorageType)param2.Value == StorageType.CompactCassette + ? cap + : cap * 1024; + } + } + + break; + case "disk2": + if(dataRow["cap2"] != DBNull.Value) + { + if(int.TryParse((string)dataRow["cap2"], out int cap)) + { + param4.Value = cap == 0 + ? null + : (StorageType)param2.Value == StorageType.CompactCassette + ? cap + : cap * 1024; + } + } + + break; + } + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding storage type {0} with interface {1} to machine {2}", + (StorageType)param2.Value, + (StorageInterface)param3.Value, + (int)param1.Value); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + } + + dbcmd.Dispose(); + } + + Console.WriteLine("Removing memory columns from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_disk1`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_disk2`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd1`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd2`;\n" + + "ALTER TABLE `machines` DROP FOREIGN KEY `fk_machines_hdd3`;\n" + + "ALTER TABLE `machines` DROP COLUMN `hdd1`;\n" + + "ALTER TABLE `machines` DROP COLUMN `hdd2`;\n" + + "ALTER TABLE `machines` DROP COLUMN `hdd3`;\n" + + "ALTER TABLE `machines` DROP COLUMN `disk1`;\n" + + "ALTER TABLE `machines` DROP COLUMN `cap1`;\n" + + "ALTER TABLE `machines` DROP COLUMN `disk2`;\n" + + "ALTER TABLE `machines` DROP COLUMN `cap2`;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Removing table `disk_formats`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "DROP TABLE `disk_formats`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 20..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('20')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV21() + { + Console.WriteLine("Updating database to version 21"); + + Console.WriteLine("Adding new columns to table `machines`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` ADD COLUMN `introduced` DATETIME NULL;\n" + + "CREATE INDEX idx_machines_introduced ON machines (introduced);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Getting all items from `machines`"); + + dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * from machines"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + IDbCommand dbcmd = connection.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + + param1.ParameterName = "@introduced"; + + param1.DbType = DbType.DateTime; + + if((int)dataRow["year"] > 0) + param1.Value = new DateTime((int)dataRow["year"], 1, 1); + else + param1.Value = null; + + var sql = $"UPDATE `machines` SET introduced = @introduced WHERE id = {(int)dataRow["id"]}"; + + dbcmd.Parameters.Add(param1); + + trans = connection.BeginTransaction(); + dbcmd.Transaction = trans; + + Console.WriteLine("Adding introduction date {0} to machine {1}", (int)dataRow["year"], (int)dataRow["id"]); + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + + dbcmd.Dispose(); + } + + Console.WriteLine("Removing year column from table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `machines` DROP COLUMN `year`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 21..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('21')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV22() + { + Console.WriteLine("Updating database to version 22"); + + Console.WriteLine("Creating new table table `machine_families`"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V22.MachineFamilies; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new columns to table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE `machines` ADD COLUMN `family` INT DEFAULT NULL;\n" + + "ALTER TABLE `machines` CHANGE COLUMN `model` `name` VARCHAR(255) NOT NULL;\n" + + "ALTER TABLE `machines` DROP INDEX `idx_machines_model`;\n" + + "ALTER TABLE `machines` ADD COLUMN `model` VARCHAR(50) DEFAULT NULL;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new indexes to table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "CREATE INDEX `idx_machines_family` ON `machines` (`family`);\n" + + "CREATE INDEX `idx_machines_name` ON `machines` (`name`);\n" + + "CREATE INDEX `idx_machines_model` ON `machines` (`model`);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new foreign keys to table `machines`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_family` (family) REFERENCES machine_families (`id`) ON UPDATE CASCADE"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 22..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('22')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void UpdateDatabaseToV23() + { + Console.WriteLine("Updating database to version 23"); + + Console.WriteLine("Altering `browser_tests` primary key"); + IDbCommand dbCmd = connection.CreateCommand(); + IDbTransaction trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE browser_tests MODIFY id int NOT NULL auto_increment;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Dropping foreign key between `iso3166_1_numeric` and `companies`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE companies DROP FOREIGN KEY `fk_companies_country`;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Altering `iso3166_1_numeric` primary key"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE iso3166_1_numeric MODIFY id smallint(3) NOT NULL;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Altering `country` column in `companies`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE companies MODIFY country smallint(3);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Re-adding new foreign keys to table `companies`"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = + "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_country` (country) REFERENCES `iso3166_1_numeric` (`id`);"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding primary keys to several tables"); + dbCmd = connection.CreateCommand(); + trans = connection.BeginTransaction(); + dbCmd.Transaction = trans; + + dbCmd.CommandText = "ALTER TABLE gpus_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + + "ALTER TABLE memory_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + + "ALTER TABLE processors_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + + "ALTER TABLE resolutions_by_gpu ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + + "ALTER TABLE sound_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;\n" + + "ALTER TABLE storage_by_machine ADD id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT;"; + + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 23..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('23')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + + void OptimizeDatabase() + { + IDbCommand dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SHOW TABLES"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + var tableName = dataRow[0].ToString(); + + Console.WriteLine("Optimizing table `{0}`", tableName); + dbCmd = connection.CreateCommand(); + dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = $"OPTIMIZE TABLE '{tableName}'"; + } + } + + public int GetVersion() + { + var currentDbVersion = 2; + IDbCommand dbCmd = connection.CreateCommand(); + IDbDataAdapter dataAdapter = core.GetNewDataAdapter(); + dbCmd.CommandText = "SELECT * FROM marechai_db"; + var dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + var newId = int.Parse(dataRow["version"].ToString()); + + if(newId > currentDbVersion) currentDbVersion = newId; + } + + return currentDbVersion; + } + + public void UpdateVersionToEntityFramework() + { + Console.WriteLine("Adding Entity Framework table..."); + IDbCommand dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = "create table `__EFMigrationsHistory`\n" + + "(MigrationId varchar(95) not null primary key,\n" + + "ProductVersion varchar(32) not null);"; + + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + + Console.WriteLine("Adding Entity Framework first migration..."); + dbCmd = connection.CreateCommand(); + + dbCmd.CommandText = "INSERT INTO marechai.`__EFMigrationsHistory` (MigrationId, ProductVersion)" + + " VALUES ('20180805214952_InitialMigration', '2.1.1-rtm-30846');"; + + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 1984 (Entity Framework)..."); + dbCmd = connection.CreateCommand(); + dbCmd.CommandText = "INSERT INTO marechai_db (version) VALUES ('1984')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); } } \ No newline at end of file diff --git a/Marechai.Database/Schemas/HexStringToBytesConverter.cs b/Marechai.Database/Schemas/HexStringToBytesConverter.cs index a94c9f21..3add09a8 100644 --- a/Marechai.Database/Schemas/HexStringToBytesConverter.cs +++ b/Marechai.Database/Schemas/HexStringToBytesConverter.cs @@ -25,63 +25,58 @@ using System; -namespace Marechai.Database.Schemas +namespace Marechai.Database.Schemas; + +public static class HexStringToBytesConverter { - public static class HexStringToBytesConverter + public static byte[] StringToHex(string v) { - public static byte[] StringToHex(string v) + var hex = new byte[v.Length / 2]; + string str = v.ToLowerInvariant(); + + for(var i = 0; i < hex.Length; i++) { - byte[] hex = new byte[v.Length / 2]; - string str = v.ToLowerInvariant(); + char c0 = str[i * 2]; + char c1 = str[i * 2 + 1]; - for(int i = 0; i < hex.Length; i++) - { - char c0 = str[i * 2]; - char c1 = str[(i * 2) + 1]; + if(c0 >= 0x30 && c0 <= 0x39) + hex[i] += (byte)((c0 - 0x30) * 16); + else if(c0 >= 0x61 && c0 <= 0x66) + hex[i] += (byte)((c0 - 0x57) * 16); + else + throw new ArgumentOutOfRangeException(); - if(c0 >= 0x30 && - c0 <= 0x39) - hex[i] += (byte)((c0 - 0x30) * 16); - else if(c0 >= 0x61 && - c0 <= 0x66) - hex[i] += (byte)((c0 - 0x57) * 16); - else - throw new ArgumentOutOfRangeException(); - - if(c1 >= 0x30 && - c1 <= 0x39) - hex[i] += (byte)(c1 - 0x30); - else if(c1 >= 0x61 && - c1 <= 0x66) - hex[i] += (byte)(c1 - 0x57); - else - throw new ArgumentOutOfRangeException(); - } - - return hex; + if(c1 >= 0x30 && c1 <= 0x39) + hex[i] += (byte)(c1 - 0x30); + else if(c1 >= 0x61 && c1 <= 0x66) + hex[i] += (byte)(c1 - 0x57); + else + throw new ArgumentOutOfRangeException(); } - public static string HexToString(byte[] v) + return hex; + } + + public static string HexToString(byte[] v) + { + var chars = new char[v.Length * 2]; + + for(var i = 0; i < v.Length; i++) { - char[] chars = new char[v.Length * 2]; + int c0 = v[i] / 0x10; + int c1 = v[i] & 0xF; - for(int i = 0; i < v.Length; i++) - { - int c0 = v[i] / 0x10; - int c1 = v[i] & 0xF; + if(c0 >= 10) + chars[i * 2] = (char)(c0 + 0x57); + else + chars[i * 2] = (char)(c0 + 0x30); - if(c0 >= 10) - chars[i * 2] = (char)(c0 + 0x57); - else - chars[i * 2] = (char)(c0 + 0x30); - - if(c1 >= 10) - chars[(i * 2) + 1] = (char)(c1 + 0x57); - else - chars[(i * 2) + 1] = (char)(c1 + 0x30); - } - - return new string(chars); + if(c1 >= 10) + chars[i * 2 + 1] = (char)(c1 + 0x57); + else + chars[i * 2 + 1] = (char)(c1 + 0x30); } + + return new string(chars); } } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Iso4217Xml.cs b/Marechai.Database/Schemas/Iso4217Xml.cs index 558cdbdf..6e7f3abe 100644 --- a/Marechai.Database/Schemas/Iso4217Xml.cs +++ b/Marechai.Database/Schemas/Iso4217Xml.cs @@ -26,42 +26,43 @@ using System; using System.Xml.Serialization; -namespace Marechai.Database.Schemas +namespace Marechai.Database.Schemas; + +public class Iso4217Xml { - public class Iso4217Xml + [XmlRoot(ElementName = "ISO_4217")] + public class Root { - [XmlRoot(ElementName = "ISO_4217")] - public class Root - { - [XmlAttribute(AttributeName = "Pblshd", DataType = "date")] - public DateTime Published { get; set; } + [XmlAttribute(AttributeName = "Pblshd", DataType = "date")] + public DateTime Published { get; set; } - [XmlArray("CcyTbl"), XmlArrayItem("CcyNtry", typeof(Currency), IsNullable = true)] - public Currency[] Current { get; set; } + [XmlArray("CcyTbl")] + [XmlArrayItem("CcyNtry", typeof(Currency), IsNullable = true)] + public Currency[] Current { get; set; } - [XmlArray("HstrcCcyTbl"), XmlArrayItem("HstrcCcyNtry", typeof(Currency), IsNullable = true)] - public Currency[] Historical { get; set; } - } + [XmlArray("HstrcCcyTbl")] + [XmlArrayItem("HstrcCcyNtry", typeof(Currency), IsNullable = true)] + public Currency[] Historical { get; set; } + } - public class Currency - { - [XmlElement("CtryNm")] - public string Country { get; set; } + public class Currency + { + [XmlElement("CtryNm")] + public string Country { get; set; } - [XmlElement("Ccy")] - public string Code { get; set; } + [XmlElement("Ccy")] + public string Code { get; set; } - [XmlElement("CcyNbr")] - public short Number { get; set; } + [XmlElement("CcyNbr")] + public short Number { get; set; } - [XmlElement("CcyMnrUnts", IsNullable = true)] - public string MinorUnits { get; set; } + [XmlElement("CcyMnrUnts", IsNullable = true)] + public string MinorUnits { get; set; } - [XmlElement("CcyNm")] - public string Name { get; set; } + [XmlElement("CcyNm")] + public string Name { get; set; } - [XmlElement("WthdrwlDt", IsNullable = true)] - public string Withdrawn { get; set; } - } + [XmlElement("WthdrwlDt", IsNullable = true)] + public string Withdrawn { get; set; } } } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V10.cs b/Marechai.Database/Schemas/Sql/V10.cs index d568dccd..b88373ce 100644 --- a/Marechai.Database/Schemas/Sql/V10.cs +++ b/Marechai.Database/Schemas/Sql/V10.cs @@ -23,133 +23,145 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V10 { - public static class V10 - { - public static readonly string Admins = V9.Admins; + public static readonly string Admins = V9.Admins; - public static readonly string BrowserTests = V9.BrowserTests; + public static readonly string BrowserTests = V9.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('10');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('10');"; - public static readonly string Companies = V9.Companies; + public static readonly string Companies = V9.Companies; - public static readonly string Computers = V9.Computers; + public static readonly string Computers = V9.Computers; - public static readonly string Consoles = V9.Consoles; + public static readonly string Consoles = V9.Consoles; - public static readonly string DiskFormats = V9.DiskFormats; + public static readonly string DiskFormats = V9.DiskFormats; - public static readonly string Forbidden = V9.Forbidden; + public static readonly string Forbidden = V9.Forbidden; - public static readonly string Gpus = V9.Gpus; + public static readonly string Gpus = V9.Gpus; - public static readonly string Logs = V9.Logs; + public static readonly string Logs = V9.Logs; - public static readonly string MoneyDonations = V9.MoneyDonations; + public static readonly string MoneyDonations = V9.MoneyDonations; - public static readonly string MusicSynths = V9.MusicSynths; + public static readonly string MusicSynths = V9.MusicSynths; - public static readonly string News = V9.News; + public static readonly string News = V9.News; - public static readonly string OwnedComputers = V9.OwnedComputers; + public static readonly string OwnedComputers = V9.OwnedComputers; - public static readonly string OwnedConsoles = V9.OwnedConsoles; + public static readonly string OwnedConsoles = V9.OwnedConsoles; - public static readonly string Processors = "CREATE TABLE `processors` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`name` char(50) NOT NULL DEFAULT '',\n" + - "`company` int(11) DEFAULT NULL,\n" + - "`model_code` varchar(45) DEFAULT NULL,\n" + - "`introduced` datetime DEFAULT NULL,\n" + - "`instruction_set` int(11) DEFAULT NULL,\n" + - "`speed` double DEFAULT NULL,\n" + - "`package` varchar(45) DEFAULT NULL,\n" + - "`GPRs` int(11) DEFAULT NULL,\n" + - "`GPR_size` int(11) DEFAULT NULL,\n" + - "`FPRs` int(11) DEFAULT NULL,\n" + - "`FPR_size` int(11) DEFAULT NULL,\n" + - "`cores` int(11) DEFAULT NULL,\n" + - "`threads_per_core` int(11) DEFAULT NULL,\n" + - "`process` varchar(45) DEFAULT NULL,\n" + - "`process_nm` float DEFAULT NULL,\n" + - "`die_size` float DEFAULT NULL,\n" + - "`transistors` bigint(20) DEFAULT NULL,\n" + - "`data_bus` int(11) DEFAULT NULL,\n" + - "`addr_bus` int(11) DEFAULT NULL,\n" + - "`SIMD_registers` int(11) DEFAULT NULL,\n" + - "`SIMD_size` int(11) DEFAULT NULL,\n" + - "`L1_instruction` float DEFAULT NULL,\n" + - "`L1_data` float DEFAULT NULL,\n" + "`L2` float DEFAULT NULL,\n" + - "`L3` float DEFAULT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_processors_name` (`name`),\n" + - "KEY `idx_processors_company` (`company`),\n" + - "KEY `idx_processors_model_code` (`model_code`),\n" + - "KEY `idx_processors_introduced` (`introduced`),\n" + - "KEY `idx_processors_instruction_set` (`instruction_set`),\n" + - "KEY `idx_processors_speed` (`speed`),\n" + - "KEY `idx_processors_package` (`package`),\n" + - "KEY `idx_processors_GPRs` (`GPRs`),\n" + - "KEY `idx_processors_GPR_size` (`GPR_size`),\n" + - "KEY `idx_processors_FPRs` (`FPRs`),\n" + - "KEY `idx_processors_FPR_size` (`FPR_size`),\n" + - "KEY `idx_processors_cores` (`cores`),\n" + - "KEY `idx_processors_threads_per_core` (`threads_per_core`),\n" + - "KEY `idx_processors_process` (`process`),\n" + - "KEY `idx_processors_process_nm` (`process_nm`),\n" + - "KEY `idx_processors_die_size` (`die_size`),\n" + - "KEY `idx_processors_transistors` (`transistors`),\n" + - "KEY `idx_processors_data_bus` (`data_bus`),\n" + - "KEY `idx_processors_addr_bus` (`addr_bus`),\n" + - "KEY `idx_processors_SIMD_registers` (`SIMD_registers`),\n" + - "KEY `idx_processors_SIMD_size` (`SIMD_size`),\n" + - "KEY `idx_processors_L1_instruction` (`L1_instruction`),\n" + - "KEY `idx_processors_L1_data` (`L1_data`),\n" + - "KEY `idx_processors_L2` (`L2`),\n" + - "KEY `idx_processors_L3` (`L3`),\n" + - "CONSTRAINT `fk_processors_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE,\n" + - "CONSTRAINT `fk_processors_instruction_set` FOREIGN KEY (`instruction_set`) REFERENCES `instruction_sets` (`id`) ON UPDATE CASCADE);"; + public static readonly string Processors = "CREATE TABLE `processors` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`name` char(50) NOT NULL DEFAULT '',\n" + + "`company` int(11) DEFAULT NULL,\n" + + "`model_code` varchar(45) DEFAULT NULL,\n" + + "`introduced` datetime DEFAULT NULL,\n" + + "`instruction_set` int(11) DEFAULT NULL,\n" + + "`speed` double DEFAULT NULL,\n" + + "`package` varchar(45) DEFAULT NULL,\n" + + "`GPRs` int(11) DEFAULT NULL,\n" + + "`GPR_size` int(11) DEFAULT NULL,\n" + + "`FPRs` int(11) DEFAULT NULL,\n" + + "`FPR_size` int(11) DEFAULT NULL,\n" + + "`cores` int(11) DEFAULT NULL,\n" + + "`threads_per_core` int(11) DEFAULT NULL,\n" + + "`process` varchar(45) DEFAULT NULL,\n" + + "`process_nm` float DEFAULT NULL,\n" + + "`die_size` float DEFAULT NULL,\n" + + "`transistors` bigint(20) DEFAULT NULL,\n" + + "`data_bus` int(11) DEFAULT NULL,\n" + + "`addr_bus` int(11) DEFAULT NULL,\n" + + "`SIMD_registers` int(11) DEFAULT NULL,\n" + + "`SIMD_size` int(11) DEFAULT NULL,\n" + + "`L1_instruction` float DEFAULT NULL,\n" + + "`L1_data` float DEFAULT NULL,\n" + + "`L2` float DEFAULT NULL,\n" + + "`L3` float DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_processors_name` (`name`),\n" + + "KEY `idx_processors_company` (`company`),\n" + + "KEY `idx_processors_model_code` (`model_code`),\n" + + "KEY `idx_processors_introduced` (`introduced`),\n" + + "KEY `idx_processors_instruction_set` (`instruction_set`),\n" + + "KEY `idx_processors_speed` (`speed`),\n" + + "KEY `idx_processors_package` (`package`),\n" + + "KEY `idx_processors_GPRs` (`GPRs`),\n" + + "KEY `idx_processors_GPR_size` (`GPR_size`),\n" + + "KEY `idx_processors_FPRs` (`FPRs`),\n" + + "KEY `idx_processors_FPR_size` (`FPR_size`),\n" + + "KEY `idx_processors_cores` (`cores`),\n" + + "KEY `idx_processors_threads_per_core` (`threads_per_core`),\n" + + "KEY `idx_processors_process` (`process`),\n" + + "KEY `idx_processors_process_nm` (`process_nm`),\n" + + "KEY `idx_processors_die_size` (`die_size`),\n" + + "KEY `idx_processors_transistors` (`transistors`),\n" + + "KEY `idx_processors_data_bus` (`data_bus`),\n" + + "KEY `idx_processors_addr_bus` (`addr_bus`),\n" + + "KEY `idx_processors_SIMD_registers` (`SIMD_registers`),\n" + + "KEY `idx_processors_SIMD_size` (`SIMD_size`),\n" + + "KEY `idx_processors_L1_instruction` (`L1_instruction`),\n" + + "KEY `idx_processors_L1_data` (`L1_data`),\n" + + "KEY `idx_processors_L2` (`L2`),\n" + + "KEY `idx_processors_L3` (`L3`),\n" + + "CONSTRAINT `fk_processors_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE,\n" + + "CONSTRAINT `fk_processors_instruction_set` FOREIGN KEY (`instruction_set`) REFERENCES `instruction_sets` (`id`) ON UPDATE CASCADE);"; - public static readonly string SoundSynths = V9.SoundSynths; + public static readonly string SoundSynths = V9.SoundSynths; - public static readonly string ComputersForeignKeys = V9.ComputersForeignKeys; + public static readonly string ComputersForeignKeys = V9.ComputersForeignKeys; - public static readonly string ConsolesForeignKeys = V9.ConsolesForeignKeys; + public static readonly string ConsolesForeignKeys = V9.ConsolesForeignKeys; - public static readonly string Iso3166Numeric = V9.Iso3166Numeric; + public static readonly string Iso3166Numeric = V9.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V9.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V9.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V9.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V9.CompaniesForeignKeys; - public static readonly string CompanyLogos = V9.CompanyLogos; + public static readonly string CompanyLogos = V9.CompanyLogos; - public static readonly string CompanyDescriptions = V9.CompanyDescriptions; + public static readonly string CompanyDescriptions = V9.CompanyDescriptions; - public static readonly string InstructionSets = "CREATE TABLE IF NOT EXISTS `instruction_sets` (\n" + - "`id` INT NOT NULL AUTO_INCREMENT,\n" + - "`instruction_set` VARCHAR(45) NOT NULL,\n" + - "PRIMARY KEY (`id`));"; + public static readonly string InstructionSets = "CREATE TABLE IF NOT EXISTS `instruction_sets` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`instruction_set` VARCHAR(45) NOT NULL,\n" + + "PRIMARY KEY (`id`));"; - public static readonly string InstructionSetExtensions = - "CREATE TABLE IF NOT EXISTS `instruction_set_extensions` (\n" + "`id` INT NOT NULL AUTO_INCREMENT,\n" + - "`extension` VARCHAR(45) NOT NULL,\n" + "PRIMARY KEY (`id`));"; + public static readonly string InstructionSetExtensions = + "CREATE TABLE IF NOT EXISTS `instruction_set_extensions` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`extension` VARCHAR(45) NOT NULL,\n" + + "PRIMARY KEY (`id`));"; - public static readonly string InstructionSetExtensionsByProcessor = - "CREATE TABLE IF NOT EXISTS `instruction_set_extensions_by_processor` (\n" + - "`id` INT NOT NULL AUTO_INCREMENT,\n" + "`processor_id` INT NOT NULL,\n" + - "`extension_id` INT NOT NULL,\n" + - "PRIMARY KEY (`id`, `processor_id`, `extension_id`),\n" + - "INDEX `idx_setextension_processor` (`processor_id` ASC),\n" + - "INDEX `idx_setextension_extension` (`extension_id` ASC),\n" + "CONSTRAINT `fk_extension_processor_id`\n" + - "FOREIGN KEY (`processor_id`)\n" + "REFERENCES `processors` (`id`)\n" + "ON DELETE RESTRICT\n" + - "ON UPDATE CASCADE,\n" + "CONSTRAINT `fk_extension_extension_id`\n" + "FOREIGN KEY (`extension_id`)\n" + - "REFERENCES `instruction_set_extensions` (`id`)\n" + "ON DELETE RESTRICT\n" + "ON UPDATE CASCADE);"; - } + public static readonly string InstructionSetExtensionsByProcessor = + "CREATE TABLE IF NOT EXISTS `instruction_set_extensions_by_processor` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`processor_id` INT NOT NULL,\n" + + "`extension_id` INT NOT NULL,\n" + + "PRIMARY KEY (`id`, `processor_id`, `extension_id`),\n" + + "INDEX `idx_setextension_processor` (`processor_id` ASC),\n" + + "INDEX `idx_setextension_extension` (`extension_id` ASC),\n" + + "CONSTRAINT `fk_extension_processor_id`\n" + + "FOREIGN KEY (`processor_id`)\n" + + "REFERENCES `processors` (`id`)\n" + + "ON DELETE RESTRICT\n" + + "ON UPDATE CASCADE,\n" + + "CONSTRAINT `fk_extension_extension_id`\n" + + "FOREIGN KEY (`extension_id`)\n" + + "REFERENCES `instruction_set_extensions` (`id`)\n" + + "ON DELETE RESTRICT\n" + + "ON UPDATE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V11.cs b/Marechai.Database/Schemas/Sql/V11.cs index 578d1aec..e17c06b6 100644 --- a/Marechai.Database/Schemas/Sql/V11.cs +++ b/Marechai.Database/Schemas/Sql/V11.cs @@ -23,86 +23,88 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V11 { - public static class V11 - { - public static readonly string Admins = V10.Admins; + public static readonly string Admins = V10.Admins; - public static readonly string BrowserTests = V10.BrowserTests; + public static readonly string BrowserTests = V10.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('11');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('11');"; - public static readonly string Companies = V10.Companies; + public static readonly string Companies = V10.Companies; - public static readonly string Computers = V10.Computers; + public static readonly string Computers = V10.Computers; - public static readonly string Consoles = V10.Consoles; + public static readonly string Consoles = V10.Consoles; - public static readonly string DiskFormats = V10.DiskFormats; + public static readonly string DiskFormats = V10.DiskFormats; - public static readonly string Forbidden = V10.Forbidden; + public static readonly string Forbidden = V10.Forbidden; - public static readonly string Gpus = "CREATE TABLE `gpus` (\n" + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`name` char(128) NOT NULL DEFAULT '',\n" + - "`company` int(11) DEFAULT NULL,\n" + - "`model_code` varchar(45) DEFAULT NULL,\n" + - "`introduced` datetime DEFAULT NULL,\n" + - "`package` varchar(45) DEFAULT NULL,\n" + - "`process` varchar(45) DEFAULT NULL,\n" + - "`process_nm` float DEFAULT NULL,\n" + - "`die_size` float DEFAULT NULL,\n" + - "`transistors` bigint(20) DEFAULT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_gpus_name` (`name`),\n" + - "KEY `idx_gpus_company` (`company`),\n" + - "KEY `idx_gpus_model_code` (`model_code`),\n" + - "KEY `idx_gpus_introduced` (`introduced`),\n" + - "KEY `idx_gpus_package` (`package`),\n" + - "KEY `idx_gpus_process` (`process`),\n" + - "KEY `idx_gpus_process_nm` (`process_nm`),\n" + - "KEY `idx_gpus_die_size` (`die_size`),\n" + - "KEY `idx_gpus_transistors` (`transistors`),\n" + - "CONSTRAINT `fk_gpus_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE);"; + public static readonly string Gpus = "CREATE TABLE `gpus` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`name` char(128) NOT NULL DEFAULT '',\n" + + "`company` int(11) DEFAULT NULL,\n" + + "`model_code` varchar(45) DEFAULT NULL,\n" + + "`introduced` datetime DEFAULT NULL,\n" + + "`package` varchar(45) DEFAULT NULL,\n" + + "`process` varchar(45) DEFAULT NULL,\n" + + "`process_nm` float DEFAULT NULL,\n" + + "`die_size` float DEFAULT NULL,\n" + + "`transistors` bigint(20) DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_gpus_name` (`name`),\n" + + "KEY `idx_gpus_company` (`company`),\n" + + "KEY `idx_gpus_model_code` (`model_code`),\n" + + "KEY `idx_gpus_introduced` (`introduced`),\n" + + "KEY `idx_gpus_package` (`package`),\n" + + "KEY `idx_gpus_process` (`process`),\n" + + "KEY `idx_gpus_process_nm` (`process_nm`),\n" + + "KEY `idx_gpus_die_size` (`die_size`),\n" + + "KEY `idx_gpus_transistors` (`transistors`),\n" + + "CONSTRAINT `fk_gpus_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE);"; - public static readonly string Logs = V10.Logs; + public static readonly string Logs = V10.Logs; - public static readonly string MoneyDonations = V10.MoneyDonations; + public static readonly string MoneyDonations = V10.MoneyDonations; - public static readonly string MusicSynths = V10.MusicSynths; + public static readonly string MusicSynths = V10.MusicSynths; - public static readonly string News = V10.News; + public static readonly string News = V10.News; - public static readonly string OwnedComputers = V10.OwnedComputers; + public static readonly string OwnedComputers = V10.OwnedComputers; - public static readonly string OwnedConsoles = V10.OwnedConsoles; + public static readonly string OwnedConsoles = V10.OwnedConsoles; - public static readonly string Processors = V10.Processors; + public static readonly string Processors = V10.Processors; - public static readonly string SoundSynths = V10.SoundSynths; + public static readonly string SoundSynths = V10.SoundSynths; - public static readonly string ComputersForeignKeys = V10.ComputersForeignKeys; + public static readonly string ComputersForeignKeys = V10.ComputersForeignKeys; - public static readonly string ConsolesForeignKeys = V10.ConsolesForeignKeys; + public static readonly string ConsolesForeignKeys = V10.ConsolesForeignKeys; - public static readonly string Iso3166Numeric = V10.Iso3166Numeric; + public static readonly string Iso3166Numeric = V10.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V10.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V10.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V10.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V10.CompaniesForeignKeys; - public static readonly string CompanyLogos = V10.CompanyLogos; + public static readonly string CompanyLogos = V10.CompanyLogos; - public static readonly string CompanyDescriptions = V10.CompanyDescriptions; + public static readonly string CompanyDescriptions = V10.CompanyDescriptions; - public static readonly string InstructionSets = V10.InstructionSets; + public static readonly string InstructionSets = V10.InstructionSets; - public static readonly string InstructionSetExtensions = V10.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V10.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V10.InstructionSetExtensionsByProcessor; - } + public static readonly string InstructionSetExtensionsByProcessor = V10.InstructionSetExtensionsByProcessor; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V12.cs b/Marechai.Database/Schemas/Sql/V12.cs index 65647a7e..f2628aa2 100644 --- a/Marechai.Database/Schemas/Sql/V12.cs +++ b/Marechai.Database/Schemas/Sql/V12.cs @@ -23,156 +23,162 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V12 { - public static class V12 - { - public static readonly string Admins = V11.Admins; + public static readonly string Admins = V11.Admins; - public static readonly string BrowserTests = V11.BrowserTests; + public static readonly string BrowserTests = V11.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('12');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('12');"; - public static readonly string Companies = V11.Companies; + public static readonly string Companies = V11.Companies; - public static readonly string Computers = "CREATE TABLE `computers` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`company` int(11) NOT NULL DEFAULT '0',\n" + - "`year` int(11) NOT NULL DEFAULT '0',\n" + - "`model` char(50) NOT NULL DEFAULT '',\n" + - "`cpu1` int(11) DEFAULT NULL,\n" + "`mhz1` int(11) DEFAULT NULL,\n" + - "`cpu2` int(11) DEFAULT NULL,\n" + - "`mhz2` decimal(11,2) DEFAULT NULL,\n" + - "`bits` int(11) NOT NULL DEFAULT '0',\n" + - "`ram` int(11) NOT NULL DEFAULT '0',\n" + - "`rom` int(11) NOT NULL DEFAULT '0',\n" + - "`gpu` int(11) DEFAULT NULL,\n" + - "`vram` int(11) NOT NULL DEFAULT '0',\n" + - "`colors` int(11) NOT NULL DEFAULT '0',\n" + - "`res` char(10) NOT NULL DEFAULT '',\n" + - "`sound_synth` int(11) NOT NULL DEFAULT '0',\n" + - "`music_synth` int(11) NOT NULL DEFAULT '0',\n" + - "`sound_channels` int(11) NOT NULL DEFAULT '0',\n" + - "`music_channels` int(11) NOT NULL DEFAULT '0',\n" + - "`hdd1` int(11) NOT NULL DEFAULT '0',\n" + - "`hdd2` int(11) DEFAULT NULL,\n" + "`hdd3` int(11) DEFAULT NULL,\n" + - "`disk1` int(11) NOT NULL DEFAULT '0',\n" + - "`cap1` char(25) NOT NULL DEFAULT '0',\n" + - "`disk2` int(11) DEFAULT NULL,\n" + - "`cap2` char(25) DEFAULT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_computers_company` (`company`),\n" + - "KEY `idx_computers_year` (`year`),\n" + - "KEY `idx_computers_model` (`model`),\n" + - "KEY `idx_computers_cpu1` (`cpu1`),\n" + - "KEY `idx_computers_cpu2` (`cpu2`),\n" + - "KEY `idx_computers_mhz1` (`mhz1`),\n" + - "KEY `idx_computers_mhz2` (`mhz2`),\n" + - "KEY `idx_computers_bits` (`bits`),\n" + - "KEY `idx_computers_ram` (`ram`),\n" + - "KEY `idx_computers_rom` (`rom`),\n" + - "KEY `idx_computers_gpu` (`gpu`),\n" + - "KEY `idx_computers_vram` (`vram`),\n" + - "KEY `idx_computers_colors` (`colors`),\n" + - "KEY `idx_computers_res` (`res`),\n" + - "KEY `idx_computers_sound_synth` (`sound_synth`),\n" + - "KEY `idx_computers_music_synth` (`music_synth`),\n" + - "KEY `idx_computers_hdd1` (`hdd1`),\n" + - "KEY `idx_computers_hdd2` (`hdd2`),\n" + - "KEY `idx_computers_hdd3` (`hdd3`),\n" + - "KEY `idx_computers_disk1` (`disk1`),\n" + - "KEY `idx_computers_disk2` (`disk2`),\n" + - "KEY `idx_computers_cap1` (`cap1`),\n" + - "KEY `idx_computers_cap2` (`cap2`))"; + public static readonly string Computers = "CREATE TABLE `computers` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`company` int(11) NOT NULL DEFAULT '0',\n" + + "`year` int(11) NOT NULL DEFAULT '0',\n" + + "`model` char(50) NOT NULL DEFAULT '',\n" + + "`cpu1` int(11) DEFAULT NULL,\n" + + "`mhz1` int(11) DEFAULT NULL,\n" + + "`cpu2` int(11) DEFAULT NULL,\n" + + "`mhz2` decimal(11,2) DEFAULT NULL,\n" + + "`bits` int(11) NOT NULL DEFAULT '0',\n" + + "`ram` int(11) NOT NULL DEFAULT '0',\n" + + "`rom` int(11) NOT NULL DEFAULT '0',\n" + + "`gpu` int(11) DEFAULT NULL,\n" + + "`vram` int(11) NOT NULL DEFAULT '0',\n" + + "`colors` int(11) NOT NULL DEFAULT '0',\n" + + "`res` char(10) NOT NULL DEFAULT '',\n" + + "`sound_synth` int(11) NOT NULL DEFAULT '0',\n" + + "`music_synth` int(11) NOT NULL DEFAULT '0',\n" + + "`sound_channels` int(11) NOT NULL DEFAULT '0',\n" + + "`music_channels` int(11) NOT NULL DEFAULT '0',\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',\n" + + "`hdd2` int(11) DEFAULT NULL,\n" + + "`hdd3` int(11) DEFAULT NULL,\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',\n" + + "`disk2` int(11) DEFAULT NULL,\n" + + "`cap2` char(25) DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_computers_company` (`company`),\n" + + "KEY `idx_computers_year` (`year`),\n" + + "KEY `idx_computers_model` (`model`),\n" + + "KEY `idx_computers_cpu1` (`cpu1`),\n" + + "KEY `idx_computers_cpu2` (`cpu2`),\n" + + "KEY `idx_computers_mhz1` (`mhz1`),\n" + + "KEY `idx_computers_mhz2` (`mhz2`),\n" + + "KEY `idx_computers_bits` (`bits`),\n" + + "KEY `idx_computers_ram` (`ram`),\n" + + "KEY `idx_computers_rom` (`rom`),\n" + + "KEY `idx_computers_gpu` (`gpu`),\n" + + "KEY `idx_computers_vram` (`vram`),\n" + + "KEY `idx_computers_colors` (`colors`),\n" + + "KEY `idx_computers_res` (`res`),\n" + + "KEY `idx_computers_sound_synth` (`sound_synth`),\n" + + "KEY `idx_computers_music_synth` (`music_synth`),\n" + + "KEY `idx_computers_hdd1` (`hdd1`),\n" + + "KEY `idx_computers_hdd2` (`hdd2`),\n" + + "KEY `idx_computers_hdd3` (`hdd3`),\n" + + "KEY `idx_computers_disk1` (`disk1`),\n" + + "KEY `idx_computers_disk2` (`disk2`),\n" + + "KEY `idx_computers_cap1` (`cap1`),\n" + + "KEY `idx_computers_cap2` (`cap2`))"; - public static readonly string Consoles = "CREATE TABLE `consoles` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`company` int(11) NOT NULL DEFAULT '0',\n" + - "`model` char(50) NOT NULL DEFAULT '',\n" + - "`year` int(11) NOT NULL DEFAULT '0',\n" + - "`cpu1` int(11) DEFAULT NULL,\n" + "`mhz1` int(11) DEFAULT NULL,\n" + - "`cpu2` int(11) DEFAULT NULL,\n" + - "`mhz2` decimal(11,2) DEFAULT NULL,\n" + - "`bits` int(11) NOT NULL DEFAULT '0',\n" + - "`ram` int(11) NOT NULL DEFAULT '0',\n" + - "`rom` int(11) NOT NULL DEFAULT '0',\n" + - "`gpu` int(11) DEFAULT NULL,\n" + - "`vram` int(11) NOT NULL DEFAULT '0',\n" + - "`res` char(11) NOT NULL DEFAULT '',\n" + - "`colors` int(11) NOT NULL DEFAULT '0',\n" + - "`palette` int(11) NOT NULL DEFAULT '0',\n" + - "`sound_synth` int(11) NOT NULL DEFAULT '0',\n" + - "`schannels` int(11) NOT NULL DEFAULT '0',\n" + - "`music_synth` int(11) NOT NULL DEFAULT '0',\n" + - "`mchannels` int(11) NOT NULL DEFAULT '0',\n" + - "`format` int(11) NOT NULL DEFAULT '0',\n" + - "`cap` int(11) NOT NULL DEFAULT '0',\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_consoles_company` (`company`),\n" + - "KEY `idx_consoles_year` (`year`),\n" + - "KEY `idx_consoles_model` (`model`),\n" + - "KEY `idx_consoles_cpu1` (`cpu1`),\n" + - "KEY `idx_consoles_cpu2` (`cpu2`),\n" + - "KEY `idx_consoles_mhz1` (`mhz1`),\n" + - "KEY `idx_consoles_mhz2` (`mhz2`),\n" + - "KEY `idx_consoles_bits` (`bits`),\n" + - "KEY `idx_consoles_ram` (`ram`),\n" + - "KEY `idx_consoles_rom` (`rom`),\n" + - "KEY `idx_consoles_gpu` (`gpu`),\n" + - "KEY `idx_consoles_vram` (`vram`),\n" + - "KEY `idx_consoles_colors` (`colors`),\n" + - "KEY `idx_consoles_res` (`res`),\n" + - "KEY `idx_consoles_sound_synth` (`sound_synth`),\n" + - "KEY `idx_consoles_music_synth` (`music_synth`),\n" + - "KEY `idx_consoles_palette` (`palette`),\n" + - "KEY `idx_consoles_format` (`format`),\n" + - "KEY `idx_consoles_cap` (`cap`));"; + public static readonly string Consoles = "CREATE TABLE `consoles` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`company` int(11) NOT NULL DEFAULT '0',\n" + + "`model` char(50) NOT NULL DEFAULT '',\n" + + "`year` int(11) NOT NULL DEFAULT '0',\n" + + "`cpu1` int(11) DEFAULT NULL,\n" + + "`mhz1` int(11) DEFAULT NULL,\n" + + "`cpu2` int(11) DEFAULT NULL,\n" + + "`mhz2` decimal(11,2) DEFAULT NULL,\n" + + "`bits` int(11) NOT NULL DEFAULT '0',\n" + + "`ram` int(11) NOT NULL DEFAULT '0',\n" + + "`rom` int(11) NOT NULL DEFAULT '0',\n" + + "`gpu` int(11) DEFAULT NULL,\n" + + "`vram` int(11) NOT NULL DEFAULT '0',\n" + + "`res` char(11) NOT NULL DEFAULT '',\n" + + "`colors` int(11) NOT NULL DEFAULT '0',\n" + + "`palette` int(11) NOT NULL DEFAULT '0',\n" + + "`sound_synth` int(11) NOT NULL DEFAULT '0',\n" + + "`schannels` int(11) NOT NULL DEFAULT '0',\n" + + "`music_synth` int(11) NOT NULL DEFAULT '0',\n" + + "`mchannels` int(11) NOT NULL DEFAULT '0',\n" + + "`format` int(11) NOT NULL DEFAULT '0',\n" + + "`cap` int(11) NOT NULL DEFAULT '0',\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_consoles_company` (`company`),\n" + + "KEY `idx_consoles_year` (`year`),\n" + + "KEY `idx_consoles_model` (`model`),\n" + + "KEY `idx_consoles_cpu1` (`cpu1`),\n" + + "KEY `idx_consoles_cpu2` (`cpu2`),\n" + + "KEY `idx_consoles_mhz1` (`mhz1`),\n" + + "KEY `idx_consoles_mhz2` (`mhz2`),\n" + + "KEY `idx_consoles_bits` (`bits`),\n" + + "KEY `idx_consoles_ram` (`ram`),\n" + + "KEY `idx_consoles_rom` (`rom`),\n" + + "KEY `idx_consoles_gpu` (`gpu`),\n" + + "KEY `idx_consoles_vram` (`vram`),\n" + + "KEY `idx_consoles_colors` (`colors`),\n" + + "KEY `idx_consoles_res` (`res`),\n" + + "KEY `idx_consoles_sound_synth` (`sound_synth`),\n" + + "KEY `idx_consoles_music_synth` (`music_synth`),\n" + + "KEY `idx_consoles_palette` (`palette`),\n" + + "KEY `idx_consoles_format` (`format`),\n" + + "KEY `idx_consoles_cap` (`cap`));"; - public static readonly string DiskFormats = V11.DiskFormats; + public static readonly string DiskFormats = V11.DiskFormats; - public static readonly string Forbidden = V11.Forbidden; + public static readonly string Forbidden = V11.Forbidden; - public static readonly string Gpus = V11.Gpus + "\n" + - $"INSERT INTO `gpus` (`id`, `name`) VALUES ({Operations.DB_NONE}, `DB_NONE`);\n" + - $"INSERT INTO `gpus` (`id`, `name`) VALUES ({Operations.DB_SOFTWARE}, `DB_FRAMEBUFFER`);"; + public static readonly string Gpus = V11.Gpus + + "\n" + + $"INSERT INTO `gpus` (`id`, `name`) VALUES ({Operations.DbNone}, `DB_NONE`);\n" + + $"INSERT INTO `gpus` (`id`, `name`) VALUES ({Operations.DbSoftware}, `DB_FRAMEBUFFER`);"; - public static readonly string Logs = V11.Logs; + public static readonly string Logs = V11.Logs; - public static readonly string MoneyDonations = V11.MoneyDonations; + public static readonly string MoneyDonations = V11.MoneyDonations; - public static readonly string MusicSynths = V11.MusicSynths; + public static readonly string MusicSynths = V11.MusicSynths; - public static readonly string News = V11.News; + public static readonly string News = V11.News; - public static readonly string OwnedComputers = V11.OwnedComputers; + public static readonly string OwnedComputers = V11.OwnedComputers; - public static readonly string OwnedConsoles = V11.OwnedConsoles; + public static readonly string OwnedConsoles = V11.OwnedConsoles; - public static readonly string Processors = V11.Processors; + public static readonly string Processors = V11.Processors; - public static readonly string SoundSynths = V11.SoundSynths; + public static readonly string SoundSynths = V11.SoundSynths; - public static readonly string ComputersForeignKeys = V11.ComputersForeignKeys; + public static readonly string ComputersForeignKeys = V11.ComputersForeignKeys; - public static readonly string ConsolesForeignKeys = V11.ConsolesForeignKeys; + public static readonly string ConsolesForeignKeys = V11.ConsolesForeignKeys; - public static readonly string Iso3166Numeric = V11.Iso3166Numeric; + public static readonly string Iso3166Numeric = V11.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V11.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V11.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V11.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V11.CompaniesForeignKeys; - public static readonly string CompanyLogos = V11.CompanyLogos; + public static readonly string CompanyLogos = V11.CompanyLogos; - public static readonly string CompanyDescriptions = V11.CompanyDescriptions; + public static readonly string CompanyDescriptions = V11.CompanyDescriptions; - public static readonly string InstructionSets = V11.InstructionSets; + public static readonly string InstructionSets = V11.InstructionSets; - public static readonly string InstructionSetExtensions = V11.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V11.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V11.InstructionSetExtensionsByProcessor; - } + public static readonly string InstructionSetExtensionsByProcessor = V11.InstructionSetExtensionsByProcessor; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V13.cs b/Marechai.Database/Schemas/Sql/V13.cs index 6cd5ae84..546ec62f 100644 --- a/Marechai.Database/Schemas/Sql/V13.cs +++ b/Marechai.Database/Schemas/Sql/V13.cs @@ -23,192 +23,198 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V13 { - public static class V13 - { - public static readonly string Admins = V12.Admins; + public static readonly string Admins = V12.Admins; - public static readonly string BrowserTests = V12.BrowserTests; + public static readonly string BrowserTests = V12.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('13');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('13');"; - public static readonly string Companies = V12.Companies; + public static readonly string Companies = V12.Companies; - public static readonly string Computers = "CREATE TABLE `computers` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`company` int(11) NOT NULL DEFAULT '0',\n" + - "`year` int(11) NOT NULL DEFAULT '0',\n" + - "`model` char(50) NOT NULL DEFAULT '',\n" + - "`cpu1` int(11) DEFAULT NULL,\n" + "`mhz1` int(11) DEFAULT NULL,\n" + - "`cpu2` int(11) DEFAULT NULL,\n" + - "`mhz2` decimal(11,2) DEFAULT NULL,\n" + - "`bits` int(11) NOT NULL DEFAULT '0',\n" + - "`ram` int(11) NOT NULL DEFAULT '0',\n" + - "`rom` int(11) NOT NULL DEFAULT '0',\n" + - "`gpu` int(11) DEFAULT NULL,\n" + - "`vram` int(11) NOT NULL DEFAULT '0',\n" + - "`colors` int(11) NOT NULL DEFAULT '0',\n" + - "`res` char(10) NOT NULL DEFAULT '',\n" + - "`sound_synth` int(11) NOT NULL DEFAULT '0',\n" + - "`music_synth` int(11) NOT NULL DEFAULT '0',\n" + - "`sound_channels` int(11) NOT NULL DEFAULT '0',\n" + - "`music_channels` int(11) NOT NULL DEFAULT '0',\n" + - "`hdd1` int(11) NOT NULL DEFAULT '0',\n" + - "`hdd2` int(11) DEFAULT NULL,\n" + "`hdd3` int(11) DEFAULT NULL,\n" + - "`disk1` int(11) NOT NULL DEFAULT '0',\n" + - "`cap1` char(25) NOT NULL DEFAULT '0',\n" + - "`disk2` int(11) DEFAULT NULL,\n" + - "`cap2` char(25) DEFAULT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_computers_company` (`company`),\n" + - "KEY `idx_computers_year` (`year`),\n" + - "KEY `idx_computers_model` (`model`),\n" + - "KEY `idx_computers_cpu1` (`cpu1`),\n" + - "KEY `idx_computers_cpu2` (`cpu2`),\n" + - "KEY `idx_computers_mhz1` (`mhz1`),\n" + - "KEY `idx_computers_mhz2` (`mhz2`),\n" + - "KEY `idx_computers_bits` (`bits`),\n" + - "KEY `idx_computers_ram` (`ram`),\n" + - "KEY `idx_computers_rom` (`rom`),\n" + - "KEY `idx_computers_gpu` (`gpu`),\n" + - "KEY `idx_computers_vram` (`vram`),\n" + - "KEY `idx_computers_colors` (`colors`),\n" + - "KEY `idx_computers_res` (`res`),\n" + - "KEY `idx_computers_sound_synth` (`sound_synth`),\n" + - "KEY `idx_computers_music_synth` (`music_synth`),\n" + - "KEY `idx_computers_hdd1` (`hdd1`),\n" + - "KEY `idx_computers_hdd2` (`hdd2`),\n" + - "KEY `idx_computers_hdd3` (`hdd3`),\n" + - "KEY `idx_computers_disk1` (`disk1`),\n" + - "KEY `idx_computers_disk2` (`disk2`),\n" + - "KEY `idx_computers_cap1` (`cap1`),\n" + - "KEY `idx_computers_cap2` (`cap2`));"; + public static readonly string Computers = "CREATE TABLE `computers` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`company` int(11) NOT NULL DEFAULT '0',\n" + + "`year` int(11) NOT NULL DEFAULT '0',\n" + + "`model` char(50) NOT NULL DEFAULT '',\n" + + "`cpu1` int(11) DEFAULT NULL,\n" + + "`mhz1` int(11) DEFAULT NULL,\n" + + "`cpu2` int(11) DEFAULT NULL,\n" + + "`mhz2` decimal(11,2) DEFAULT NULL,\n" + + "`bits` int(11) NOT NULL DEFAULT '0',\n" + + "`ram` int(11) NOT NULL DEFAULT '0',\n" + + "`rom` int(11) NOT NULL DEFAULT '0',\n" + + "`gpu` int(11) DEFAULT NULL,\n" + + "`vram` int(11) NOT NULL DEFAULT '0',\n" + + "`colors` int(11) NOT NULL DEFAULT '0',\n" + + "`res` char(10) NOT NULL DEFAULT '',\n" + + "`sound_synth` int(11) NOT NULL DEFAULT '0',\n" + + "`music_synth` int(11) NOT NULL DEFAULT '0',\n" + + "`sound_channels` int(11) NOT NULL DEFAULT '0',\n" + + "`music_channels` int(11) NOT NULL DEFAULT '0',\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',\n" + + "`hdd2` int(11) DEFAULT NULL,\n" + + "`hdd3` int(11) DEFAULT NULL,\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',\n" + + "`disk2` int(11) DEFAULT NULL,\n" + + "`cap2` char(25) DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_computers_company` (`company`),\n" + + "KEY `idx_computers_year` (`year`),\n" + + "KEY `idx_computers_model` (`model`),\n" + + "KEY `idx_computers_cpu1` (`cpu1`),\n" + + "KEY `idx_computers_cpu2` (`cpu2`),\n" + + "KEY `idx_computers_mhz1` (`mhz1`),\n" + + "KEY `idx_computers_mhz2` (`mhz2`),\n" + + "KEY `idx_computers_bits` (`bits`),\n" + + "KEY `idx_computers_ram` (`ram`),\n" + + "KEY `idx_computers_rom` (`rom`),\n" + + "KEY `idx_computers_gpu` (`gpu`),\n" + + "KEY `idx_computers_vram` (`vram`),\n" + + "KEY `idx_computers_colors` (`colors`),\n" + + "KEY `idx_computers_res` (`res`),\n" + + "KEY `idx_computers_sound_synth` (`sound_synth`),\n" + + "KEY `idx_computers_music_synth` (`music_synth`),\n" + + "KEY `idx_computers_hdd1` (`hdd1`),\n" + + "KEY `idx_computers_hdd2` (`hdd2`),\n" + + "KEY `idx_computers_hdd3` (`hdd3`),\n" + + "KEY `idx_computers_disk1` (`disk1`),\n" + + "KEY `idx_computers_disk2` (`disk2`),\n" + + "KEY `idx_computers_cap1` (`cap1`),\n" + + "KEY `idx_computers_cap2` (`cap2`));"; - public static readonly string Consoles = "CREATE TABLE `consoles` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`company` int(11) NOT NULL DEFAULT '0',\n" + - "`model` char(50) NOT NULL DEFAULT '',\n" + - "`year` int(11) NOT NULL DEFAULT '0',\n" + - "`cpu1` int(11) DEFAULT NULL,\n" + "`mhz1` int(11) DEFAULT NULL,\n" + - "`cpu2` int(11) DEFAULT NULL,\n" + - "`mhz2` decimal(11,2) DEFAULT NULL,\n" + - "`bits` int(11) NOT NULL DEFAULT '0',\n" + - "`ram` int(11) NOT NULL DEFAULT '0',\n" + - "`rom` int(11) NOT NULL DEFAULT '0',\n" + - "`gpu` int(11) DEFAULT NULL,\n" + - "`vram` int(11) NOT NULL DEFAULT '0',\n" + - "`res` char(11) NOT NULL DEFAULT '',\n" + - "`colors` int(11) NOT NULL DEFAULT '0',\n" + - "`palette` int(11) NOT NULL DEFAULT '0',\n" + - "`sound_synth` int(11) NOT NULL DEFAULT '0',\n" + - "`schannels` int(11) NOT NULL DEFAULT '0',\n" + - "`music_synth` int(11) NOT NULL DEFAULT '0',\n" + - "`mchannels` int(11) NOT NULL DEFAULT '0',\n" + - "`format` int(11) NOT NULL DEFAULT '0',\n" + - "`cap` int(11) NOT NULL DEFAULT '0',\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_consoles_company` (`company`),\n" + - "KEY `idx_consoles_year` (`year`),\n" + - "KEY `idx_consoles_model` (`model`),\n" + - "KEY `idx_consoles_cpu1` (`cpu1`),\n" + - "KEY `idx_consoles_cpu2` (`cpu2`),\n" + - "KEY `idx_consoles_mhz1` (`mhz1`),\n" + - "KEY `idx_consoles_mhz2` (`mhz2`),\n" + - "KEY `idx_consoles_bits` (`bits`),\n" + - "KEY `idx_consoles_ram` (`ram`),\n" + - "KEY `idx_consoles_rom` (`rom`),\n" + - "KEY `idx_consoles_gpu` (`gpu`),\n" + - "KEY `idx_consoles_vram` (`vram`),\n" + - "KEY `idx_consoles_colors` (`colors`),\n" + - "KEY `idx_consoles_res` (`res`),\n" + - "KEY `idx_consoles_sound_synth` (`sound_synth`),\n" + - "KEY `idx_consoles_music_synth` (`music_synth`),\n" + - "KEY `idx_consoles_palette` (`palette`),\n" + - "KEY `idx_consoles_format` (`format`),\n" + - "KEY `idx_consoles_cap` (`cap`));"; + public static readonly string Consoles = "CREATE TABLE `consoles` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`company` int(11) NOT NULL DEFAULT '0',\n" + + "`model` char(50) NOT NULL DEFAULT '',\n" + + "`year` int(11) NOT NULL DEFAULT '0',\n" + + "`cpu1` int(11) DEFAULT NULL,\n" + + "`mhz1` int(11) DEFAULT NULL,\n" + + "`cpu2` int(11) DEFAULT NULL,\n" + + "`mhz2` decimal(11,2) DEFAULT NULL,\n" + + "`bits` int(11) NOT NULL DEFAULT '0',\n" + + "`ram` int(11) NOT NULL DEFAULT '0',\n" + + "`rom` int(11) NOT NULL DEFAULT '0',\n" + + "`gpu` int(11) DEFAULT NULL,\n" + + "`vram` int(11) NOT NULL DEFAULT '0',\n" + + "`res` char(11) NOT NULL DEFAULT '',\n" + + "`colors` int(11) NOT NULL DEFAULT '0',\n" + + "`palette` int(11) NOT NULL DEFAULT '0',\n" + + "`sound_synth` int(11) NOT NULL DEFAULT '0',\n" + + "`schannels` int(11) NOT NULL DEFAULT '0',\n" + + "`music_synth` int(11) NOT NULL DEFAULT '0',\n" + + "`mchannels` int(11) NOT NULL DEFAULT '0',\n" + + "`format` int(11) NOT NULL DEFAULT '0',\n" + + "`cap` int(11) NOT NULL DEFAULT '0',\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_consoles_company` (`company`),\n" + + "KEY `idx_consoles_year` (`year`),\n" + + "KEY `idx_consoles_model` (`model`),\n" + + "KEY `idx_consoles_cpu1` (`cpu1`),\n" + + "KEY `idx_consoles_cpu2` (`cpu2`),\n" + + "KEY `idx_consoles_mhz1` (`mhz1`),\n" + + "KEY `idx_consoles_mhz2` (`mhz2`),\n" + + "KEY `idx_consoles_bits` (`bits`),\n" + + "KEY `idx_consoles_ram` (`ram`),\n" + + "KEY `idx_consoles_rom` (`rom`),\n" + + "KEY `idx_consoles_gpu` (`gpu`),\n" + + "KEY `idx_consoles_vram` (`vram`),\n" + + "KEY `idx_consoles_colors` (`colors`),\n" + + "KEY `idx_consoles_res` (`res`),\n" + + "KEY `idx_consoles_sound_synth` (`sound_synth`),\n" + + "KEY `idx_consoles_music_synth` (`music_synth`),\n" + + "KEY `idx_consoles_palette` (`palette`),\n" + + "KEY `idx_consoles_format` (`format`),\n" + + "KEY `idx_consoles_cap` (`cap`));"; - public static readonly string DiskFormats = V12.DiskFormats; + public static readonly string DiskFormats = V12.DiskFormats; - public static readonly string Forbidden = V12.Forbidden; + public static readonly string Forbidden = V12.Forbidden; - public static readonly string Gpus = V12.Gpus; + public static readonly string Gpus = V12.Gpus; - public static readonly string Logs = V12.Logs; + public static readonly string Logs = V12.Logs; - public static readonly string MoneyDonations = V12.MoneyDonations; + public static readonly string MoneyDonations = V12.MoneyDonations; - public static readonly string News = V12.News; + public static readonly string News = V12.News; - public static readonly string OwnedComputers = V12.OwnedComputers; + public static readonly string OwnedComputers = V12.OwnedComputers; - public static readonly string OwnedConsoles = V12.OwnedConsoles; + public static readonly string OwnedConsoles = V12.OwnedConsoles; - public static readonly string Processors = V12.Processors; + public static readonly string Processors = V12.Processors; - public static readonly string SoundSynths = "CREATE TABLE `sound_synths` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`name` char(50) NOT NULL DEFAULT '',\n" + - "`company` int(11) DEFAULT NULL,\n" + - "`model_code` varchar(45) DEFAULT NULL,\n" + - "`introduced` datetime DEFAULT NULL,\n" + - "`voices` int(11) DEFAULT NULL,\n" + - "`frequency` double DEFAULT NULL,\n" + - "`depth` int(11) DEFAULT NULL,\n" + - "`square_wave` int(11) DEFAULT NULL,\n" + - "`white_noise` int(11) DEFAULT NULL,\n" + - "`type` int(11) DEFAULT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_sound_synths_name` (`name`),\n" + - "KEY `idx_sound_synths_company` (`company`),\n" + - "KEY `idx_sound_synths_model_code` (`model_code`),\n" + - "KEY `idx_sound_synths_introduced` (`introduced`),\n" + - "KEY `idx_sound_synths_voices` (`voices`),\n" + - "KEY `idx_sound_synths_frequency` (`frequency`),\n" + - "KEY `idx_sound_synths_depth` (`depth`),\n" + - "KEY `idx_sound_synths_square_wave` (`square_wave`),\n" + - "KEY `idx_sound_synths_white_noise` (`white_noise`),\n" + - "KEY `idx_sound_synths_type` (`type`),\n" + - "CONSTRAINT `fk_sound_synths_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE);"; + public static readonly string SoundSynths = "CREATE TABLE `sound_synths` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`name` char(50) NOT NULL DEFAULT '',\n" + + "`company` int(11) DEFAULT NULL,\n" + + "`model_code` varchar(45) DEFAULT NULL,\n" + + "`introduced` datetime DEFAULT NULL,\n" + + "`voices` int(11) DEFAULT NULL,\n" + + "`frequency` double DEFAULT NULL,\n" + + "`depth` int(11) DEFAULT NULL,\n" + + "`square_wave` int(11) DEFAULT NULL,\n" + + "`white_noise` int(11) DEFAULT NULL,\n" + + "`type` int(11) DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_sound_synths_name` (`name`),\n" + + "KEY `idx_sound_synths_company` (`company`),\n" + + "KEY `idx_sound_synths_model_code` (`model_code`),\n" + + "KEY `idx_sound_synths_introduced` (`introduced`),\n" + + "KEY `idx_sound_synths_voices` (`voices`),\n" + + "KEY `idx_sound_synths_frequency` (`frequency`),\n" + + "KEY `idx_sound_synths_depth` (`depth`),\n" + + "KEY `idx_sound_synths_square_wave` (`square_wave`),\n" + + "KEY `idx_sound_synths_white_noise` (`white_noise`),\n" + + "KEY `idx_sound_synths_type` (`type`),\n" + + "CONSTRAINT `fk_sound_synths_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE);"; - public static readonly string ComputersForeignKeys = - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_company (company) REFERENCES companies (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu1 (cpu1) REFERENCES processors (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu2 (cpu2) REFERENCES processors (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_gpu (gpu) REFERENCES gpus (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_music_synth (music_synth) REFERENCES sound_synths (id) ON UPDATE CASCADE;\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd1 (hdd1) REFERENCES disk_formats (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd2 (hdd2) REFERENCES disk_formats (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd3 (hdd3) REFERENCES disk_formats (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk1 (disk1) REFERENCES disk_formats (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk2 (disk2) REFERENCES disk_formats (id);"; + public static readonly string ComputersForeignKeys = + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_company (company) REFERENCES companies (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu1 (cpu1) REFERENCES processors (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu2 (cpu2) REFERENCES processors (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_gpu (gpu) REFERENCES gpus (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_music_synth (music_synth) REFERENCES sound_synths (id) ON UPDATE CASCADE;\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd1 (hdd1) REFERENCES disk_formats (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd2 (hdd2) REFERENCES disk_formats (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd3 (hdd3) REFERENCES disk_formats (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk1 (disk1) REFERENCES disk_formats (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk2 (disk2) REFERENCES disk_formats (id);"; - public static readonly string ConsolesForeignKeys = - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_company (company) REFERENCES companies (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu1 (cpu1) REFERENCES processors (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu2 (cpu2) REFERENCES processors (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_gpu (gpu) REFERENCES gpus (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_music_synth (music_synth) REFERENCES sound_synths (id) ON UPDATE CASCADE;\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_format (format) REFERENCES disk_formats (id);"; + public static readonly string ConsolesForeignKeys = + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_company (company) REFERENCES companies (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu1 (cpu1) REFERENCES processors (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu2 (cpu2) REFERENCES processors (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_gpu (gpu) REFERENCES gpus (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_music_synth (music_synth) REFERENCES sound_synths (id) ON UPDATE CASCADE;\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_format (format) REFERENCES disk_formats (id);"; - public static readonly string Iso3166Numeric = V12.Iso3166Numeric; + public static readonly string Iso3166Numeric = V12.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V12.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V12.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V12.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V12.CompaniesForeignKeys; - public static readonly string CompanyLogos = V12.CompanyLogos; + public static readonly string CompanyLogos = V12.CompanyLogos; - public static readonly string CompanyDescriptions = V12.CompanyDescriptions; + public static readonly string CompanyDescriptions = V12.CompanyDescriptions; - public static readonly string InstructionSets = V12.InstructionSets; + public static readonly string InstructionSets = V12.InstructionSets; - public static readonly string InstructionSetExtensions = V12.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V12.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V12.InstructionSetExtensionsByProcessor; - } + public static readonly string InstructionSetExtensionsByProcessor = V12.InstructionSetExtensionsByProcessor; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V14.cs b/Marechai.Database/Schemas/Sql/V14.cs index fafcd754..9b1f17d4 100644 --- a/Marechai.Database/Schemas/Sql/V14.cs +++ b/Marechai.Database/Schemas/Sql/V14.cs @@ -23,119 +23,122 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V14 { - public static class V14 - { - public static readonly string Admins = V13.Admins; + public static readonly string Admins = V13.Admins; - public static readonly string BrowserTests = V13.BrowserTests; + public static readonly string BrowserTests = V13.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('14');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('14');"; - public static readonly string Companies = V13.Companies; + public static readonly string Companies = V13.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (;\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + - "`company` int(11) NOT NULL DEFAULT '0',;\n" + - "`year` int(11) NOT NULL DEFAULT '0',;\n" + - "`model` char(50) NOT NULL DEFAULT '',;\n" + - "`cpu1` int(11) DEFAULT NULL,;\n" + "`mhz1` int(11) DEFAULT NULL,;\n" + - "`cpu2` int(11) DEFAULT NULL,;\n" + - "`mhz2` decimal(11,2) DEFAULT NULL,;\n" + - "`ram` int(11) NOT NULL DEFAULT '0',;\n" + - "`rom` int(11) NOT NULL DEFAULT '0',;\n" + - "`gpu` int(11) DEFAULT NULL,;\n" + - "`vram` int(11) NOT NULL DEFAULT '0',;\n" + - "`colors` int(11) NOT NULL DEFAULT '0',;\n" + - "`res` char(10) NOT NULL DEFAULT '',;\n" + - "`sound_synth` int(11) NOT NULL DEFAULT '0',;\n" + - "`music_synth` int(11) NOT NULL DEFAULT '0',;\n" + - "`sound_channels` int(11) NOT NULL DEFAULT '0',;\n" + - "`music_channels` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd2` int(11) DEFAULT NULL,;\n" + "`hdd3` int(11) DEFAULT NULL,;\n" + - "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + - "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + - "`disk2` int(11) DEFAULT NULL,;\n" + - "`cap2` char(25) DEFAULT NULL,;\n" + - "`type` int(11) NOT NULL DEFAULT '0',;\n" + "PRIMARY KEY (`id`),;\n" + - "KEY `idx_machines_company` (`company`),;\n" + - "KEY `idx_machines_year` (`year`),;\n" + - "KEY `idx_machines_model` (`model`),;\n" + - "KEY `idx_machines_cpu1` (`cpu1`),;\n" + - "KEY `idx_machines_cpu2` (`cpu2`),;\n" + - "KEY `idx_machines_mhz1` (`mhz1`),;\n" + - "KEY `idx_machines_mhz2` (`mhz2`),;\n" + - "KEY `idx_machines_ram` (`ram`),;\n" + - "KEY `idx_machines_rom` (`rom`),;\n" + - "KEY `idx_machines_gpu` (`gpu`),;\n" + - "KEY `idx_machines_vram` (`vram`),;\n" + - "KEY `idx_machines_colors` (`colors`),;\n" + - "KEY `idx_machines_res` (`res`),;\n" + - "KEY `idx_machines_sound_synth` (`sound_synth`),;\n" + - "KEY `idx_machines_music_synth` (`music_synth`),;\n" + - "KEY `idx_machines_hdd1` (`hdd1`),;\n" + - "KEY `idx_machines_hdd2` (`hdd2`),;\n" + - "KEY `idx_machines_hdd3` (`hdd3`),;\n" + - "KEY `idx_machines_disk1` (`disk1`),;\n" + - "KEY `idx_machines_disk2` (`disk2`),;\n" + - "KEY `idx_machines_cap1` (`cap1`),;\n" + - "KEY `idx_machines_cap2` (`cap2`),;\n" + - "KEY `idx_machines_type` (`type`));"; + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`year` int(11) NOT NULL DEFAULT '0',;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`cpu1` int(11) DEFAULT NULL,;\n" + + "`mhz1` int(11) DEFAULT NULL,;\n" + + "`cpu2` int(11) DEFAULT NULL,;\n" + + "`mhz2` decimal(11,2) DEFAULT NULL,;\n" + + "`ram` int(11) NOT NULL DEFAULT '0',;\n" + + "`rom` int(11) NOT NULL DEFAULT '0',;\n" + + "`gpu` int(11) DEFAULT NULL,;\n" + + "`vram` int(11) NOT NULL DEFAULT '0',;\n" + + "`colors` int(11) NOT NULL DEFAULT '0',;\n" + + "`res` char(10) NOT NULL DEFAULT '',;\n" + + "`sound_synth` int(11) NOT NULL DEFAULT '0',;\n" + + "`music_synth` int(11) NOT NULL DEFAULT '0',;\n" + + "`sound_channels` int(11) NOT NULL DEFAULT '0',;\n" + + "`music_channels` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd2` int(11) DEFAULT NULL,;\n" + + "`hdd3` int(11) DEFAULT NULL,;\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + + "`disk2` int(11) DEFAULT NULL,;\n" + + "`cap2` char(25) DEFAULT NULL,;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_year` (`year`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_cpu1` (`cpu1`),;\n" + + "KEY `idx_machines_cpu2` (`cpu2`),;\n" + + "KEY `idx_machines_mhz1` (`mhz1`),;\n" + + "KEY `idx_machines_mhz2` (`mhz2`),;\n" + + "KEY `idx_machines_ram` (`ram`),;\n" + + "KEY `idx_machines_rom` (`rom`),;\n" + + "KEY `idx_machines_gpu` (`gpu`),;\n" + + "KEY `idx_machines_vram` (`vram`),;\n" + + "KEY `idx_machines_colors` (`colors`),;\n" + + "KEY `idx_machines_res` (`res`),;\n" + + "KEY `idx_machines_sound_synth` (`sound_synth`),;\n" + + "KEY `idx_machines_music_synth` (`music_synth`),;\n" + + "KEY `idx_machines_hdd1` (`hdd1`),;\n" + + "KEY `idx_machines_hdd2` (`hdd2`),;\n" + + "KEY `idx_machines_hdd3` (`hdd3`),;\n" + + "KEY `idx_machines_disk1` (`disk1`),;\n" + + "KEY `idx_machines_disk2` (`disk2`),;\n" + + "KEY `idx_machines_cap1` (`cap1`),;\n" + + "KEY `idx_machines_cap2` (`cap2`),;\n" + + "KEY `idx_machines_type` (`type`));"; - public static readonly string DiskFormats = V13.DiskFormats; + public static readonly string DiskFormats = V13.DiskFormats; - public static readonly string Forbidden = V13.Forbidden; + public static readonly string Forbidden = V13.Forbidden; - public static readonly string Gpus = V13.Gpus; + public static readonly string Gpus = V13.Gpus; - public static readonly string Logs = V13.Logs; + public static readonly string Logs = V13.Logs; - public static readonly string MoneyDonations = V13.MoneyDonations; + public static readonly string MoneyDonations = V13.MoneyDonations; - public static readonly string News = V13.News; + public static readonly string News = V13.News; - public static readonly string OwnedComputers = V13.OwnedComputers; + public static readonly string OwnedComputers = V13.OwnedComputers; - public static readonly string OwnedConsoles = V13.OwnedConsoles; + public static readonly string OwnedConsoles = V13.OwnedConsoles; - public static readonly string Processors = V13.Processors; + public static readonly string Processors = V13.Processors; - public static readonly string SoundSynths = V13.SoundSynths; + public static readonly string SoundSynths = V13.SoundSynths; - public static readonly string CompaniesForeignKeys = V13.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V13.CompaniesForeignKeys; - public static readonly string Iso3166Numeric = V13.Iso3166Numeric; + public static readonly string Iso3166Numeric = V13.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V13.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V13.Iso3166NumericValues; - public static readonly string MachinesForeignKeys = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_cpu1` (cpu1) REFERENCES `processors` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_cpu2` (cpu2) REFERENCES `processors` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_gpu` (gpu) REFERENCES `gpus` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_sound_synth` (sound_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; + public static readonly string MachinesForeignKeys = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_cpu1` (cpu1) REFERENCES `processors` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_cpu2` (cpu2) REFERENCES `processors` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_gpu` (gpu) REFERENCES `gpus` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_sound_synth` (sound_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; - public static readonly string CompanyLogos = V13.CompanyLogos; + public static readonly string CompanyLogos = V13.CompanyLogos; - public static readonly string CompanyDescriptions = V13.CompanyDescriptions; + public static readonly string CompanyDescriptions = V13.CompanyDescriptions; - public static readonly string InstructionSets = V13.InstructionSets; + public static readonly string InstructionSets = V13.InstructionSets; - public static readonly string InstructionSetExtensions = V13.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V13.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V13.InstructionSetExtensionsByProcessor; - } + public static readonly string InstructionSetExtensionsByProcessor = V13.InstructionSetExtensionsByProcessor; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V15.cs b/Marechai.Database/Schemas/Sql/V15.cs index 2ea12d53..8e44ef37 100644 --- a/Marechai.Database/Schemas/Sql/V15.cs +++ b/Marechai.Database/Schemas/Sql/V15.cs @@ -23,120 +23,122 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V15 { - public static class V15 - { - public static readonly string Admins = V14.Admins; + public static readonly string Admins = V14.Admins; - public static readonly string BrowserTests = V14.BrowserTests; + public static readonly string BrowserTests = V14.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('15');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('15');"; - public static readonly string Companies = V14.Companies; + public static readonly string Companies = V14.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (;\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + - "`company` int(11) NOT NULL DEFAULT '0',;\n" + - "`year` int(11) NOT NULL DEFAULT '0',;\n" + - "`model` char(50) NOT NULL DEFAULT '',;\n" + - "`ram` int(11) NOT NULL DEFAULT '0',;\n" + - "`rom` int(11) NOT NULL DEFAULT '0',;\n" + - "`gpu` int(11) DEFAULT NULL,;\n" + - "`vram` int(11) NOT NULL DEFAULT '0',;\n" + - "`colors` int(11) NOT NULL DEFAULT '0',;\n" + - "`res` char(10) NOT NULL DEFAULT '',;\n" + - "`sound_synth` int(11) NOT NULL DEFAULT '0',;\n" + - "`music_synth` int(11) NOT NULL DEFAULT '0',;\n" + - "`sound_channels` int(11) NOT NULL DEFAULT '0',;\n" + - "`music_channels` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd2` int(11) DEFAULT NULL,;\n" + "`hdd3` int(11) DEFAULT NULL,;\n" + - "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + - "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + - "`disk2` int(11) DEFAULT NULL,;\n" + - "`cap2` char(25) DEFAULT NULL,;\n" + - "`type` int(11) NOT NULL DEFAULT '0',;\n" + "PRIMARY KEY (`id`),;\n" + - "KEY `idx_machines_company` (`company`),;\n" + - "KEY `idx_machines_year` (`year`),;\n" + - "KEY `idx_machines_model` (`model`),;\n" + - "KEY `idx_machines_ram` (`ram`),;\n" + - "KEY `idx_machines_rom` (`rom`),;\n" + - "KEY `idx_machines_gpu` (`gpu`),;\n" + - "KEY `idx_machines_vram` (`vram`),;\n" + - "KEY `idx_machines_colors` (`colors`),;\n" + - "KEY `idx_machines_res` (`res`),;\n" + - "KEY `idx_machines_sound_synth` (`sound_synth`),;\n" + - "KEY `idx_machines_music_synth` (`music_synth`),;\n" + - "KEY `idx_machines_hdd1` (`hdd1`),;\n" + - "KEY `idx_machines_hdd2` (`hdd2`),;\n" + - "KEY `idx_machines_hdd3` (`hdd3`),;\n" + - "KEY `idx_machines_disk1` (`disk1`),;\n" + - "KEY `idx_machines_disk2` (`disk2`),;\n" + - "KEY `idx_machines_cap1` (`cap1`),;\n" + - "KEY `idx_machines_cap2` (`cap2`),;\n" + - "KEY `idx_machines_type` (`type`));"; + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`year` int(11) NOT NULL DEFAULT '0',;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`ram` int(11) NOT NULL DEFAULT '0',;\n" + + "`rom` int(11) NOT NULL DEFAULT '0',;\n" + + "`gpu` int(11) DEFAULT NULL,;\n" + + "`vram` int(11) NOT NULL DEFAULT '0',;\n" + + "`colors` int(11) NOT NULL DEFAULT '0',;\n" + + "`res` char(10) NOT NULL DEFAULT '',;\n" + + "`sound_synth` int(11) NOT NULL DEFAULT '0',;\n" + + "`music_synth` int(11) NOT NULL DEFAULT '0',;\n" + + "`sound_channels` int(11) NOT NULL DEFAULT '0',;\n" + + "`music_channels` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd2` int(11) DEFAULT NULL,;\n" + + "`hdd3` int(11) DEFAULT NULL,;\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + + "`disk2` int(11) DEFAULT NULL,;\n" + + "`cap2` char(25) DEFAULT NULL,;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_year` (`year`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_ram` (`ram`),;\n" + + "KEY `idx_machines_rom` (`rom`),;\n" + + "KEY `idx_machines_gpu` (`gpu`),;\n" + + "KEY `idx_machines_vram` (`vram`),;\n" + + "KEY `idx_machines_colors` (`colors`),;\n" + + "KEY `idx_machines_res` (`res`),;\n" + + "KEY `idx_machines_sound_synth` (`sound_synth`),;\n" + + "KEY `idx_machines_music_synth` (`music_synth`),;\n" + + "KEY `idx_machines_hdd1` (`hdd1`),;\n" + + "KEY `idx_machines_hdd2` (`hdd2`),;\n" + + "KEY `idx_machines_hdd3` (`hdd3`),;\n" + + "KEY `idx_machines_disk1` (`disk1`),;\n" + + "KEY `idx_machines_disk2` (`disk2`),;\n" + + "KEY `idx_machines_cap1` (`cap1`),;\n" + + "KEY `idx_machines_cap2` (`cap2`),;\n" + + "KEY `idx_machines_type` (`type`));"; - public static readonly string DiskFormats = V14.DiskFormats; + public static readonly string DiskFormats = V14.DiskFormats; - public static readonly string Forbidden = V14.Forbidden; + public static readonly string Forbidden = V14.Forbidden; - public static readonly string Gpus = V14.Gpus; + public static readonly string Gpus = V14.Gpus; - public static readonly string Logs = V14.Logs; + public static readonly string Logs = V14.Logs; - public static readonly string MoneyDonations = V14.MoneyDonations; + public static readonly string MoneyDonations = V14.MoneyDonations; - public static readonly string News = V14.News; + public static readonly string News = V14.News; - public static readonly string OwnedComputers = V14.OwnedComputers; + public static readonly string OwnedComputers = V14.OwnedComputers; - public static readonly string OwnedConsoles = V14.OwnedConsoles; + public static readonly string OwnedConsoles = V14.OwnedConsoles; - public static readonly string Processors = V14.Processors; + public static readonly string Processors = V14.Processors; - public static readonly string SoundSynths = V14.SoundSynths; + public static readonly string SoundSynths = V14.SoundSynths; - public static readonly string MachinesForeignKeys = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_gpu` (gpu) REFERENCES `gpus` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_sound_synth` (sound_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; + public static readonly string MachinesForeignKeys = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_gpu` (gpu) REFERENCES `gpus` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_sound_synth` (sound_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; - public static readonly string Iso3166Numeric = V14.Iso3166Numeric; + public static readonly string Iso3166Numeric = V14.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V14.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V14.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V14.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V14.CompaniesForeignKeys; - public static readonly string CompanyLogos = V14.CompanyLogos; + public static readonly string CompanyLogos = V14.CompanyLogos; - public static readonly string CompanyDescriptions = V14.CompanyDescriptions; + public static readonly string CompanyDescriptions = V14.CompanyDescriptions; - public static readonly string InstructionSets = V14.InstructionSets; + public static readonly string InstructionSets = V14.InstructionSets; - public static readonly string InstructionSetExtensions = V14.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V14.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V14.InstructionSetExtensionsByProcessor; + public static readonly string InstructionSetExtensionsByProcessor = V14.InstructionSetExtensionsByProcessor; - public static readonly string ProcessorsByMachine = "CREATE TABLE `processors_by_machine` (\n" + - "`processor` INT NOT NULL, \n" + - "`machine` INT NOT NULL,\n" + - "`speed` FLOAT DEFAULT NULL, \n" + - "KEY `idx_processors_by_machine_processor` (`processor`),\n" + - "KEY `idx_processors_by_machine_machine` (`machine`),\n" + - "KEY `idx_processors_by_machine_speed` (`speed`),\n" + - "CONSTRAINT `fk_processors_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + - "CONSTRAINT `fk_processors_by_machine_processor` FOREIGN KEY (`processor`) REFERENCES `processors` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; - } + public static readonly string ProcessorsByMachine = "CREATE TABLE `processors_by_machine` (\n" + + "`processor` INT NOT NULL, \n" + + "`machine` INT NOT NULL,\n" + + "`speed` FLOAT DEFAULT NULL, \n" + + "KEY `idx_processors_by_machine_processor` (`processor`),\n" + + "KEY `idx_processors_by_machine_machine` (`machine`),\n" + + "KEY `idx_processors_by_machine_speed` (`speed`),\n" + + "CONSTRAINT `fk_processors_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + + "CONSTRAINT `fk_processors_by_machine_processor` FOREIGN KEY (`processor`) REFERENCES `processors` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V16.cs b/Marechai.Database/Schemas/Sql/V16.cs index 68f52cca..c26b25bc 100644 --- a/Marechai.Database/Schemas/Sql/V16.cs +++ b/Marechai.Database/Schemas/Sql/V16.cs @@ -23,116 +23,119 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V16 { - public static class V16 - { - public static readonly string Admins = V15.Admins; + public static readonly string Admins = V15.Admins; - public static readonly string BrowserTests = V15.BrowserTests; + public static readonly string BrowserTests = V15.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('16');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('16');"; - public static readonly string Companies = V15.Companies; + public static readonly string Companies = V15.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (;\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + - "`company` int(11) NOT NULL DEFAULT '0',;\n" + - "`year` int(11) NOT NULL DEFAULT '0',;\n" + - "`model` char(50) NOT NULL DEFAULT '',;\n" + - "`ram` int(11) NOT NULL DEFAULT '0',;\n" + - "`rom` int(11) NOT NULL DEFAULT '0',;\n" + - "`vram` int(11) NOT NULL DEFAULT '0',;\n" + - "`colors` int(11) NOT NULL DEFAULT '0',;\n" + - "`res` char(10) NOT NULL DEFAULT '',;\n" + - "`sound_synth` int(11) NOT NULL DEFAULT '0',;\n" + - "`music_synth` int(11) NOT NULL DEFAULT '0',;\n" + - "`sound_channels` int(11) NOT NULL DEFAULT '0',;\n" + - "`music_channels` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd2` int(11) DEFAULT NULL,;\n" + "`hdd3` int(11) DEFAULT NULL,;\n" + - "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + - "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + - "`disk2` int(11) DEFAULT NULL,;\n" + - "`cap2` char(25) DEFAULT NULL,;\n" + - "`type` int(11) NOT NULL DEFAULT '0',;\n" + "PRIMARY KEY (`id`),;\n" + - "KEY `idx_machines_company` (`company`),;\n" + - "KEY `idx_machines_year` (`year`),;\n" + - "KEY `idx_machines_model` (`model`),;\n" + - "KEY `idx_machines_ram` (`ram`),;\n" + - "KEY `idx_machines_rom` (`rom`),;\n" + - "KEY `idx_machines_vram` (`vram`),;\n" + - "KEY `idx_machines_colors` (`colors`),;\n" + - "KEY `idx_machines_res` (`res`),;\n" + - "KEY `idx_machines_sound_synth` (`sound_synth`),;\n" + - "KEY `idx_machines_music_synth` (`music_synth`),;\n" + - "KEY `idx_machines_hdd1` (`hdd1`),;\n" + - "KEY `idx_machines_hdd2` (`hdd2`),;\n" + - "KEY `idx_machines_hdd3` (`hdd3`),;\n" + - "KEY `idx_machines_disk1` (`disk1`),;\n" + - "KEY `idx_machines_disk2` (`disk2`),;\n" + - "KEY `idx_machines_cap1` (`cap1`),;\n" + - "KEY `idx_machines_cap2` (`cap2`),;\n" + - "KEY `idx_machines_type` (`type`));"; + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`year` int(11) NOT NULL DEFAULT '0',;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`ram` int(11) NOT NULL DEFAULT '0',;\n" + + "`rom` int(11) NOT NULL DEFAULT '0',;\n" + + "`vram` int(11) NOT NULL DEFAULT '0',;\n" + + "`colors` int(11) NOT NULL DEFAULT '0',;\n" + + "`res` char(10) NOT NULL DEFAULT '',;\n" + + "`sound_synth` int(11) NOT NULL DEFAULT '0',;\n" + + "`music_synth` int(11) NOT NULL DEFAULT '0',;\n" + + "`sound_channels` int(11) NOT NULL DEFAULT '0',;\n" + + "`music_channels` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd2` int(11) DEFAULT NULL,;\n" + + "`hdd3` int(11) DEFAULT NULL,;\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + + "`disk2` int(11) DEFAULT NULL,;\n" + + "`cap2` char(25) DEFAULT NULL,;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_year` (`year`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_ram` (`ram`),;\n" + + "KEY `idx_machines_rom` (`rom`),;\n" + + "KEY `idx_machines_vram` (`vram`),;\n" + + "KEY `idx_machines_colors` (`colors`),;\n" + + "KEY `idx_machines_res` (`res`),;\n" + + "KEY `idx_machines_sound_synth` (`sound_synth`),;\n" + + "KEY `idx_machines_music_synth` (`music_synth`),;\n" + + "KEY `idx_machines_hdd1` (`hdd1`),;\n" + + "KEY `idx_machines_hdd2` (`hdd2`),;\n" + + "KEY `idx_machines_hdd3` (`hdd3`),;\n" + + "KEY `idx_machines_disk1` (`disk1`),;\n" + + "KEY `idx_machines_disk2` (`disk2`),;\n" + + "KEY `idx_machines_cap1` (`cap1`),;\n" + + "KEY `idx_machines_cap2` (`cap2`),;\n" + + "KEY `idx_machines_type` (`type`));"; - public static readonly string DiskFormats = V15.DiskFormats; + public static readonly string DiskFormats = V15.DiskFormats; - public static readonly string Forbidden = V15.Forbidden; + public static readonly string Forbidden = V15.Forbidden; - public static readonly string Gpus = V15.Gpus; + public static readonly string Gpus = V15.Gpus; - public static readonly string Logs = V15.Logs; + public static readonly string Logs = V15.Logs; - public static readonly string MoneyDonations = V15.MoneyDonations; + public static readonly string MoneyDonations = V15.MoneyDonations; - public static readonly string News = V15.News; + public static readonly string News = V15.News; - public static readonly string OwnedComputers = V15.OwnedComputers; + public static readonly string OwnedComputers = V15.OwnedComputers; - public static readonly string OwnedConsoles = V15.OwnedConsoles; + public static readonly string OwnedConsoles = V15.OwnedConsoles; - public static readonly string Processors = V15.Processors; + public static readonly string Processors = V15.Processors; - public static readonly string SoundSynths = V15.SoundSynths; + public static readonly string SoundSynths = V15.SoundSynths; - public static readonly string MachinesForeignKeys = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_sound_synth` (sound_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; + public static readonly string MachinesForeignKeys = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_music_synth` (music_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_sound_synth` (sound_synth) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE;"; - public static readonly string Iso3166Numeric = V15.Iso3166Numeric; + public static readonly string Iso3166Numeric = V15.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V15.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V15.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V15.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V15.CompaniesForeignKeys; - public static readonly string CompanyLogos = V15.CompanyLogos; + public static readonly string CompanyLogos = V15.CompanyLogos; - public static readonly string CompanyDescriptions = V15.CompanyDescriptions; + public static readonly string CompanyDescriptions = V15.CompanyDescriptions; - public static readonly string InstructionSets = V15.InstructionSets; + public static readonly string InstructionSets = V15.InstructionSets; - public static readonly string InstructionSetExtensions = V15.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V15.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V15.InstructionSetExtensionsByProcessor; + public static readonly string InstructionSetExtensionsByProcessor = V15.InstructionSetExtensionsByProcessor; - public static readonly string ProcessorsByMachine = V15.ProcessorsByMachine; + public static readonly string ProcessorsByMachine = V15.ProcessorsByMachine; - public static readonly string GpusByMachine = "CREATE TABLE `gpus_by_machine` (\n" + "`gpu` INT NOT NULL, \n" + - "`machine` INT NOT NULL,\n" + - "KEY `idx_gpus_by_machine_gpus` (`gpu`),\n" + - "KEY `idx_gpus_by_machine_machine` (`machine`),\n" + - "CONSTRAINT `fk_gpus_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + - "CONSTRAINT `fk_gpus_by_machine_gpu` FOREIGN KEY (`gpu`) REFERENCES `gpus` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; - } + public static readonly string GpusByMachine = "CREATE TABLE `gpus_by_machine` (\n" + + "`gpu` INT NOT NULL, \n" + + "`machine` INT NOT NULL,\n" + + "KEY `idx_gpus_by_machine_gpus` (`gpu`),\n" + + "KEY `idx_gpus_by_machine_machine` (`machine`),\n" + + "CONSTRAINT `fk_gpus_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + + "CONSTRAINT `fk_gpus_by_machine_gpu` FOREIGN KEY (`gpu`) REFERENCES `gpus` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V17.cs b/Marechai.Database/Schemas/Sql/V17.cs index 63a4b802..fe572c76 100644 --- a/Marechai.Database/Schemas/Sql/V17.cs +++ b/Marechai.Database/Schemas/Sql/V17.cs @@ -23,110 +23,112 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V17 { - public static class V17 - { - public static readonly string Admins = V16.Admins; + public static readonly string Admins = V16.Admins; - public static readonly string BrowserTests = V16.BrowserTests; + public static readonly string BrowserTests = V16.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`));\n" + - "INSERT INTO marechai_db (version) VALUES ('17');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`));\n" + + "INSERT INTO marechai_db (version) VALUES ('17');"; - public static readonly string Companies = V16.Companies; + public static readonly string Companies = V16.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (;\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + - "`company` int(11) NOT NULL DEFAULT '0',;\n" + - "`year` int(11) NOT NULL DEFAULT '0',;\n" + - "`model` char(50) NOT NULL DEFAULT '',;\n" + - "`ram` int(11) NOT NULL DEFAULT '0',;\n" + - "`rom` int(11) NOT NULL DEFAULT '0',;\n" + - "`vram` int(11) NOT NULL DEFAULT '0',;\n" + - "`colors` int(11) NOT NULL DEFAULT '0',;\n" + - "`res` char(10) NOT NULL DEFAULT '',;\n" + - "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd2` int(11) DEFAULT NULL,;\n" + "`hdd3` int(11) DEFAULT NULL,;\n" + - "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + - "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + - "`disk2` int(11) DEFAULT NULL,;\n" + - "`cap2` char(25) DEFAULT NULL,;\n" + - "`type` int(11) NOT NULL DEFAULT '0',;\n" + "PRIMARY KEY (`id`),;\n" + - "KEY `idx_machines_company` (`company`),;\n" + - "KEY `idx_machines_year` (`year`),;\n" + - "KEY `idx_machines_model` (`model`),;\n" + - "KEY `idx_machines_ram` (`ram`),;\n" + - "KEY `idx_machines_rom` (`rom`),;\n" + - "KEY `idx_machines_vram` (`vram`),;\n" + - "KEY `idx_machines_colors` (`colors`),;\n" + - "KEY `idx_machines_res` (`res`),;\n" + - "KEY `idx_machines_hdd1` (`hdd1`),;\n" + - "KEY `idx_machines_hdd2` (`hdd2`),;\n" + - "KEY `idx_machines_hdd3` (`hdd3`),;\n" + - "KEY `idx_machines_disk1` (`disk1`),;\n" + - "KEY `idx_machines_disk2` (`disk2`),;\n" + - "KEY `idx_machines_cap1` (`cap1`),;\n" + - "KEY `idx_machines_cap2` (`cap2`),;\n" + - "KEY `idx_machines_type` (`type`));"; + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`year` int(11) NOT NULL DEFAULT '0',;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`ram` int(11) NOT NULL DEFAULT '0',;\n" + + "`rom` int(11) NOT NULL DEFAULT '0',;\n" + + "`vram` int(11) NOT NULL DEFAULT '0',;\n" + + "`colors` int(11) NOT NULL DEFAULT '0',;\n" + + "`res` char(10) NOT NULL DEFAULT '',;\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd2` int(11) DEFAULT NULL,;\n" + + "`hdd3` int(11) DEFAULT NULL,;\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + + "`disk2` int(11) DEFAULT NULL,;\n" + + "`cap2` char(25) DEFAULT NULL,;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_year` (`year`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_ram` (`ram`),;\n" + + "KEY `idx_machines_rom` (`rom`),;\n" + + "KEY `idx_machines_vram` (`vram`),;\n" + + "KEY `idx_machines_colors` (`colors`),;\n" + + "KEY `idx_machines_res` (`res`),;\n" + + "KEY `idx_machines_hdd1` (`hdd1`),;\n" + + "KEY `idx_machines_hdd2` (`hdd2`),;\n" + + "KEY `idx_machines_hdd3` (`hdd3`),;\n" + + "KEY `idx_machines_disk1` (`disk1`),;\n" + + "KEY `idx_machines_disk2` (`disk2`),;\n" + + "KEY `idx_machines_cap1` (`cap1`),;\n" + + "KEY `idx_machines_cap2` (`cap2`),;\n" + + "KEY `idx_machines_type` (`type`));"; - public static readonly string DiskFormats = V16.DiskFormats; + public static readonly string DiskFormats = V16.DiskFormats; - public static readonly string Forbidden = V16.Forbidden; + public static readonly string Forbidden = V16.Forbidden; - public static readonly string Gpus = V16.Gpus; + public static readonly string Gpus = V16.Gpus; - public static readonly string Logs = V16.Logs; + public static readonly string Logs = V16.Logs; - public static readonly string MoneyDonations = V16.MoneyDonations; + public static readonly string MoneyDonations = V16.MoneyDonations; - public static readonly string News = V16.News; + public static readonly string News = V16.News; - public static readonly string OwnedComputers = V16.OwnedComputers; + public static readonly string OwnedComputers = V16.OwnedComputers; - public static readonly string OwnedConsoles = V16.OwnedConsoles; + public static readonly string OwnedConsoles = V16.OwnedConsoles; - public static readonly string Processors = V16.Processors; + public static readonly string Processors = V16.Processors; - public static readonly string SoundSynths = V16.SoundSynths; + public static readonly string SoundSynths = V16.SoundSynths; - public static readonly string MachinesForeignKeys = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;"; + public static readonly string MachinesForeignKeys = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk1` (disk1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_disk2` (disk2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd1` (hdd1) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd2` (hdd2) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_hdd3` (hdd3) REFERENCES `disk_formats` (`id`) ON UPDATE CASCADE;"; - public static readonly string Iso3166Numeric = V16.Iso3166Numeric; + public static readonly string Iso3166Numeric = V16.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V16.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V16.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V16.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V16.CompaniesForeignKeys; - public static readonly string CompanyLogos = V16.CompanyLogos; + public static readonly string CompanyLogos = V16.CompanyLogos; - public static readonly string CompanyDescriptions = V16.CompanyDescriptions; + public static readonly string CompanyDescriptions = V16.CompanyDescriptions; - public static readonly string InstructionSets = V16.InstructionSets; + public static readonly string InstructionSets = V16.InstructionSets; - public static readonly string InstructionSetExtensions = V16.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V16.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V16.InstructionSetExtensionsByProcessor; + public static readonly string InstructionSetExtensionsByProcessor = V16.InstructionSetExtensionsByProcessor; - public static readonly string ProcessorsByMachine = V16.ProcessorsByMachine; + public static readonly string ProcessorsByMachine = V16.ProcessorsByMachine; - public static readonly string GpusByMachine = V16.GpusByMachine; + public static readonly string GpusByMachine = V16.GpusByMachine; - public static readonly string SoundByMachine = "CREATE TABLE `sound_by_machine` (\n" + - "`sound_synth` INT NOT NULL, \n" + "`machine` INT NOT NULL,\n" + - "KEY `idx_sound_by_machine_sound_synth` (`sound_synth`),\n" + - "KEY `idx_sound_by_machine_machine` (`machine`),\n" + - "CONSTRAINT `fk_sound_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + - "CONSTRAINT `fk_sound_by_machine_sound_synth` FOREIGN KEY (`sound_synth`) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; - } + public static readonly string SoundByMachine = "CREATE TABLE `sound_by_machine` (\n" + + "`sound_synth` INT NOT NULL, \n" + + "`machine` INT NOT NULL,\n" + + "KEY `idx_sound_by_machine_sound_synth` (`sound_synth`),\n" + + "KEY `idx_sound_by_machine_machine` (`machine`),\n" + + "CONSTRAINT `fk_sound_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + + "CONSTRAINT `fk_sound_by_machine_sound_synth` FOREIGN KEY (`sound_synth`) REFERENCES `sound_synths` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V18.cs b/Marechai.Database/Schemas/Sql/V18.cs index 9a126469..cf3d9140 100644 --- a/Marechai.Database/Schemas/Sql/V18.cs +++ b/Marechai.Database/Schemas/Sql/V18.cs @@ -23,106 +23,107 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V18 { - public static class V18 - { - public static readonly string Admins = V17.Admins; + public static readonly string Admins = V17.Admins; - public static readonly string BrowserTests = V17.BrowserTests; + public static readonly string BrowserTests = V17.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`));\n" + - "INSERT INTO marechai_db (version) VALUES ('18');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`));\n" + + "INSERT INTO marechai_db (version) VALUES ('18');"; - public static readonly string Companies = V17.Companies; + public static readonly string Companies = V17.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (;\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + - "`company` int(11) NOT NULL DEFAULT '0',;\n" + - "`year` int(11) NOT NULL DEFAULT '0',;\n" + - "`model` char(50) NOT NULL DEFAULT '',;\n" + - "`colors` int(11) NOT NULL DEFAULT '0',;\n" + - "`res` char(10) NOT NULL DEFAULT '',;\n" + - "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd2` int(11) DEFAULT NULL,;\n" + "`hdd3` int(11) DEFAULT NULL,;\n" + - "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + - "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + - "`disk2` int(11) DEFAULT NULL,;\n" + - "`cap2` char(25) DEFAULT NULL,;\n" + - "`type` int(11) NOT NULL DEFAULT '0',;\n" + "PRIMARY KEY (`id`),;\n" + - "KEY `idx_machines_company` (`company`),;\n" + - "KEY `idx_machines_year` (`year`),;\n" + - "KEY `idx_machines_model` (`model`),;\n" + - "KEY `idx_machines_colors` (`colors`),;\n" + - "KEY `idx_machines_res` (`res`),;\n" + - "KEY `idx_machines_hdd1` (`hdd1`),;\n" + - "KEY `idx_machines_hdd2` (`hdd2`),;\n" + - "KEY `idx_machines_hdd3` (`hdd3`),;\n" + - "KEY `idx_machines_disk1` (`disk1`),;\n" + - "KEY `idx_machines_disk2` (`disk2`),;\n" + - "KEY `idx_machines_cap1` (`cap1`),;\n" + - "KEY `idx_machines_cap2` (`cap2`),;\n" + - "KEY `idx_machines_type` (`type`));"; + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`year` int(11) NOT NULL DEFAULT '0',;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`colors` int(11) NOT NULL DEFAULT '0',;\n" + + "`res` char(10) NOT NULL DEFAULT '',;\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd2` int(11) DEFAULT NULL,;\n" + + "`hdd3` int(11) DEFAULT NULL,;\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + + "`disk2` int(11) DEFAULT NULL,;\n" + + "`cap2` char(25) DEFAULT NULL,;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_year` (`year`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_colors` (`colors`),;\n" + + "KEY `idx_machines_res` (`res`),;\n" + + "KEY `idx_machines_hdd1` (`hdd1`),;\n" + + "KEY `idx_machines_hdd2` (`hdd2`),;\n" + + "KEY `idx_machines_hdd3` (`hdd3`),;\n" + + "KEY `idx_machines_disk1` (`disk1`),;\n" + + "KEY `idx_machines_disk2` (`disk2`),;\n" + + "KEY `idx_machines_cap1` (`cap1`),;\n" + + "KEY `idx_machines_cap2` (`cap2`),;\n" + + "KEY `idx_machines_type` (`type`));"; - public static readonly string DiskFormats = V17.DiskFormats; + public static readonly string DiskFormats = V17.DiskFormats; - public static readonly string Forbidden = V17.Forbidden; + public static readonly string Forbidden = V17.Forbidden; - public static readonly string Gpus = V17.Gpus; + public static readonly string Gpus = V17.Gpus; - public static readonly string Logs = V17.Logs; + public static readonly string Logs = V17.Logs; - public static readonly string MoneyDonations = V17.MoneyDonations; + public static readonly string MoneyDonations = V17.MoneyDonations; - public static readonly string News = V17.News; + public static readonly string News = V17.News; - public static readonly string OwnedComputers = V17.OwnedComputers; + public static readonly string OwnedComputers = V17.OwnedComputers; - public static readonly string OwnedConsoles = V17.OwnedConsoles; + public static readonly string OwnedConsoles = V17.OwnedConsoles; - public static readonly string Processors = V17.Processors; + public static readonly string Processors = V17.Processors; - public static readonly string SoundSynths = V17.SoundSynths; + public static readonly string SoundSynths = V17.SoundSynths; - public static readonly string MachinesForeignKeys = V17.MachinesForeignKeys; + public static readonly string MachinesForeignKeys = V17.MachinesForeignKeys; - public static readonly string Iso3166Numeric = V17.Iso3166Numeric; + public static readonly string Iso3166Numeric = V17.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V17.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V17.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V17.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V17.CompaniesForeignKeys; - public static readonly string CompanyLogos = V17.CompanyLogos; + public static readonly string CompanyLogos = V17.CompanyLogos; - public static readonly string CompanyDescriptions = V17.CompanyDescriptions; + public static readonly string CompanyDescriptions = V17.CompanyDescriptions; - public static readonly string InstructionSets = V17.InstructionSets; + public static readonly string InstructionSets = V17.InstructionSets; - public static readonly string InstructionSetExtensions = V17.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V17.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V17.InstructionSetExtensionsByProcessor; + public static readonly string InstructionSetExtensionsByProcessor = V17.InstructionSetExtensionsByProcessor; - public static readonly string ProcessorsByMachine = V17.ProcessorsByMachine; + public static readonly string ProcessorsByMachine = V17.ProcessorsByMachine; - public static readonly string GpusByMachine = V17.GpusByMachine; + public static readonly string GpusByMachine = V17.GpusByMachine; - public static readonly string SoundByMachine = V17.SoundByMachine; + public static readonly string SoundByMachine = V17.SoundByMachine; - public static readonly string MemoryByMachine = "CREATE TABLE `memory_by_machine` (\n" + - "`machine` INT NOT NULL,\n" + - "`type` INT NOT NULL DEFAULT 0,\n" + - "`usage` INT NOT NULL DEFAULT 0,\n" + - "`size` BIGINT DEFAULT NULL,\n" + - "`speed` DOUBLE DEFAULT NULL,\n" + - "KEY `idx_memory_by_machine_machine` (`machine`),\n" + - "KEY `idx_memory_by_machine_type` (`type`),\n" + - "KEY `idx_memory_by_machine_usage` (`usage`),\n" + - "KEY `idx_memory_by_machine_size` (`size`),\n" + - "KEY `idx_memory_by_machine_speed` (`speed`),\n" + - "CONSTRAINT `fk_memory_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; - } + public static readonly string MemoryByMachine = "CREATE TABLE `memory_by_machine` (\n" + + "`machine` INT NOT NULL,\n" + + "`type` INT NOT NULL DEFAULT 0,\n" + + "`usage` INT NOT NULL DEFAULT 0,\n" + + "`size` BIGINT DEFAULT NULL,\n" + + "`speed` DOUBLE DEFAULT NULL,\n" + + "KEY `idx_memory_by_machine_machine` (`machine`),\n" + + "KEY `idx_memory_by_machine_type` (`type`),\n" + + "KEY `idx_memory_by_machine_usage` (`usage`),\n" + + "KEY `idx_memory_by_machine_size` (`size`),\n" + + "KEY `idx_memory_by_machine_speed` (`speed`),\n" + + "CONSTRAINT `fk_memory_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V19.cs b/Marechai.Database/Schemas/Sql/V19.cs index 93187484..ded5e743 100644 --- a/Marechai.Database/Schemas/Sql/V19.cs +++ b/Marechai.Database/Schemas/Sql/V19.cs @@ -23,113 +23,116 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V19 { - public static class V19 - { - public static readonly string Admins = V18.Admins; + public static readonly string Admins = V18.Admins; - public static readonly string BrowserTests = V18.BrowserTests; + public static readonly string BrowserTests = V18.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`));\n" + - "INSERT INTO marechai_db (version) VALUES ('19');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`));\n" + + "INSERT INTO marechai_db (version) VALUES ('19');"; - public static readonly string Companies = V18.Companies; + public static readonly string Companies = V18.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (;\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + - "`company` int(11) NOT NULL DEFAULT '0',;\n" + - "`year` int(11) NOT NULL DEFAULT '0',;\n" + - "`model` char(50) NOT NULL DEFAULT '',;\n" + - "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + - "`hdd2` int(11) DEFAULT NULL,;\n" + "`hdd3` int(11) DEFAULT NULL,;\n" + - "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + - "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + - "`disk2` int(11) DEFAULT NULL,;\n" + - "`cap2` char(25) DEFAULT NULL,;\n" + - "`type` int(11) NOT NULL DEFAULT '0',;\n" + "PRIMARY KEY (`id`),;\n" + - "KEY `idx_machines_company` (`company`),;\n" + - "KEY `idx_machines_year` (`year`),;\n" + - "KEY `idx_machines_model` (`model`),;\n" + - "KEY `idx_machines_hdd1` (`hdd1`),;\n" + - "KEY `idx_machines_hdd2` (`hdd2`),;\n" + - "KEY `idx_machines_hdd3` (`hdd3`),;\n" + - "KEY `idx_machines_disk1` (`disk1`),;\n" + - "KEY `idx_machines_disk2` (`disk2`),;\n" + - "KEY `idx_machines_cap1` (`cap1`),;\n" + - "KEY `idx_machines_cap2` (`cap2`),;\n" + - "KEY `idx_machines_type` (`type`));"; + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`year` int(11) NOT NULL DEFAULT '0',;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`hdd1` int(11) NOT NULL DEFAULT '0',;\n" + + "`hdd2` int(11) DEFAULT NULL,;\n" + + "`hdd3` int(11) DEFAULT NULL,;\n" + + "`disk1` int(11) NOT NULL DEFAULT '0',;\n" + + "`cap1` char(25) NOT NULL DEFAULT '0',;\n" + + "`disk2` int(11) DEFAULT NULL,;\n" + + "`cap2` char(25) DEFAULT NULL,;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_year` (`year`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_hdd1` (`hdd1`),;\n" + + "KEY `idx_machines_hdd2` (`hdd2`),;\n" + + "KEY `idx_machines_hdd3` (`hdd3`),;\n" + + "KEY `idx_machines_disk1` (`disk1`),;\n" + + "KEY `idx_machines_disk2` (`disk2`),;\n" + + "KEY `idx_machines_cap1` (`cap1`),;\n" + + "KEY `idx_machines_cap2` (`cap2`),;\n" + + "KEY `idx_machines_type` (`type`));"; - public static readonly string DiskFormats = V18.DiskFormats; + public static readonly string DiskFormats = V18.DiskFormats; - public static readonly string Forbidden = V18.Forbidden; + public static readonly string Forbidden = V18.Forbidden; - public static readonly string Gpus = V18.Gpus; + public static readonly string Gpus = V18.Gpus; - public static readonly string Logs = V18.Logs; + public static readonly string Logs = V18.Logs; - public static readonly string MoneyDonations = V18.MoneyDonations; + public static readonly string MoneyDonations = V18.MoneyDonations; - public static readonly string News = V18.News; + public static readonly string News = V18.News; - public static readonly string OwnedComputers = V18.OwnedComputers; + public static readonly string OwnedComputers = V18.OwnedComputers; - public static readonly string OwnedConsoles = V18.OwnedConsoles; + public static readonly string OwnedConsoles = V18.OwnedConsoles; - public static readonly string Processors = V18.Processors; + public static readonly string Processors = V18.Processors; - public static readonly string SoundSynths = V18.SoundSynths; + public static readonly string SoundSynths = V18.SoundSynths; - public static readonly string MachinesForeignKeys = V18.MachinesForeignKeys; + public static readonly string MachinesForeignKeys = V18.MachinesForeignKeys; - public static readonly string Iso3166Numeric = V18.Iso3166Numeric; + public static readonly string Iso3166Numeric = V18.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V18.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V18.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V18.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V18.CompaniesForeignKeys; - public static readonly string CompanyLogos = V18.CompanyLogos; + public static readonly string CompanyLogos = V18.CompanyLogos; - public static readonly string CompanyDescriptions = V18.CompanyDescriptions; + public static readonly string CompanyDescriptions = V18.CompanyDescriptions; - public static readonly string InstructionSets = V18.InstructionSets; + public static readonly string InstructionSets = V18.InstructionSets; - public static readonly string InstructionSetExtensions = V18.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V18.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V18.InstructionSetExtensionsByProcessor; + public static readonly string InstructionSetExtensionsByProcessor = V18.InstructionSetExtensionsByProcessor; - public static readonly string ProcessorsByMachine = V18.ProcessorsByMachine; + public static readonly string ProcessorsByMachine = V18.ProcessorsByMachine; - public static readonly string GpusByMachine = V18.GpusByMachine; + public static readonly string GpusByMachine = V18.GpusByMachine; - public static readonly string SoundByMachine = V18.SoundByMachine; + public static readonly string SoundByMachine = V18.SoundByMachine; - public static readonly string MemoryByMachine = V18.MemoryByMachine; + public static readonly string MemoryByMachine = V18.MemoryByMachine; - public static readonly string Resolutions = "CREATE TABLE `resolutions` (\n" + - "`id` INT NOT NULL AUTO_INCREMENT,\n" + - "`width` INT NOT NULL DEFAULT 0,\n" + - "`height` INT NOT NULL DEFAULT 0,\n" + - "`colors` BIGINT DEFAULT NULL,\n" + - "`palette` BIGINT DEFAULT NULL,\n" + - "`chars` BOOL NOT NULL DEFAULT 0,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_resolutions_width` (`width`),\n" + - "KEY `idx_resolutions_height` (`height`),\n" + - "KEY `idx_resolutions_colors` (`colors`),\n" + - "KEY `idx_resolutions_palette` (`palette`),\n" + - "INDEX `idx_resolutions_resolution` (`width`,`height`),\n" + - "INDEX `idx_resolutions_resolution_with_color` (`width`,`height`,`colors`),\n" + - "INDEX `idx_resolutions_resolution_with_color_and_palette` (`width`,`height`,`colors`,`palette`));"; + public static readonly string Resolutions = "CREATE TABLE `resolutions` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`width` INT NOT NULL DEFAULT 0,\n" + + "`height` INT NOT NULL DEFAULT 0,\n" + + "`colors` BIGINT DEFAULT NULL,\n" + + "`palette` BIGINT DEFAULT NULL,\n" + + "`chars` BOOL NOT NULL DEFAULT 0,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_resolutions_width` (`width`),\n" + + "KEY `idx_resolutions_height` (`height`),\n" + + "KEY `idx_resolutions_colors` (`colors`),\n" + + "KEY `idx_resolutions_palette` (`palette`),\n" + + "INDEX `idx_resolutions_resolution` (`width`,`height`),\n" + + "INDEX `idx_resolutions_resolution_with_color` (`width`,`height`,`colors`),\n" + + "INDEX `idx_resolutions_resolution_with_color_and_palette` (`width`,`height`,`colors`,`palette`));"; - public static readonly string ResolutionsByGpu = "CREATE TABLE `resolutions_by_gpu` (\n" + - "`gpu` INT NOT NULL,\n" + "`resolution` INT NOT NULL,\n" + - "KEY `idx_resolutions_by_gpu_gpu` (`gpu`),\n" + - "KEY `idx_resolutions_by_gpu_resolution` (`resolution`),\n" + - "CONSTRAINT `fk_resolutions_by_gpu_gpu` FOREIGN KEY (`gpu`) REFERENCES `gpus` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + - "CONSTRAINT `fk_resolutions_by_gpu_resolution` FOREIGN KEY (`resolution`) REFERENCES `resolutions` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; - } + public static readonly string ResolutionsByGpu = "CREATE TABLE `resolutions_by_gpu` (\n" + + "`gpu` INT NOT NULL,\n" + + "`resolution` INT NOT NULL,\n" + + "KEY `idx_resolutions_by_gpu_gpu` (`gpu`),\n" + + "KEY `idx_resolutions_by_gpu_resolution` (`resolution`),\n" + + "CONSTRAINT `fk_resolutions_by_gpu_gpu` FOREIGN KEY (`gpu`) REFERENCES `gpus` (`id`) ON UPDATE CASCADE ON DELETE CASCADE,\n" + + "CONSTRAINT `fk_resolutions_by_gpu_resolution` FOREIGN KEY (`resolution`) REFERENCES `resolutions` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V2.cs b/Marechai.Database/Schemas/Sql/V2.cs index 732896ac..9734057a 100644 --- a/Marechai.Database/Schemas/Sql/V2.cs +++ b/Marechai.Database/Schemas/Sql/V2.cs @@ -23,209 +23,244 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V2 { - public static class V2 - { - public static readonly string Admins = @"CREATE TABLE IF NOT EXISTS `admin` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user` char(50) NOT NULL DEFAULT '', - `password` char(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Admins = """ + CREATE TABLE IF NOT EXISTS `admin` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user` char(50) NOT NULL DEFAULT '', + `password` char(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string BrowserTests = @"CREATE TABLE IF NOT EXISTS `browser_test` ( - `id` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT, - `idstring` varchar(128) NOT NULL DEFAULT '', - `browser` varchar(64) NOT NULL DEFAULT '', - `version` varchar(16) NOT NULL DEFAULT '', - `os` varchar(32) NOT NULL DEFAULT '', - `platform` varchar(8) NOT NULL DEFAULT '', - `gif87` tinyint(1) NOT NULL DEFAULT '0', - `gif89` tinyint(1) NOT NULL DEFAULT '0', - `jpeg` tinyint(1) NOT NULL DEFAULT '0', - `png` tinyint(1) NOT NULL DEFAULT '0', - `pngt` tinyint(1) NOT NULL DEFAULT '0', - `agif` tinyint(1) NOT NULL DEFAULT '0', - `table` tinyint(1) NOT NULL DEFAULT '0', - `colors` tinyint(1) NOT NULL DEFAULT '0', - `js` tinyint(1) NOT NULL DEFAULT '0', - `frames` tinyint(1) NOT NULL DEFAULT '0', - `flash` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) - );"; + public static readonly string BrowserTests = """ + CREATE TABLE IF NOT EXISTS `browser_test` ( + `id` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT, + `idstring` varchar(128) NOT NULL DEFAULT '', + `browser` varchar(64) NOT NULL DEFAULT '', + `version` varchar(16) NOT NULL DEFAULT '', + `os` varchar(32) NOT NULL DEFAULT '', + `platform` varchar(8) NOT NULL DEFAULT '', + `gif87` tinyint(1) NOT NULL DEFAULT '0', + `gif89` tinyint(1) NOT NULL DEFAULT '0', + `jpeg` tinyint(1) NOT NULL DEFAULT '0', + `png` tinyint(1) NOT NULL DEFAULT '0', + `pngt` tinyint(1) NOT NULL DEFAULT '0', + `agif` tinyint(1) NOT NULL DEFAULT '0', + `table` tinyint(1) NOT NULL DEFAULT '0', + `colors` tinyint(1) NOT NULL DEFAULT '0', + `js` tinyint(1) NOT NULL DEFAULT '0', + `frames` tinyint(1) NOT NULL DEFAULT '0', + `flash` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Companies = @"CREATE TABLE IF NOT EXISTS `Companias` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `Compania` char(128) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Companies = """ + CREATE TABLE IF NOT EXISTS `Companias` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `Compania` char(128) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + " + """; - public static readonly string Computers = @"CREATE TABLE IF NOT EXISTS `computers` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `company` int(11) NOT NULL DEFAULT '0', - `year` int(11) NOT NULL DEFAULT '0', - `model` char(50) NOT NULL DEFAULT '', - `cpu1` int(11) NOT NULL DEFAULT '0', - `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00', - `cpu2` int(11) DEFAULT NULL, - `mhz2` decimal(11,2) DEFAULT NULL, - `bits` int(11) NOT NULL DEFAULT '0', - `ram` int(11) NOT NULL DEFAULT '0', - `rom` int(11) NOT NULL DEFAULT '0', - `gpu` int(11) NOT NULL DEFAULT '0', - `vram` int(11) NOT NULL DEFAULT '0', - `colors` int(11) NOT NULL DEFAULT '0', - `res` char(10) NOT NULL DEFAULT '', - `spu` int(11) NOT NULL DEFAULT '0', - `mpu` int(11) NOT NULL DEFAULT '0', - `sound_channels` int(11) NOT NULL DEFAULT '0', - `music_channels` int(11) NOT NULL DEFAULT '0', - `hdd1` int(11) NOT NULL DEFAULT '0', - `hdd2` int(11) DEFAULT NULL, - `hdd3` int(11) DEFAULT NULL, - `disk1` int(11) NOT NULL DEFAULT '0', - `cap1` char(25) NOT NULL DEFAULT '0', - `disk2` int(11) DEFAULT NULL, - `cap2` char(25) DEFAULT NULL, - `comment` char(255) DEFAULT NULL, - PRIMARY KEY (`id`) - );"; + public static readonly string Computers = """ + CREATE TABLE IF NOT EXISTS `computers` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `company` int(11) NOT NULL DEFAULT '0', + `year` int(11) NOT NULL DEFAULT '0', + `model` char(50) NOT NULL DEFAULT '', + `cpu1` int(11) NOT NULL DEFAULT '0', + `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00', + `cpu2` int(11) DEFAULT NULL, + `mhz2` decimal(11,2) DEFAULT NULL, + `bits` int(11) NOT NULL DEFAULT '0', + `ram` int(11) NOT NULL DEFAULT '0', + `rom` int(11) NOT NULL DEFAULT '0', + `gpu` int(11) NOT NULL DEFAULT '0', + `vram` int(11) NOT NULL DEFAULT '0', + `colors` int(11) NOT NULL DEFAULT '0', + `res` char(10) NOT NULL DEFAULT '', + `spu` int(11) NOT NULL DEFAULT '0', + `mpu` int(11) NOT NULL DEFAULT '0', + `sound_channels` int(11) NOT NULL DEFAULT '0', + `music_channels` int(11) NOT NULL DEFAULT '0', + `hdd1` int(11) NOT NULL DEFAULT '0', + `hdd2` int(11) DEFAULT NULL, + `hdd3` int(11) DEFAULT NULL, + `disk1` int(11) NOT NULL DEFAULT '0', + `cap1` char(25) NOT NULL DEFAULT '0', + `disk2` int(11) DEFAULT NULL, + `cap2` char(25) DEFAULT NULL, + `comment` char(255) DEFAULT NULL, + PRIMARY KEY (`id`) + ); + """; - public static readonly string Consoles = @"CREATE TABLE IF NOT EXISTS `consoles` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `company` int(11) NOT NULL DEFAULT '0', - `name` char(50) NOT NULL DEFAULT '', - `year` int(11) NOT NULL DEFAULT '0', - `cpu1` int(11) NOT NULL DEFAULT '0', - `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00', - `cpu2` int(11) DEFAULT NULL, - `mhz2` decimal(11,2) DEFAULT NULL, - `bits` int(11) NOT NULL DEFAULT '0', - `ram` int(11) NOT NULL DEFAULT '0', - `rom` int(11) NOT NULL DEFAULT '0', - `gpu` int(11) NOT NULL DEFAULT '0', - `vram` int(11) NOT NULL DEFAULT '0', - `res` char(11) NOT NULL DEFAULT '', - `colors` int(11) NOT NULL DEFAULT '0', - `palette` int(11) NOT NULL DEFAULT '0', - `spu` int(11) NOT NULL DEFAULT '0', - `schannels` int(11) NOT NULL DEFAULT '0', - `mpu` int(11) NOT NULL DEFAULT '0', - `mchannels` int(11) NOT NULL DEFAULT '0', - `format` int(11) NOT NULL DEFAULT '0', - `cap` int(11) NOT NULL DEFAULT '0', - `comments` char(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Consoles = """ + CREATE TABLE IF NOT EXISTS `consoles` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `company` int(11) NOT NULL DEFAULT '0', + `name` char(50) NOT NULL DEFAULT '', + `year` int(11) NOT NULL DEFAULT '0', + `cpu1` int(11) NOT NULL DEFAULT '0', + `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00', + `cpu2` int(11) DEFAULT NULL, + `mhz2` decimal(11,2) DEFAULT NULL, + `bits` int(11) NOT NULL DEFAULT '0', + `ram` int(11) NOT NULL DEFAULT '0', + `rom` int(11) NOT NULL DEFAULT '0', + `gpu` int(11) NOT NULL DEFAULT '0', + `vram` int(11) NOT NULL DEFAULT '0', + `res` char(11) NOT NULL DEFAULT '', + `colors` int(11) NOT NULL DEFAULT '0', + `palette` int(11) NOT NULL DEFAULT '0', + `spu` int(11) NOT NULL DEFAULT '0', + `schannels` int(11) NOT NULL DEFAULT '0', + `mpu` int(11) NOT NULL DEFAULT '0', + `mchannels` int(11) NOT NULL DEFAULT '0', + `format` int(11) NOT NULL DEFAULT '0', + `cap` int(11) NOT NULL DEFAULT '0', + `comments` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string ConsoleCompanies = @"CREATE TABLE IF NOT EXISTS `console_company` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `company` char(128) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string ConsoleCompanies = """ + CREATE TABLE IF NOT EXISTS `console_company` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `company` char(128) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Cpus = @"CREATE TABLE IF NOT EXISTS `cpu` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `cpu` char(50) NOT NULL DEFAULT '', - KEY `id` (`id`) - );"; + public static readonly string Cpus = """ + CREATE TABLE IF NOT EXISTS `cpu` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cpu` char(50) NOT NULL DEFAULT '', + KEY `id` (`id`) + ); + """; - public static readonly string Dsps = @"CREATE TABLE IF NOT EXISTS `DSPs` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `DSP` char(50) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Dsps = """ + CREATE TABLE IF NOT EXISTS `DSPs` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `DSP` char(50) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Forbidden = @"CREATE TABLE IF NOT EXISTS `forbidden` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `browser` char(128) NOT NULL DEFAULT '', - `date` char(20) NOT NULL DEFAULT '', - `ip` char(16) NOT NULL DEFAULT '', - `referer` char(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Forbidden = """ + CREATE TABLE IF NOT EXISTS `forbidden` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `browser` char(128) NOT NULL DEFAULT '', + `date` char(20) NOT NULL DEFAULT '', + `ip` char(16) NOT NULL DEFAULT '', + `referer` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string DiskFormats = @"CREATE TABLE IF NOT EXISTS `Formatos_de_disco` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `Format` char(50) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string DiskFormats = """ + CREATE TABLE IF NOT EXISTS `Formatos_de_disco` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `Format` char(50) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Gpus = @"CREATE TABLE IF NOT EXISTS `gpus` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `gpu` char(128) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Gpus = """ + CREATE TABLE IF NOT EXISTS `gpus` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `gpu` char(128) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Logs = @"CREATE TABLE IF NOT EXISTS `log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `browser` char(128) NOT NULL DEFAULT '', - `ip` char(16) NOT NULL DEFAULT '', - `date` char(20) NOT NULL DEFAULT '', - `referer` char(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Logs = """ + CREATE TABLE IF NOT EXISTS `log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `browser` char(128) NOT NULL DEFAULT '', + `ip` char(16) NOT NULL DEFAULT '', + `date` char(20) NOT NULL DEFAULT '', + `referer` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string MoneyDonations = @"CREATE TABLE IF NOT EXISTS `money_donation` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `donator` char(128) NOT NULL DEFAULT '', - `quantity` decimal(11,2) NOT NULL DEFAULT '0.00', - PRIMARY KEY (`id`) - );"; + public static readonly string MoneyDonations = """ + CREATE TABLE IF NOT EXISTS `money_donation` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `donator` char(128) NOT NULL DEFAULT '', + `quantity` decimal(11,2) NOT NULL DEFAULT '0.00', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Mpus = @"CREATE TABLE IF NOT EXISTS `mpus` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `mpu` char(50) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Mpus = """ + CREATE TABLE IF NOT EXISTS `mpus` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `mpu` char(50) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string News = @"CREATE TABLE IF NOT EXISTS `news` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `date` char(20) NOT NULL DEFAULT '', - `type` int(11) NOT NULL DEFAULT '0', - `added_id` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) - );"; + public static readonly string News = """ + CREATE TABLE IF NOT EXISTS `news` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `date` char(20) NOT NULL DEFAULT '', + `type` int(11) NOT NULL DEFAULT '0', + `added_id` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ); + """; - public static readonly string OwnComputers = @"CREATE TABLE IF NOT EXISTS `own_computer` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `db_id` int(11) NOT NULL DEFAULT '0', - `date` varchar(20) NOT NULL DEFAULT '', - `status` int(11) NOT NULL DEFAULT '0', - `trade` int(11) NOT NULL DEFAULT '0', - `boxed` int(11) NOT NULL DEFAULT '0', - `manuals` int(11) NOT NULL DEFAULT '0', - `cpu1` int(11) NOT NULL DEFAULT '0', - `mhz1` decimal(10,0) NOT NULL DEFAULT '0', - `cpu2` int(11) NOT NULL DEFAULT '0', - `mhz2` decimal(10,0) NOT NULL DEFAULT '0', - `ram` int(11) NOT NULL DEFAULT '0', - `vram` int(11) NOT NULL DEFAULT '0', - `rigid` varchar(64) NOT NULL DEFAULT '', - `disk1` int(11) NOT NULL DEFAULT '0', - `cap1` int(11) NOT NULL DEFAULT '0', - `disk2` int(11) NOT NULL DEFAULT '0', - `cap2` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) - );"; + public static readonly string OwnComputers = """ + CREATE TABLE IF NOT EXISTS `own_computer` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `db_id` int(11) NOT NULL DEFAULT '0', + `date` varchar(20) NOT NULL DEFAULT '', + `status` int(11) NOT NULL DEFAULT '0', + `trade` int(11) NOT NULL DEFAULT '0', + `boxed` int(11) NOT NULL DEFAULT '0', + `manuals` int(11) NOT NULL DEFAULT '0', + `cpu1` int(11) NOT NULL DEFAULT '0', + `mhz1` decimal(10,0) NOT NULL DEFAULT '0', + `cpu2` int(11) NOT NULL DEFAULT '0', + `mhz2` decimal(10,0) NOT NULL DEFAULT '0', + `ram` int(11) NOT NULL DEFAULT '0', + `vram` int(11) NOT NULL DEFAULT '0', + `rigid` varchar(64) NOT NULL DEFAULT '', + `disk1` int(11) NOT NULL DEFAULT '0', + `cap1` int(11) NOT NULL DEFAULT '0', + `disk2` int(11) NOT NULL DEFAULT '0', + `cap2` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ); + """; - public static readonly string OwnConsoles = @"CREATE TABLE IF NOT EXISTS `own_consoles` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `db_id` int(11) NOT NULL DEFAULT '0', - `date` char(20) NOT NULL DEFAULT '', - `status` int(11) NOT NULL DEFAULT '0', - `trade` int(11) NOT NULL DEFAULT '0', - `boxed` int(11) NOT NULL DEFAULT '0', - `manuals` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) - );"; + public static readonly string OwnConsoles = """ + CREATE TABLE IF NOT EXISTS `own_consoles` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `db_id` int(11) NOT NULL DEFAULT '0', + `date` char(20) NOT NULL DEFAULT '', + `status` int(11) NOT NULL DEFAULT '0', + `trade` int(11) NOT NULL DEFAULT '0', + `boxed` int(11) NOT NULL DEFAULT '0', + `manuals` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ); + """; - public static readonly string ProcesadoresPrincipales = - @"CREATE TABLE IF NOT EXISTS `procesadores_principales` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `CPU` char(50) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; - } + public static readonly string ProcesadoresPrincipales = """ + CREATE TABLE IF NOT EXISTS `procesadores_principales` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `CPU` char(50) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V20.cs b/Marechai.Database/Schemas/Sql/V20.cs index e2760bda..4bed3cec 100644 --- a/Marechai.Database/Schemas/Sql/V20.cs +++ b/Marechai.Database/Schemas/Sql/V20.cs @@ -23,92 +23,92 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V20 { - public static class V20 - { - public static readonly string Admins = V19.Admins; + public static readonly string Admins = V19.Admins; - public static readonly string BrowserTests = V19.BrowserTests; + public static readonly string BrowserTests = V19.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`));\n" + - "INSERT INTO marechai_db (version) VALUES ('20');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`));\n" + + "INSERT INTO marechai_db (version) VALUES ('20');"; - public static readonly string Companies = V19.Companies; + public static readonly string Companies = V19.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (;\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + - "`company` int(11) NOT NULL DEFAULT '0',;\n" + - "`year` int(11) NOT NULL DEFAULT '0',;\n" + - "`model` char(50) NOT NULL DEFAULT '',;\n" + - "`type` int(11) NOT NULL DEFAULT '0',;\n" + "PRIMARY KEY (`id`),;\n" + - "KEY `idx_machines_company` (`company`),;\n" + - "KEY `idx_machines_year` (`year`),;\n" + - "KEY `idx_machines_model` (`model`),;\n" + - "KEY `idx_machines_type` (`type`));"; + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`year` int(11) NOT NULL DEFAULT '0',;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_year` (`year`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_type` (`type`));"; - public static readonly string Forbidden = V19.Forbidden; + public static readonly string Forbidden = V19.Forbidden; - public static readonly string Gpus = V19.Gpus; + public static readonly string Gpus = V19.Gpus; - public static readonly string Logs = V19.Logs; + public static readonly string Logs = V19.Logs; - public static readonly string MoneyDonations = V19.MoneyDonations; + public static readonly string MoneyDonations = V19.MoneyDonations; - public static readonly string News = V19.News; + public static readonly string News = V19.News; - public static readonly string OwnedComputers = V19.OwnedComputers; + public static readonly string OwnedComputers = V19.OwnedComputers; - public static readonly string OwnedConsoles = V19.OwnedConsoles; + public static readonly string OwnedConsoles = V19.OwnedConsoles; - public static readonly string Processors = V19.Processors; + public static readonly string Processors = V19.Processors; - public static readonly string SoundSynths = V19.SoundSynths; + public static readonly string SoundSynths = V19.SoundSynths; - public static readonly string MachinesForeignKeys = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; + public static readonly string MachinesForeignKeys = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; - public static readonly string Iso3166Numeric = V19.Iso3166Numeric; + public static readonly string Iso3166Numeric = V19.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V19.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V19.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V19.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V19.CompaniesForeignKeys; - public static readonly string CompanyLogos = V19.CompanyLogos; + public static readonly string CompanyLogos = V19.CompanyLogos; - public static readonly string CompanyDescriptions = V19.CompanyDescriptions; + public static readonly string CompanyDescriptions = V19.CompanyDescriptions; - public static readonly string InstructionSets = V19.InstructionSets; + public static readonly string InstructionSets = V19.InstructionSets; - public static readonly string InstructionSetExtensions = V19.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V19.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V19.InstructionSetExtensionsByProcessor; + public static readonly string InstructionSetExtensionsByProcessor = V19.InstructionSetExtensionsByProcessor; - public static readonly string ProcessorsByMachine = V19.ProcessorsByMachine; + public static readonly string ProcessorsByMachine = V19.ProcessorsByMachine; - public static readonly string GpusByMachine = V19.GpusByMachine; + public static readonly string GpusByMachine = V19.GpusByMachine; - public static readonly string SoundByMachine = V19.SoundByMachine; + public static readonly string SoundByMachine = V19.SoundByMachine; - public static readonly string MemoryByMachine = V19.MemoryByMachine; + public static readonly string MemoryByMachine = V19.MemoryByMachine; - public static readonly string Resolutions = V19.Resolutions; + public static readonly string Resolutions = V19.Resolutions; - public static readonly string ResolutionsByGpu = V19.ResolutionsByGpu; + public static readonly string ResolutionsByGpu = V19.ResolutionsByGpu; - public static readonly string StorageByMachine = "CREATE TABLE `storage_by_machine` (\n" + - "`machine` INT NOT NULL,\n" + - "`type` INT NOT NULL DEFAULT 0,\n" + - "`interface` INT NOT NULL DEFAULT 0,\n" + - "`capacity` BIGINT DEFAULT NULL,\n" + - "KEY `idx_storage_machine` (`machine`),\n" + - "KEY `idx_storage_type` (`type`),\n" + - "KEY `idx_storage_interface` (`interface`),\n" + - "KEY `idx_storage_capacity` (`capacity`),\n" + - "CONSTRAINT `fk_storage_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; - } + public static readonly string StorageByMachine = "CREATE TABLE `storage_by_machine` (\n" + + "`machine` INT NOT NULL,\n" + + "`type` INT NOT NULL DEFAULT 0,\n" + + "`interface` INT NOT NULL DEFAULT 0,\n" + + "`capacity` BIGINT DEFAULT NULL,\n" + + "KEY `idx_storage_machine` (`machine`),\n" + + "KEY `idx_storage_type` (`type`),\n" + + "KEY `idx_storage_interface` (`interface`),\n" + + "KEY `idx_storage_capacity` (`capacity`),\n" + + "CONSTRAINT `fk_storage_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V21.cs b/Marechai.Database/Schemas/Sql/V21.cs index cee6c523..e28e920f 100644 --- a/Marechai.Database/Schemas/Sql/V21.cs +++ b/Marechai.Database/Schemas/Sql/V21.cs @@ -23,92 +23,92 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V21 { - public static class V21 - { - public static readonly string Admins = V20.Admins; + public static readonly string Admins = V20.Admins; - public static readonly string BrowserTests = V20.BrowserTests; + public static readonly string BrowserTests = V20.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`));\n" + - "INSERT INTO marechai_db (version) VALUES ('21');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`));\n" + + "INSERT INTO marechai_db (version) VALUES ('21');"; - public static readonly string Companies = V20.Companies; + public static readonly string Companies = V20.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (;\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + - "`company` int(11) NOT NULL DEFAULT '0',;\n" + - "`introduced` DATETIME NULL,;\n" + - "`model` char(50) NOT NULL DEFAULT '',;\n" + - "`type` int(11) NOT NULL DEFAULT '0',;\n" + "PRIMARY KEY (`id`),;\n" + - "KEY `idx_machines_company` (`company`),;\n" + - "KEY `idx_machines_introduced` (`introduced`),;\n" + - "KEY `idx_machines_model` (`model`),;\n" + - "KEY `idx_machines_type` (`type`));"; + public static readonly string Machines = "CREATE TABLE `machines` (;\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,;\n" + + "`company` int(11) NOT NULL DEFAULT '0',;\n" + + "`introduced` DATETIME NULL,;\n" + + "`model` char(50) NOT NULL DEFAULT '',;\n" + + "`type` int(11) NOT NULL DEFAULT '0',;\n" + + "PRIMARY KEY (`id`),;\n" + + "KEY `idx_machines_company` (`company`),;\n" + + "KEY `idx_machines_introduced` (`introduced`),;\n" + + "KEY `idx_machines_model` (`model`),;\n" + + "KEY `idx_machines_type` (`type`));"; - public static readonly string Forbidden = V20.Forbidden; + public static readonly string Forbidden = V20.Forbidden; - public static readonly string Gpus = V20.Gpus; + public static readonly string Gpus = V20.Gpus; - public static readonly string Logs = V20.Logs; + public static readonly string Logs = V20.Logs; - public static readonly string MoneyDonations = V20.MoneyDonations; + public static readonly string MoneyDonations = V20.MoneyDonations; - public static readonly string News = V20.News; + public static readonly string News = V20.News; - public static readonly string OwnedComputers = V20.OwnedComputers; + public static readonly string OwnedComputers = V20.OwnedComputers; - public static readonly string OwnedConsoles = V20.OwnedConsoles; + public static readonly string OwnedConsoles = V20.OwnedConsoles; - public static readonly string Processors = V20.Processors; + public static readonly string Processors = V20.Processors; - public static readonly string SoundSynths = V20.SoundSynths; + public static readonly string SoundSynths = V20.SoundSynths; - public static readonly string MachinesForeignKeys = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; + public static readonly string MachinesForeignKeys = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;"; - public static readonly string Iso3166Numeric = V20.Iso3166Numeric; + public static readonly string Iso3166Numeric = V20.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V20.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V20.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V20.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V20.CompaniesForeignKeys; - public static readonly string CompanyLogos = V20.CompanyLogos; + public static readonly string CompanyLogos = V20.CompanyLogos; - public static readonly string CompanyDescriptions = V20.CompanyDescriptions; + public static readonly string CompanyDescriptions = V20.CompanyDescriptions; - public static readonly string InstructionSets = V20.InstructionSets; + public static readonly string InstructionSets = V20.InstructionSets; - public static readonly string InstructionSetExtensions = V20.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V20.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V20.InstructionSetExtensionsByProcessor; + public static readonly string InstructionSetExtensionsByProcessor = V20.InstructionSetExtensionsByProcessor; - public static readonly string ProcessorsByMachine = V20.ProcessorsByMachine; + public static readonly string ProcessorsByMachine = V20.ProcessorsByMachine; - public static readonly string GpusByMachine = V20.GpusByMachine; + public static readonly string GpusByMachine = V20.GpusByMachine; - public static readonly string SoundByMachine = V20.SoundByMachine; + public static readonly string SoundByMachine = V20.SoundByMachine; - public static readonly string MemoryByMachine = V20.MemoryByMachine; + public static readonly string MemoryByMachine = V20.MemoryByMachine; - public static readonly string Resolutions = V20.Resolutions; + public static readonly string Resolutions = V20.Resolutions; - public static readonly string ResolutionsByGpu = V20.ResolutionsByGpu; + public static readonly string ResolutionsByGpu = V20.ResolutionsByGpu; - public static readonly string StorageByMachine = "CREATE TABLE `storage_by_machine` (\n" + - "`machine` INT NOT NULL,\n" + - "`type` INT NOT NULL DEFAULT 0,\n" + - "`interface` INT NOT NULL DEFAULT 0,\n" + - "`capacity` BIGINT DEFAULT NULL,\n" + - "KEY `idx_storage_machine` (`machine`),\n" + - "KEY `idx_storage_type` (`type`),\n" + - "KEY `idx_storage_interface` (`interface`),\n" + - "KEY `idx_storage_capacity` (`capacity`),\n" + - "CONSTRAINT `fk_storage_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; - } + public static readonly string StorageByMachine = "CREATE TABLE `storage_by_machine` (\n" + + "`machine` INT NOT NULL,\n" + + "`type` INT NOT NULL DEFAULT 0,\n" + + "`interface` INT NOT NULL DEFAULT 0,\n" + + "`capacity` BIGINT DEFAULT NULL,\n" + + "KEY `idx_storage_machine` (`machine`),\n" + + "KEY `idx_storage_type` (`type`),\n" + + "KEY `idx_storage_interface` (`interface`),\n" + + "KEY `idx_storage_capacity` (`capacity`),\n" + + "CONSTRAINT `fk_storage_by_machine_machine` FOREIGN KEY (`machine`) REFERENCES `machines` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V22.cs b/Marechai.Database/Schemas/Sql/V22.cs index 88d2a3c1..e37b20c8 100644 --- a/Marechai.Database/Schemas/Sql/V22.cs +++ b/Marechai.Database/Schemas/Sql/V22.cs @@ -23,96 +23,97 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V22 { - public static class V22 - { - public static readonly string Admins = V21.Admins; + public static readonly string Admins = V21.Admins; - public static readonly string BrowserTests = V21.BrowserTests; + public static readonly string BrowserTests = V21.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`));\n" + - "INSERT INTO marechai_db (version) VALUES ('22');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`));\n" + + "INSERT INTO marechai_db (version) VALUES ('22');"; - public static readonly string Companies = V21.Companies; + public static readonly string Companies = V21.Companies; - public static readonly string Machines = "CREATE TABLE `machines` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`company` int(11) NOT NULL DEFAULT '0',\n" + - "`name` varchar(255) NOT NULL,\n" + - "`type` int(11) NOT NULL DEFAULT '0',\n" + - "`introduced` datetime DEFAULT NULL,\n" + - "`family` int(11) DEFAULT NULL,\n" + - "`model` varchar(50) DEFAULT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_machines_company` (`company`),\n" + - "KEY `idx_machines_type` (`type`),\n" + - "KEY `idx_machines_introduced` (`introduced`),\n" + - "KEY `idx_machines_family` (`family`),\n" + - "KEY `idx_machines_name` (`name`),\n" + - "KEY `idx_machines_model` (`model`));"; + public static readonly string Machines = "CREATE TABLE `machines` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`company` int(11) NOT NULL DEFAULT '0',\n" + + "`name` varchar(255) NOT NULL,\n" + + "`type` int(11) NOT NULL DEFAULT '0',\n" + + "`introduced` datetime DEFAULT NULL,\n" + + "`family` int(11) DEFAULT NULL,\n" + + "`model` varchar(50) DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_machines_company` (`company`),\n" + + "KEY `idx_machines_type` (`type`),\n" + + "KEY `idx_machines_introduced` (`introduced`),\n" + + "KEY `idx_machines_family` (`family`),\n" + + "KEY `idx_machines_name` (`name`),\n" + + "KEY `idx_machines_model` (`model`));"; - public static readonly string Forbidden = V21.Forbidden; + public static readonly string Forbidden = V21.Forbidden; - public static readonly string Gpus = V21.Gpus; + public static readonly string Gpus = V21.Gpus; - public static readonly string Logs = V21.Logs; + public static readonly string Logs = V21.Logs; - public static readonly string MoneyDonations = V21.MoneyDonations; + public static readonly string MoneyDonations = V21.MoneyDonations; - public static readonly string News = V21.News; + public static readonly string News = V21.News; - public static readonly string OwnedComputers = V21.OwnedComputers; + public static readonly string OwnedComputers = V21.OwnedComputers; - public static readonly string OwnedConsoles = V21.OwnedConsoles; + public static readonly string OwnedConsoles = V21.OwnedConsoles; - public static readonly string Processors = V21.Processors; + public static readonly string Processors = V21.Processors; - public static readonly string SoundSynths = V21.SoundSynths; + public static readonly string SoundSynths = V21.SoundSynths; - public static readonly string MachinesForeignKeys = - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + - "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_family` (family) REFERENCES `machine_families` (`id`) ON UPDATE CASCADE;"; + public static readonly string MachinesForeignKeys = + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `machines` ADD FOREIGN KEY `fk_machines_family` (family) REFERENCES `machine_families` (`id`) ON UPDATE CASCADE;"; - public static readonly string Iso3166Numeric = V21.Iso3166Numeric; + public static readonly string Iso3166Numeric = V21.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V21.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V21.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V21.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V21.CompaniesForeignKeys; - public static readonly string CompanyLogos = V21.CompanyLogos; + public static readonly string CompanyLogos = V21.CompanyLogos; - public static readonly string CompanyDescriptions = V21.CompanyDescriptions; + public static readonly string CompanyDescriptions = V21.CompanyDescriptions; - public static readonly string InstructionSets = V21.InstructionSets; + public static readonly string InstructionSets = V21.InstructionSets; - public static readonly string InstructionSetExtensions = V21.InstructionSetExtensions; + public static readonly string InstructionSetExtensions = V21.InstructionSetExtensions; - public static readonly string InstructionSetExtensionsByProcessor = V21.InstructionSetExtensionsByProcessor; + public static readonly string InstructionSetExtensionsByProcessor = V21.InstructionSetExtensionsByProcessor; - public static readonly string ProcessorsByMachine = V21.ProcessorsByMachine; + public static readonly string ProcessorsByMachine = V21.ProcessorsByMachine; - public static readonly string GpusByMachine = V21.GpusByMachine; + public static readonly string GpusByMachine = V21.GpusByMachine; - public static readonly string SoundByMachine = V21.SoundByMachine; + public static readonly string SoundByMachine = V21.SoundByMachine; - public static readonly string MemoryByMachine = V21.MemoryByMachine; + public static readonly string MemoryByMachine = V21.MemoryByMachine; - public static readonly string Resolutions = V21.Resolutions; + public static readonly string Resolutions = V21.Resolutions; - public static readonly string ResolutionsByGpu = V21.ResolutionsByGpu; + public static readonly string ResolutionsByGpu = V21.ResolutionsByGpu; - public static readonly string StorageByMachine = V21.StorageByMachine; + public static readonly string StorageByMachine = V21.StorageByMachine; - public static readonly string MachineFamilies = "CREATE TABLE `machine_families` (\n" + - "`id` INT NOT NULL AUTO_INCREMENT,\n" + - "`company` INT NOT NULL,\n" + - "`name` VARCHAR(255) NOT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_machine_families_company` (`company`),\n" + - "KEY `idx_machine_families_name` (`name`),\n" + - "CONSTRAINT `fk_machine_families_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; - } + public static readonly string MachineFamilies = "CREATE TABLE `machine_families` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`company` INT NOT NULL,\n" + + "`name` VARCHAR(255) NOT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_machine_families_company` (`company`),\n" + + "KEY `idx_machine_families_name` (`name`),\n" + + "CONSTRAINT `fk_machine_families_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE ON DELETE CASCADE);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V3.cs b/Marechai.Database/Schemas/Sql/V3.cs index e0b3be2d..21381134 100644 --- a/Marechai.Database/Schemas/Sql/V3.cs +++ b/Marechai.Database/Schemas/Sql/V3.cs @@ -23,204 +23,237 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V3 { - public static class V3 - { - public static readonly string Admins = @"CREATE TABLE `admins` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user` char(50) NOT NULL DEFAULT '', - `password` char(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Admins = """ + CREATE TABLE `admins` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user` char(50) NOT NULL DEFAULT '', + `password` char(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string BrowserTests = @"CREATE TABLE IF NOT EXISTS `browser_tests` ( - `id` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT, - `user_agent` varchar(128) NOT NULL DEFAULT '', - `browser` varchar(64) NOT NULL DEFAULT '', - `version` varchar(16) NOT NULL DEFAULT '', - `os` varchar(32) NOT NULL DEFAULT '', - `platform` varchar(8) NOT NULL DEFAULT '', - `gif87` tinyint(1) NOT NULL DEFAULT '0', - `gif89` tinyint(1) NOT NULL DEFAULT '0', - `jpeg` tinyint(1) NOT NULL DEFAULT '0', - `png` tinyint(1) NOT NULL DEFAULT '0', - `pngt` tinyint(1) NOT NULL DEFAULT '0', - `agif` tinyint(1) NOT NULL DEFAULT '0', - `table` tinyint(1) NOT NULL DEFAULT '0', - `colors` tinyint(1) NOT NULL DEFAULT '0', - `js` tinyint(1) NOT NULL DEFAULT '0', - `frames` tinyint(1) NOT NULL DEFAULT '0', - `flash` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) - );"; + public static readonly string BrowserTests = """ + CREATE TABLE IF NOT EXISTS `browser_tests` ( + `id` smallint(5) unsigned zerofill NOT NULL AUTO_INCREMENT, + `user_agent` varchar(128) NOT NULL DEFAULT '', + `browser` varchar(64) NOT NULL DEFAULT '', + `version` varchar(16) NOT NULL DEFAULT '', + `os` varchar(32) NOT NULL DEFAULT '', + `platform` varchar(8) NOT NULL DEFAULT '', + `gif87` tinyint(1) NOT NULL DEFAULT '0', + `gif89` tinyint(1) NOT NULL DEFAULT '0', + `jpeg` tinyint(1) NOT NULL DEFAULT '0', + `png` tinyint(1) NOT NULL DEFAULT '0', + `pngt` tinyint(1) NOT NULL DEFAULT '0', + `agif` tinyint(1) NOT NULL DEFAULT '0', + `table` tinyint(1) NOT NULL DEFAULT '0', + `colors` tinyint(1) NOT NULL DEFAULT '0', + `js` tinyint(1) NOT NULL DEFAULT '0', + `frames` tinyint(1) NOT NULL DEFAULT '0', + `flash` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ); + """; - public static readonly string MarechaiDb = @"CREATE TABLE `marechai_db` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `version` int(11) NOT NULL, - `updated` datetime DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) - ); - INSERT INTO marechai_db (version) VALUES ('3');"; + public static readonly string MarechaiDb = """ + CREATE TABLE `marechai_db` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `version` int(11) NOT NULL, + `updated` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) + ); + INSERT INTO marechai_db (version) VALUES ('3'); + """; - public static readonly string Companies = @"CREATE TABLE IF NOT EXISTS `companies` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` char(128) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Companies = """ + CREATE TABLE IF NOT EXISTS `companies` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` char(128) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Computers = @"CREATE TABLE IF NOT EXISTS `computers` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `company` int(11) NOT NULL DEFAULT '0', - `year` int(11) NOT NULL DEFAULT '0', - `model` char(50) NOT NULL DEFAULT '', - `cpu1` int(11) NOT NULL DEFAULT '0', - `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00', - `cpu2` int(11) DEFAULT NULL, - `mhz2` decimal(11,2) DEFAULT NULL, - `bits` int(11) NOT NULL DEFAULT '0', - `ram` int(11) NOT NULL DEFAULT '0', - `rom` int(11) NOT NULL DEFAULT '0', - `gpu` int(11) NOT NULL DEFAULT '0', - `vram` int(11) NOT NULL DEFAULT '0', - `colors` int(11) NOT NULL DEFAULT '0', - `res` char(10) NOT NULL DEFAULT '', - `sound_synth` int(11) NOT NULL DEFAULT '0', - `music_synth` int(11) NOT NULL DEFAULT '0', - `sound_channels` int(11) NOT NULL DEFAULT '0', - `music_channels` int(11) NOT NULL DEFAULT '0', - `hdd1` int(11) NOT NULL DEFAULT '0', - `hdd2` int(11) DEFAULT NULL, - `hdd3` int(11) DEFAULT NULL, - `disk1` int(11) NOT NULL DEFAULT '0', - `cap1` char(25) NOT NULL DEFAULT '0', - `disk2` int(11) DEFAULT NULL, - `cap2` char(25) DEFAULT NULL, - `comment` char(255) DEFAULT NULL, - PRIMARY KEY (`id`) - );"; + public static readonly string Computers = """ + CREATE TABLE IF NOT EXISTS `computers` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `company` int(11) NOT NULL DEFAULT '0', + `year` int(11) NOT NULL DEFAULT '0', + `model` char(50) NOT NULL DEFAULT '', + `cpu1` int(11) NOT NULL DEFAULT '0', + `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00', + `cpu2` int(11) DEFAULT NULL, + `mhz2` decimal(11,2) DEFAULT NULL, + `bits` int(11) NOT NULL DEFAULT '0', + `ram` int(11) NOT NULL DEFAULT '0', + `rom` int(11) NOT NULL DEFAULT '0', + `gpu` int(11) NOT NULL DEFAULT '0', + `vram` int(11) NOT NULL DEFAULT '0', + `colors` int(11) NOT NULL DEFAULT '0', + `res` char(10) NOT NULL DEFAULT '', + `sound_synth` int(11) NOT NULL DEFAULT '0', + `music_synth` int(11) NOT NULL DEFAULT '0', + `sound_channels` int(11) NOT NULL DEFAULT '0', + `music_channels` int(11) NOT NULL DEFAULT '0', + `hdd1` int(11) NOT NULL DEFAULT '0', + `hdd2` int(11) DEFAULT NULL, + `hdd3` int(11) DEFAULT NULL, + `disk1` int(11) NOT NULL DEFAULT '0', + `cap1` char(25) NOT NULL DEFAULT '0', + `disk2` int(11) DEFAULT NULL, + `cap2` char(25) DEFAULT NULL, + `comment` char(255) DEFAULT NULL, + PRIMARY KEY (`id`) + ); + """; - public static readonly string Consoles = @"CREATE TABLE IF NOT EXISTS `consoles` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `company` int(11) NOT NULL DEFAULT '0', - `model` char(50) NOT NULL DEFAULT '', - `year` int(11) NOT NULL DEFAULT '0', - `cpu1` int(11) NOT NULL DEFAULT '0', - `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00', - `cpu2` int(11) DEFAULT NULL, - `mhz2` decimal(11,2) DEFAULT NULL, - `bits` int(11) NOT NULL DEFAULT '0', - `ram` int(11) NOT NULL DEFAULT '0', - `rom` int(11) NOT NULL DEFAULT '0', - `gpu` int(11) NOT NULL DEFAULT '0', - `vram` int(11) NOT NULL DEFAULT '0', - `res` char(11) NOT NULL DEFAULT '', - `colors` int(11) NOT NULL DEFAULT '0', - `palette` int(11) NOT NULL DEFAULT '0', - `sound_synth` int(11) NOT NULL DEFAULT '0', - `schannels` int(11) NOT NULL DEFAULT '0', - `music_channels` int(11) NOT NULL DEFAULT '0', - `mchannels` int(11) NOT NULL DEFAULT '0', - `format` int(11) NOT NULL DEFAULT '0', - `cap` int(11) NOT NULL DEFAULT '0', - `comments` char(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Consoles = """ + CREATE TABLE IF NOT EXISTS `consoles` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `company` int(11) NOT NULL DEFAULT '0', + `model` char(50) NOT NULL DEFAULT '', + `year` int(11) NOT NULL DEFAULT '0', + `cpu1` int(11) NOT NULL DEFAULT '0', + `mhz1` decimal(11,2) NOT NULL DEFAULT '0.00', + `cpu2` int(11) DEFAULT NULL, + `mhz2` decimal(11,2) DEFAULT NULL, + `bits` int(11) NOT NULL DEFAULT '0', + `ram` int(11) NOT NULL DEFAULT '0', + `rom` int(11) NOT NULL DEFAULT '0', + `gpu` int(11) NOT NULL DEFAULT '0', + `vram` int(11) NOT NULL DEFAULT '0', + `res` char(11) NOT NULL DEFAULT '', + `colors` int(11) NOT NULL DEFAULT '0', + `palette` int(11) NOT NULL DEFAULT '0', + `sound_synth` int(11) NOT NULL DEFAULT '0', + `schannels` int(11) NOT NULL DEFAULT '0', + `music_channels` int(11) NOT NULL DEFAULT '0', + `mchannels` int(11) NOT NULL DEFAULT '0', + `format` int(11) NOT NULL DEFAULT '0', + `cap` int(11) NOT NULL DEFAULT '0', + `comments` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string DiskFormats = @"CREATE TABLE IF NOT EXISTS `disk_formats` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `description` char(50) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string DiskFormats = """ + CREATE TABLE IF NOT EXISTS `disk_formats` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `description` char(50) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Forbidden = @"CREATE TABLE IF NOT EXISTS `forbidden` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `browser` char(128) NOT NULL DEFAULT '', - `date` char(20) NOT NULL DEFAULT '', - `ip` char(16) NOT NULL DEFAULT '', - `referer` char(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Forbidden = """ + CREATE TABLE IF NOT EXISTS `forbidden` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `browser` char(128) NOT NULL DEFAULT '', + `date` char(20) NOT NULL DEFAULT '', + `ip` char(16) NOT NULL DEFAULT '', + `referer` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Gpus = @"CREATE TABLE IF NOT EXISTS `gpus` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` char(128) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Gpus = """ + CREATE TABLE IF NOT EXISTS `gpus` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` char(128) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Logs = @"CREATE TABLE IF NOT EXISTS `log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `browser` char(128) NOT NULL DEFAULT '', - `ip` char(16) NOT NULL DEFAULT '', - `date` char(20) NOT NULL DEFAULT '', - `referer` char(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string Logs = """ + CREATE TABLE IF NOT EXISTS `log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `browser` char(128) NOT NULL DEFAULT '', + `ip` char(16) NOT NULL DEFAULT '', + `date` char(20) NOT NULL DEFAULT '', + `referer` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string MoneyDonations = @"CREATE TABLE IF NOT EXISTS `money_donation` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `donator` char(128) NOT NULL DEFAULT '', - `quantity` decimal(11,2) NOT NULL DEFAULT '0.00', - PRIMARY KEY (`id`) - );"; + public static readonly string MoneyDonations = """ + CREATE TABLE IF NOT EXISTS `money_donation` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `donator` char(128) NOT NULL DEFAULT '', + `quantity` decimal(11,2) NOT NULL DEFAULT '0.00', + PRIMARY KEY (`id`) + ); + """; - public static readonly string MusicSynths = @"CREATE TABLE IF NOT EXISTS `music_synths` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` char(50) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; + public static readonly string MusicSynths = """ + CREATE TABLE IF NOT EXISTS `music_synths` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` char(50) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; - public static readonly string News = @"CREATE TABLE IF NOT EXISTS `news` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `date` char(20) NOT NULL DEFAULT '', - `type` int(11) NOT NULL DEFAULT '0', - `added_id` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) - );"; + public static readonly string News = """ + CREATE TABLE IF NOT EXISTS `news` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `date` char(20) NOT NULL DEFAULT '', + `type` int(11) NOT NULL DEFAULT '0', + `added_id` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ); + """; - public static readonly string OwnedComputers = @"CREATE TABLE IF NOT EXISTS `owned_computers` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `db_id` int(11) NOT NULL DEFAULT '0', - `date` varchar(20) NOT NULL DEFAULT '', - `status` int(11) NOT NULL DEFAULT '0', - `trade` int(11) NOT NULL DEFAULT '0', - `boxed` int(11) NOT NULL DEFAULT '0', - `manuals` int(11) NOT NULL DEFAULT '0', - `cpu1` int(11) NOT NULL DEFAULT '0', - `mhz1` decimal(10,0) NOT NULL DEFAULT '0', - `cpu2` int(11) NOT NULL DEFAULT '0', - `mhz2` decimal(10,0) NOT NULL DEFAULT '0', - `ram` int(11) NOT NULL DEFAULT '0', - `vram` int(11) NOT NULL DEFAULT '0', - `rigid` varchar(64) NOT NULL DEFAULT '', - `disk1` int(11) NOT NULL DEFAULT '0', - `cap1` int(11) NOT NULL DEFAULT '0', - `disk2` int(11) NOT NULL DEFAULT '0', - `cap2` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) - );"; + public static readonly string OwnedComputers = """ + CREATE TABLE IF NOT EXISTS `owned_computers` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `db_id` int(11) NOT NULL DEFAULT '0', + `date` varchar(20) NOT NULL DEFAULT '', + `status` int(11) NOT NULL DEFAULT '0', + `trade` int(11) NOT NULL DEFAULT '0', + `boxed` int(11) NOT NULL DEFAULT '0', + `manuals` int(11) NOT NULL DEFAULT '0', + `cpu1` int(11) NOT NULL DEFAULT '0', + `mhz1` decimal(10,0) NOT NULL DEFAULT '0', + `cpu2` int(11) NOT NULL DEFAULT '0', + `mhz2` decimal(10,0) NOT NULL DEFAULT '0', + `ram` int(11) NOT NULL DEFAULT '0', + `vram` int(11) NOT NULL DEFAULT '0', + `rigid` varchar(64) NOT NULL DEFAULT '', + `disk1` int(11) NOT NULL DEFAULT '0', + `cap1` int(11) NOT NULL DEFAULT '0', + `disk2` int(11) NOT NULL DEFAULT '0', + `cap2` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ); + """; - public static readonly string OwnedConsoles = @"CREATE TABLE IF NOT EXISTS `owned_consoles` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `db_id` int(11) NOT NULL DEFAULT '0', - `date` char(20) NOT NULL DEFAULT '', - `status` int(11) NOT NULL DEFAULT '0', - `trade` int(11) NOT NULL DEFAULT '0', - `boxed` int(11) NOT NULL DEFAULT '0', - `manuals` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) - );"; + public static readonly string OwnedConsoles = """ + CREATE TABLE IF NOT EXISTS `owned_consoles` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `db_id` int(11) NOT NULL DEFAULT '0', + `date` char(20) NOT NULL DEFAULT '', + `status` int(11) NOT NULL DEFAULT '0', + `trade` int(11) NOT NULL DEFAULT '0', + `boxed` int(11) NOT NULL DEFAULT '0', + `manuals` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ); + """; - public static readonly string Processors = @"CREATE TABLE IF NOT EXISTS `processors` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` char(50) NOT NULL DEFAULT '', - KEY `id` (`id`) - );"; + public static readonly string Processors = """ + CREATE TABLE IF NOT EXISTS `processors` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` char(50) NOT NULL DEFAULT '', + KEY `id` (`id`) + ); + """; - public static readonly string SoundSynths = @"CREATE TABLE IF NOT EXISTS `sound_synths` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` char(50) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) - );"; - } + public static readonly string SoundSynths = """ + CREATE TABLE IF NOT EXISTS `sound_synths` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` char(50) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) + ); + """; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V4.cs b/Marechai.Database/Schemas/Sql/V4.cs index 9ea5f2fa..49ae0170 100644 --- a/Marechai.Database/Schemas/Sql/V4.cs +++ b/Marechai.Database/Schemas/Sql/V4.cs @@ -23,138 +23,153 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V4 { - public static class V4 - { - public static readonly string Admins = V3.Admins + "\n" + "CREATE INDEX idx_admins_user ON admins (user);"; + public static readonly string Admins = V3.Admins + "\n" + "CREATE INDEX idx_admins_user ON admins (user);"; - public static readonly string BrowserTests = V3.BrowserTests + "\n" + - "CREATE INDEX idx_browser_tests_user_agent ON browser_tests (user_agent);\n" + - "CREATE INDEX idx_browser_tests_browser ON browser_tests (browser);\n" + - "CREATE INDEX idx_browser_tests_version ON browser_tests (version);\n" + - "CREATE INDEX idx_browser_tests_os ON browser_tests (os);\n" + - "CREATE INDEX idx_browser_tests_platform ON browser_tests (platform);"; + public static readonly string BrowserTests = V3.BrowserTests + + "\n" + + "CREATE INDEX idx_browser_tests_user_agent ON browser_tests (user_agent);\n" + + "CREATE INDEX idx_browser_tests_browser ON browser_tests (browser);\n" + + "CREATE INDEX idx_browser_tests_version ON browser_tests (version);\n" + + "CREATE INDEX idx_browser_tests_os ON browser_tests (os);\n" + + "CREATE INDEX idx_browser_tests_platform ON browser_tests (platform);"; - public static readonly string MarechaiDb = @"CREATE TABLE `marechai_db` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `version` int(11) NOT NULL, - `updated` datetime DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) - ); - INSERT INTO marechai_db (version) VALUES ('4');"; + public static readonly string MarechaiDb = """ + CREATE TABLE `marechai_db` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `version` int(11) NOT NULL, + `updated` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) + ); + INSERT INTO marechai_db (version) VALUES ('4'); + """; - public static readonly string Companies = - V3.Companies + "\n" + "CREATE INDEX idx_companies_name ON companies (name);"; + public static readonly string Companies = + V3.Companies + "\n" + "CREATE INDEX idx_companies_name ON companies (name);"; - public static readonly string Computers = V3.Computers + "\n" + - "CREATE INDEX idx_computers_company ON computers (company);\n" + - "CREATE INDEX idx_computers_year ON computers (year);\n" + - "CREATE INDEX idx_computers_model ON computers (model);\n" + - "CREATE INDEX idx_computers_cpu1 ON computers (cpu1);\n" + - "CREATE INDEX idx_computers_cpu2 ON computers (cpu2);\n" + - "CREATE INDEX idx_computers_mhz1 ON computers (mhz1);\n" + - "CREATE INDEX idx_computers_mhz2 ON computers (mhz2);\n" + - "CREATE INDEX idx_computers_bits ON computers (bits);\n" + - "CREATE INDEX idx_computers_ram ON computers (ram);\n" + - "CREATE INDEX idx_computers_rom ON computers (rom);\n" + - "CREATE INDEX idx_computers_gpu ON computers (gpu);\n" + - "CREATE INDEX idx_computers_vram ON computers (vram);\n" + - "CREATE INDEX idx_computers_colors ON computers (colors);\n" + - "CREATE INDEX idx_computers_res ON computers (res);\n" + - "CREATE INDEX idx_computers_sound_synth ON computers (sound_synth);\n" + - "CREATE INDEX idx_computers_music_synth ON computers (music_synth);\n" + - "CREATE INDEX idx_computers_hdd1 ON computers (hdd1);\n" + - "CREATE INDEX idx_computers_hdd2 ON computers (hdd2);\n" + - "CREATE INDEX idx_computers_hdd3 ON computers (hdd3);\n" + - "CREATE INDEX idx_computers_disk1 ON computers (disk1);\n" + - "CREATE INDEX idx_computers_disk2 ON computers (disk2);\n" + - "CREATE INDEX idx_computers_cap1 ON computers (cap1);\n" + - "CREATE INDEX idx_computers_cap2 ON computers (cap2);"; + public static readonly string Computers = V3.Computers + + "\n" + + "CREATE INDEX idx_computers_company ON computers (company);\n" + + "CREATE INDEX idx_computers_year ON computers (year);\n" + + "CREATE INDEX idx_computers_model ON computers (model);\n" + + "CREATE INDEX idx_computers_cpu1 ON computers (cpu1);\n" + + "CREATE INDEX idx_computers_cpu2 ON computers (cpu2);\n" + + "CREATE INDEX idx_computers_mhz1 ON computers (mhz1);\n" + + "CREATE INDEX idx_computers_mhz2 ON computers (mhz2);\n" + + "CREATE INDEX idx_computers_bits ON computers (bits);\n" + + "CREATE INDEX idx_computers_ram ON computers (ram);\n" + + "CREATE INDEX idx_computers_rom ON computers (rom);\n" + + "CREATE INDEX idx_computers_gpu ON computers (gpu);\n" + + "CREATE INDEX idx_computers_vram ON computers (vram);\n" + + "CREATE INDEX idx_computers_colors ON computers (colors);\n" + + "CREATE INDEX idx_computers_res ON computers (res);\n" + + "CREATE INDEX idx_computers_sound_synth ON computers (sound_synth);\n" + + "CREATE INDEX idx_computers_music_synth ON computers (music_synth);\n" + + "CREATE INDEX idx_computers_hdd1 ON computers (hdd1);\n" + + "CREATE INDEX idx_computers_hdd2 ON computers (hdd2);\n" + + "CREATE INDEX idx_computers_hdd3 ON computers (hdd3);\n" + + "CREATE INDEX idx_computers_disk1 ON computers (disk1);\n" + + "CREATE INDEX idx_computers_disk2 ON computers (disk2);\n" + + "CREATE INDEX idx_computers_cap1 ON computers (cap1);\n" + + "CREATE INDEX idx_computers_cap2 ON computers (cap2);"; - public static readonly string Consoles = V3.Consoles + "\n" + - "CREATE INDEX idx_consoles_company ON consoles (company);\n" + - "CREATE INDEX idx_consoles_year ON consoles (year);\n" + - "CREATE INDEX idx_consoles_model ON consoles (model);\n" + - "CREATE INDEX idx_consoles_cpu1 ON consoles (cpu1);\n" + - "CREATE INDEX idx_consoles_cpu2 ON consoles (cpu2);\n" + - "CREATE INDEX idx_consoles_mhz1 ON consoles (mhz1);\n" + - "CREATE INDEX idx_consoles_mhz2 ON consoles (mhz2);\n" + - "CREATE INDEX idx_consoles_bits ON consoles (bits);\n" + - "CREATE INDEX idx_consoles_ram ON consoles (ram);\n" + - "CREATE INDEX idx_consoles_rom ON consoles (rom);\n" + - "CREATE INDEX idx_consoles_gpu ON consoles (gpu);\n" + - "CREATE INDEX idx_consoles_vram ON consoles (vram);\n" + - "CREATE INDEX idx_consoles_colors ON consoles (colors);\n" + - "CREATE INDEX idx_consoles_res ON consoles (res);\n" + - "CREATE INDEX idx_consoles_sound_synth ON consoles (sound_synth);\n" + - "CREATE INDEX idx_consoles_music_synth ON consoles (music_synth);\n" + - "CREATE INDEX idx_consoles_palette ON consoles (palette);\n" + - "CREATE INDEX idx_consoles_format ON consoles (format);\n" + - "CREATE INDEX idx_consoles_cap ON consoles (cap);"; + public static readonly string Consoles = V3.Consoles + + "\n" + + "CREATE INDEX idx_consoles_company ON consoles (company);\n" + + "CREATE INDEX idx_consoles_year ON consoles (year);\n" + + "CREATE INDEX idx_consoles_model ON consoles (model);\n" + + "CREATE INDEX idx_consoles_cpu1 ON consoles (cpu1);\n" + + "CREATE INDEX idx_consoles_cpu2 ON consoles (cpu2);\n" + + "CREATE INDEX idx_consoles_mhz1 ON consoles (mhz1);\n" + + "CREATE INDEX idx_consoles_mhz2 ON consoles (mhz2);\n" + + "CREATE INDEX idx_consoles_bits ON consoles (bits);\n" + + "CREATE INDEX idx_consoles_ram ON consoles (ram);\n" + + "CREATE INDEX idx_consoles_rom ON consoles (rom);\n" + + "CREATE INDEX idx_consoles_gpu ON consoles (gpu);\n" + + "CREATE INDEX idx_consoles_vram ON consoles (vram);\n" + + "CREATE INDEX idx_consoles_colors ON consoles (colors);\n" + + "CREATE INDEX idx_consoles_res ON consoles (res);\n" + + "CREATE INDEX idx_consoles_sound_synth ON consoles (sound_synth);\n" + + "CREATE INDEX idx_consoles_music_synth ON consoles (music_synth);\n" + + "CREATE INDEX idx_consoles_palette ON consoles (palette);\n" + + "CREATE INDEX idx_consoles_format ON consoles (format);\n" + + "CREATE INDEX idx_consoles_cap ON consoles (cap);"; - public static readonly string DiskFormats = V3.DiskFormats + "\n" + - "CREATE INDEX idx_disk_formats_description ON disk_formats (description);"; + public static readonly string DiskFormats = + V3.DiskFormats + "\n" + "CREATE INDEX idx_disk_formats_description ON disk_formats (description);"; - public static readonly string Forbidden = V3.Forbidden + "\n" + - "CREATE INDEX idx_forbidden_browser ON forbidden (browser);\n" + - "CREATE INDEX idx_forbidden_date ON forbidden (date);\n" + - "CREATE INDEX idx_forbidden_ip ON forbidden (ip);\n" + - "CREATE INDEX idx_forbidden_referer ON forbidden (referer);"; + public static readonly string Forbidden = V3.Forbidden + + "\n" + + "CREATE INDEX idx_forbidden_browser ON forbidden (browser);\n" + + "CREATE INDEX idx_forbidden_date ON forbidden (date);\n" + + "CREATE INDEX idx_forbidden_ip ON forbidden (ip);\n" + + "CREATE INDEX idx_forbidden_referer ON forbidden (referer);"; - public static readonly string Gpus = V3.Gpus + "\n" + "CREATE INDEX idx_gpus_name ON gpus (name);"; + public static readonly string Gpus = V3.Gpus + "\n" + "CREATE INDEX idx_gpus_name ON gpus (name);"; - public static readonly string Logs = V3.Logs + "\n" + "CREATE INDEX idx_log_browser ON log (browser);\n" + - "CREATE INDEX idx_log_date ON log (date);\n" + - "CREATE INDEX idx_log_ip ON log (ip);\n" + - "CREATE INDEX idx_log_referer ON log (referer);"; + public static readonly string Logs = V3.Logs + + "\n" + + "CREATE INDEX idx_log_browser ON log (browser);\n" + + "CREATE INDEX idx_log_date ON log (date);\n" + + "CREATE INDEX idx_log_ip ON log (ip);\n" + + "CREATE INDEX idx_log_referer ON log (referer);"; - public static readonly string MoneyDonations = V3.MoneyDonations + "\n" + - "CREATE INDEX idx_money_donations_donator ON money_donations (donator);\n" + - "CREATE INDEX idx_money_donations_quantity ON money_donations (quantity);"; + public static readonly string MoneyDonations = V3.MoneyDonations + + "\n" + + "CREATE INDEX idx_money_donations_donator ON money_donations (donator);\n" + + "CREATE INDEX idx_money_donations_quantity ON money_donations (quantity);"; - public static readonly string MusicSynths = - V3.MusicSynths + "\n" + "CREATE INDEX idx_music_synts_name ON music_synths (name);"; + public static readonly string MusicSynths = + V3.MusicSynths + "\n" + "CREATE INDEX idx_music_synts_name ON music_synths (name);"; - public static readonly string News = V3.News + "\n" + "CREATE INDEX idx_news_date ON news (date);\n" + - "CREATE INDEX idx_news_type ON news (type);\n" + - "CREATE INDEX idx_news_ip ON news (added_id);"; + public static readonly string News = V3.News + + "\n" + + "CREATE INDEX idx_news_date ON news (date);\n" + + "CREATE INDEX idx_news_type ON news (type);\n" + + "CREATE INDEX idx_news_ip ON news (added_id);"; - public static readonly string OwnedComputers = V3.OwnedComputers + "\n" + - "CREATE INDEX idx_owned_computers_db_id ON owned_computers (db_id);\n" + - "CREATE INDEX idx_owned_computers_date ON owned_computers (date);\n" + - "CREATE INDEX idx_owned_computers_status ON owned_computers (status);\n" + - "CREATE INDEX idx_owned_computers_trade ON owned_computers (trade);\n" + - "CREATE INDEX idx_owned_computers_boxed ON owned_computers (boxed);\n" + - "CREATE INDEX idx_owned_computers_manuals ON owned_computers (manuals);\n" + - "CREATE INDEX idx_owned_computers_cpu1 ON owned_computers (cpu1);\n" + - "CREATE INDEX idx_owned_computers_cpu2 ON owned_computers (cpu2);\n" + - "CREATE INDEX idx_owned_computers_mhz1 ON owned_computers (mhz1);\n" + - "CREATE INDEX idx_owned_computers_mhz2 ON owned_computers (mhz2);\n" + - "CREATE INDEX idx_owned_computers_ram ON owned_computers (ram);\n" + - "CREATE INDEX idx_owned_computers_vram ON owned_computers (vram);\n" + - "CREATE INDEX idx_owned_computers_rigid ON owned_computers (rigid);\n" + - "CREATE INDEX idx_owned_computers_disk1 ON owned_computers (disk1);\n" + - "CREATE INDEX idx_owned_computers_disk2 ON owned_computers (disk2);\n" + - "CREATE INDEX idx_owned_computers_cap1 ON owned_computers (cap1);\n" + - "CREATE INDEX idx_owned_computers_cap2 ON owned_computers (cap2);"; + public static readonly string OwnedComputers = V3.OwnedComputers + + "\n" + + "CREATE INDEX idx_owned_computers_db_id ON owned_computers (db_id);\n" + + "CREATE INDEX idx_owned_computers_date ON owned_computers (date);\n" + + "CREATE INDEX idx_owned_computers_status ON owned_computers (status);\n" + + "CREATE INDEX idx_owned_computers_trade ON owned_computers (trade);\n" + + "CREATE INDEX idx_owned_computers_boxed ON owned_computers (boxed);\n" + + "CREATE INDEX idx_owned_computers_manuals ON owned_computers (manuals);\n" + + "CREATE INDEX idx_owned_computers_cpu1 ON owned_computers (cpu1);\n" + + "CREATE INDEX idx_owned_computers_cpu2 ON owned_computers (cpu2);\n" + + "CREATE INDEX idx_owned_computers_mhz1 ON owned_computers (mhz1);\n" + + "CREATE INDEX idx_owned_computers_mhz2 ON owned_computers (mhz2);\n" + + "CREATE INDEX idx_owned_computers_ram ON owned_computers (ram);\n" + + "CREATE INDEX idx_owned_computers_vram ON owned_computers (vram);\n" + + "CREATE INDEX idx_owned_computers_rigid ON owned_computers (rigid);\n" + + "CREATE INDEX idx_owned_computers_disk1 ON owned_computers (disk1);\n" + + "CREATE INDEX idx_owned_computers_disk2 ON owned_computers (disk2);\n" + + "CREATE INDEX idx_owned_computers_cap1 ON owned_computers (cap1);\n" + + "CREATE INDEX idx_owned_computers_cap2 ON owned_computers (cap2);"; - public static readonly string OwnedConsoles = V3.OwnedConsoles + "\n" + - "CREATE INDEX idx_owned_consoles_db_id ON owned_consoles (db_id);\n" + - "CREATE INDEX idx_owned_consoles_date ON owned_consoles (date);\n" + - "CREATE INDEX idx_owned_consoles_status ON owned_consoles (status);\n" + - "CREATE INDEX idx_owned_consoles_trade ON owned_consoles (trade);\n" + - "CREATE INDEX idx_owned_consoles_boxed ON owned_consoles (boxed);\n" + - "CREATE INDEX idx_owned_consoles_manuals ON owned_consoles (manuals);"; + public static readonly string OwnedConsoles = V3.OwnedConsoles + + "\n" + + "CREATE INDEX idx_owned_consoles_db_id ON owned_consoles (db_id);\n" + + "CREATE INDEX idx_owned_consoles_date ON owned_consoles (date);\n" + + "CREATE INDEX idx_owned_consoles_status ON owned_consoles (status);\n" + + "CREATE INDEX idx_owned_consoles_trade ON owned_consoles (trade);\n" + + "CREATE INDEX idx_owned_consoles_boxed ON owned_consoles (boxed);\n" + + "CREATE INDEX idx_owned_consoles_manuals ON owned_consoles (manuals);"; - public static readonly string Processors = @"CREATE TABLE IF NOT EXISTS `processors` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` char(50) NOT NULL DEFAULT '', - PRIMARY KEY `id` (`id`) - );" + "\n" + - "CREATE INDEX idx_processors_name ON processors (name);"; + public static readonly string Processors = """ + CREATE TABLE IF NOT EXISTS `processors` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` char(50) NOT NULL DEFAULT '', + PRIMARY KEY `id` (`id`) + ); + """ + + "\n" + + "CREATE INDEX idx_processors_name ON processors (name);"; - public static readonly string SoundSynths = - V3.SoundSynths + "\n" + "CREATE INDEX idx_sound_synths_name ON sound_synths (name);"; - } + public static readonly string SoundSynths = + V3.SoundSynths + "\n" + "CREATE INDEX idx_sound_synths_name ON sound_synths (name);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V5.cs b/Marechai.Database/Schemas/Sql/V5.cs index c9fec46f..1627ad3d 100644 --- a/Marechai.Database/Schemas/Sql/V5.cs +++ b/Marechai.Database/Schemas/Sql/V5.cs @@ -23,70 +23,71 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V5 { - public static class V5 - { - public static readonly string Admins = V4.Admins; + public static readonly string Admins = V4.Admins; - public static readonly string BrowserTests = V4.BrowserTests; + public static readonly string BrowserTests = V4.BrowserTests; - public static readonly string MarechaiDb = @"CREATE TABLE `marechai_db` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `version` int(11) NOT NULL, - `updated` datetime DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) - ); - INSERT INTO marechai_db (version) VALUES ('5');"; + public static readonly string MarechaiDb = """ + CREATE TABLE `marechai_db` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `version` int(11) NOT NULL, + `updated` datetime DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) + ); + INSERT INTO marechai_db (version) VALUES ('5'); + """; - public static readonly string Companies = V4.Companies; + public static readonly string Companies = V4.Companies; - public static readonly string Computers = V4.Computers; + public static readonly string Computers = V4.Computers; - public static readonly string Consoles = V4.Consoles; + public static readonly string Consoles = V4.Consoles; - public static readonly string DiskFormats = V4.DiskFormats; + public static readonly string DiskFormats = V4.DiskFormats; - public static readonly string Forbidden = V4.Forbidden; + public static readonly string Forbidden = V4.Forbidden; - public static readonly string Gpus = V4.Gpus; + public static readonly string Gpus = V4.Gpus; - public static readonly string Logs = V4.Logs; + public static readonly string Logs = V4.Logs; - public static readonly string MoneyDonations = V4.MoneyDonations; + public static readonly string MoneyDonations = V4.MoneyDonations; - public static readonly string MusicSynths = V4.MusicSynths; + public static readonly string MusicSynths = V4.MusicSynths; - public static readonly string News = V4.News; + public static readonly string News = V4.News; - public static readonly string OwnedComputers = V4.OwnedComputers; + public static readonly string OwnedComputers = V4.OwnedComputers; - public static readonly string OwnedConsoles = V4.OwnedConsoles; + public static readonly string OwnedConsoles = V4.OwnedConsoles; - public static readonly string Processors = V4.Processors; + public static readonly string Processors = V4.Processors; - public static readonly string SoundSynths = V4.SoundSynths; + public static readonly string SoundSynths = V4.SoundSynths; - public static readonly string ComputersForeignKeys = - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_company (company) REFERENCES companies (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu1 (cpu1) REFERENCES processors (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu2 (cpu2) REFERENCES processors (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_gpu (gpu) REFERENCES gpus (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_music_synth (music_synth) REFERENCES music_synths (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd1 (hdd1) REFERENCES disk_formats (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd2 (hdd2) REFERENCES disk_formats (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd3 (hdd3) REFERENCES disk_formats (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk1 (disk1) REFERENCES disk_formats (id);\n" + - "ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk2 (disk2) REFERENCES disk_formats (id);"; + public static readonly string ComputersForeignKeys = + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_company (company) REFERENCES companies (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu1 (cpu1) REFERENCES processors (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_cpu2 (cpu2) REFERENCES processors (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_gpu (gpu) REFERENCES gpus (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_music_synth (music_synth) REFERENCES music_synths (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd1 (hdd1) REFERENCES disk_formats (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd2 (hdd2) REFERENCES disk_formats (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_hdd3 (hdd3) REFERENCES disk_formats (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk1 (disk1) REFERENCES disk_formats (id);\n" + + "ALTER TABLE computers ADD FOREIGN KEY fk_computers_disk2 (disk2) REFERENCES disk_formats (id);"; - public static readonly string ConsolesForeignKeys = - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_company (company) REFERENCES companies (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu1 (cpu1) REFERENCES processors (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu2 (cpu2) REFERENCES processors (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_gpu (gpu) REFERENCES gpus (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_music_synth (music_synth) REFERENCES music_synths (id);\n" + - "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_format (format) REFERENCES disk_formats (id);"; - } + public static readonly string ConsolesForeignKeys = + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_company (company) REFERENCES companies (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu1 (cpu1) REFERENCES processors (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_cpu2 (cpu2) REFERENCES processors (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_gpu (gpu) REFERENCES gpus (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_sound_synth (sound_synth) REFERENCES sound_synths (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_music_synth (music_synth) REFERENCES music_synths (id);\n" + + "ALTER TABLE consoles ADD FOREIGN KEY fk_consoles_format (format) REFERENCES disk_formats (id);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V6.cs b/Marechai.Database/Schemas/Sql/V6.cs index c81de8e5..7c0c7137 100644 --- a/Marechai.Database/Schemas/Sql/V6.cs +++ b/Marechai.Database/Schemas/Sql/V6.cs @@ -23,148 +23,150 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V6 { - public static class V6 - { - public static readonly string Admins = V5.Admins; + public static readonly string Admins = V5.Admins; - public static readonly string BrowserTests = V5.BrowserTests; + public static readonly string BrowserTests = V5.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('6');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('6');"; - public static readonly string Companies = "CREATE TABLE `companies` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`name` varchar(128) NOT NULL DEFAULT '',\n" + - "`founded` datetime DEFAULT NULL,\n" + - "`website` varchar(255) DEFAULT NULL,\n" + - "`twitter` varchar(45) DEFAULT NULL,\n" + - "`facebook` varchar(45) DEFAULT NULL,\n" + - "`sold` datetime DEFAULT NULL,\n" + - "`sold_to` int(11) DEFAULT NULL,\n" + - "`address` varchar(80) DEFAULT NULL,\n" + - "`city` varchar(80) DEFAULT NULL,\n" + - "`province` varchar(80) DEFAULT NULL,\n" + - "`postal_code` varchar(25) DEFAULT NULL,\n" + - "`country` smallint(3) UNSIGNED ZEROFILL DEFAULT NULL,\n" + - "PRIMARY KEY (`id`),\n" + "KEY `idx_companies_name` (`name`),\n" + - "KEY `idx_companies_founded` (`founded`),\n" + - "KEY `idx_companies_website` (`website`),\n" + - "KEY `idx_companies_twitter` (`twitter`),\n" + - "KEY `idx_companies_facebook` (`facebook`),\n" + - "KEY `idx_companies_sold` (`sold`),\n" + - "KEY `idx_companies_sold_to` (`sold_to`),\n" + - "KEY `idx_companies_address` (`address`),\n" + - "KEY `idx_companies_city` (`city`),\n" + - "KEY `idx_companies_province` (`province`),\n" + - "KEY `idx_companies_postal_code` (`postal_code`),\n" + - "KEY `idx_companies_country` (`country`));"; + public static readonly string Companies = "CREATE TABLE `companies` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`name` varchar(128) NOT NULL DEFAULT '',\n" + + "`founded` datetime DEFAULT NULL,\n" + + "`website` varchar(255) DEFAULT NULL,\n" + + "`twitter` varchar(45) DEFAULT NULL,\n" + + "`facebook` varchar(45) DEFAULT NULL,\n" + + "`sold` datetime DEFAULT NULL,\n" + + "`sold_to` int(11) DEFAULT NULL,\n" + + "`address` varchar(80) DEFAULT NULL,\n" + + "`city` varchar(80) DEFAULT NULL,\n" + + "`province` varchar(80) DEFAULT NULL,\n" + + "`postal_code` varchar(25) DEFAULT NULL,\n" + + "`country` smallint(3) UNSIGNED ZEROFILL DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_companies_name` (`name`),\n" + + "KEY `idx_companies_founded` (`founded`),\n" + + "KEY `idx_companies_website` (`website`),\n" + + "KEY `idx_companies_twitter` (`twitter`),\n" + + "KEY `idx_companies_facebook` (`facebook`),\n" + + "KEY `idx_companies_sold` (`sold`),\n" + + "KEY `idx_companies_sold_to` (`sold_to`),\n" + + "KEY `idx_companies_address` (`address`),\n" + + "KEY `idx_companies_city` (`city`),\n" + + "KEY `idx_companies_province` (`province`),\n" + + "KEY `idx_companies_postal_code` (`postal_code`),\n" + + "KEY `idx_companies_country` (`country`));"; - public static readonly string Computers = V5.Computers; + public static readonly string Computers = V5.Computers; - public static readonly string Consoles = V5.Consoles; + public static readonly string Consoles = V5.Consoles; - public static readonly string DiskFormats = V5.DiskFormats; + public static readonly string DiskFormats = V5.DiskFormats; - public static readonly string Forbidden = V5.Forbidden; + public static readonly string Forbidden = V5.Forbidden; - public static readonly string Gpus = V5.Gpus; + public static readonly string Gpus = V5.Gpus; - public static readonly string Logs = V5.Logs; + public static readonly string Logs = V5.Logs; - public static readonly string MoneyDonations = V5.MoneyDonations; + public static readonly string MoneyDonations = V5.MoneyDonations; - public static readonly string MusicSynths = V5.MusicSynths; + public static readonly string MusicSynths = V5.MusicSynths; - public static readonly string News = V5.News; + public static readonly string News = V5.News; - public static readonly string OwnedComputers = V5.OwnedComputers; + public static readonly string OwnedComputers = V5.OwnedComputers; - public static readonly string OwnedConsoles = V5.OwnedConsoles; + public static readonly string OwnedConsoles = V5.OwnedConsoles; - public static readonly string Processors = V5.Processors; + public static readonly string Processors = V5.Processors; - public static readonly string SoundSynths = V5.SoundSynths; + public static readonly string SoundSynths = V5.SoundSynths; - public static readonly string ComputersForeignKeys = V5.ComputersForeignKeys; + public static readonly string ComputersForeignKeys = V5.ComputersForeignKeys; - public static readonly string ConsolesForeignKeys = V5.ConsolesForeignKeys; + public static readonly string ConsolesForeignKeys = V5.ConsolesForeignKeys; - public static readonly string Iso3166Numeric = "CREATE TABLE `iso3166_1_numeric` (\n" + - "`id` SMALLINT(3) UNSIGNED ZEROFILL NOT NULL,\n" + - "`name` VARCHAR(64) NOT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "INDEX `idx_name` (`name` ASC));"; + public static readonly string Iso3166Numeric = "CREATE TABLE `iso3166_1_numeric` (\n" + + "`id` SMALLINT(3) UNSIGNED ZEROFILL NOT NULL,\n" + + "`name` VARCHAR(64) NOT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "INDEX `idx_name` (`name` ASC));"; - public static readonly string Iso3166NumericValues = - "INSERT INTO `iso3166_1_numeric` VALUES (004,'Afghanistan'),(248,'Åland Islands'),(008,'Albania')," + - "(012,'Algeria'),(016,'American Samoa'),(020,'Andorra'),(024,'Angola'),(660,'Anguilla'),(010,'Antarctica')," + - "(028,'Antigua and Barbuda'),(032,'Argentina'),(051,'Armenia'),(533,'Aruba'),(036,'Australia')," + - "(040,'Austria'),(031,'Azerbaijan'),(044,'Bahamas'),(048,'Bahrain'),(050,'Bangladesh'),(052,'Barbados')," + - "(112,'Belarus'),(056,'Belgium'),(084,'Belize'),(204,'Benin'),(060,'Bermuda'),(064,'Bhutan')," + - "(862,'Bolivarian Republic of Venezuela'),(535,'Bonaire, Sint Eustatius and Saba')," + - "(070,'Bosnia and Herzegovina'),(072,'Botswana'),(074,'Bouvet Island'),(076,'Brazil')," + - "(080,'British Antarctic Territory'),(086,'British Indian Ocean Territory'),(092,'British Virgin Islands')," + - "(096,'Brunei Darussalam'),(100,'Bulgaria'),(854,'Burkina Faso'),(108,'Burundi'),(132,'Cabo Verde')," + - "(116,'Cambodia'),(120,'Cameroon'),(124,'Canada'),(128,'Canton and Enderbury Islands')," + - "(136,'Cayman Islands'),(140,'Central African Republic'),(148,'Chad'),(830,'Channel Islands'),(152,'Chile')," + - "(156,'China'),(162,'Christmas Island'),(166,'Cocos (Keeling) Islands'),(170,'Colombia'),(174,'Comoros')," + - "(178,'Congo'),(184,'Cook Islands'),(188,'Costa Rica'),(384,'Côte d\\'Ivoire'),(191,'Croatia'),(192,'Cuba')," + - "(531,'Curaçao'),(196,'Cyprus'),(203,'Czechia'),(200,'Czechoslovakia')," + - "(408,'Democratic People\\'s Republic of Korea'),(180,'Democratic Republic of the Congo')," + - "(720,'Democratic Yemen'),(208,'Denmark'),(262,'Djibouti'),(212,'Dominica'),(214,'Dominican Republic')," + - "(216,'Dronning Maud Land'),(218,'Ecuador'),(818,'Egypt'),(222,'El Salvador'),(226,'Equatorial Guinea')," + - "(232,'Eritrea'),(233,'Estonia'),(230,'Ethiopia'),(231,'Ethiopia'),(238,'Falkland Islands (Malvinas)')," + - "(234,'Faroe Islands'),(280,'Federal Republic of Germany'),(583,'Federated States of Micronesia')," + - "(242,'Fiji'),(246,'Finland'),(250,'France'),(249,'France, Metropolitan'),(254,'French Guiana')," + - "(258,'French Polynesia'),(260,'French Southern Territories'),(266,'Gabon'),(270,'Gambia')," + - "(274,'Gaza Strip (Palestine)'),(268,'Georgia'),(278,'German Democratic Republic'),(276,'Germany')," + - "(288,'Ghana'),(292,'Gibraltar'),(300,'Greece'),(304,'Greenland'),(308,'Grenada'),(312,'Guadeloupe')," + - "(316,'Guam'),(320,'Guatemala'),(831,'Guernsey'),(324,'Guinea'),(624,'Guinea-Bissau'),(328,'Guyana')," + - "(332,'Haiti'),(334,'Heard Island and McDonald Islands'),(336,'Holy See'),(340,'Honduras')," + - "(344,'Hong Kong'),(348,'Hungary'),(352,'Iceland'),(356,'India'),(360,'Indonesia'),(368,'Iraq')," + - "(372,'Ireland'),(364,'Islamic Republic of Iran'),(833,'Isle of Man'),(376,'Israel'),(380,'Italy')," + - "(388,'Jamaica'),(392,'Japan'),(832,'Jersey'),(396,'Johnston Island'),(400,'Jordan'),(398,'Kazakhstan')," + - "(404,'Kenya'),(296,'Kiribati'),(414,'Kuwait'),(417,'Kyrgyzstan'),(418,'Lao People\\'s Democratic Republic')," + - "(428,'Latvia'),(422,'Lebanon'),(426,'Lesotho'),(430,'Liberia'),(434,'Libya'),(438,'Liechtenstein')," + - "(440,'Lithuania'),(442,'Luxembourg'),(446,'Macao'),(450,'Madagascar'),(454,'Malawi'),(458,'Malaysia')," + - "(462,'Maldives'),(466,'Mali'),(470,'Malta'),(584,'Marshall Islands'),(474,'Martinique'),(478,'Mauritania')," + - "(480,'Mauritius'),(175,'Mayotte'),(484,'Mexico'),(488,'Midway Islands'),(492,'Monaco'),(496,'Mongolia')," + - "(499,'Montenegro'),(500,'Montserrat'),(504,'Morocco'),(508,'Mozambique'),(104,'Myanmar'),(516,'Namibia')," + - "(520,'Nauru'),(524,'Nepal'),(528,'Netherlands'),(530,'Netherlands Antilles'),(532,'Netherlands Antilles')," + - "(536,'Neutral Zone'),(540,'New Caledonia'),(554,'New Zealand'),(558,'Nicaragua'),(562,'Niger')," + - "(566,'Nigeria'),(570,'Niue'),(574,'Norfolk Island'),(580,'Northern Mariana Islands'),(578,'Norway')," + - "(512,'Oman'),(586,'Pakistan'),(585,'Palau'),(590,'Panama'),(591,'Panama'),(594,'Panama Canal Zone')," + - "(598,'Papua New Guinea'),(600,'Paraguay'),(604,'Peru'),(608,'Philippines'),(612,'Pitcairn')," + - "(068,'Plurinational State of Bolivia'),(616,'Poland'),(620,'Portugal'),(630,'Puerto Rico'),(634,'Qatar')," + - "(410,'Republic of Korea'),(498,'Republic of Moldova'),(714,'Republic of Viet-Nam'),(638,'Réunion')," + - "(642,'Romania'),(643,'Russian Federation'),(646,'Rwanda'),(650,'Ryukyu Islands'),(652,'Saint Barthélemy')," + - "(654,'Saint Helena, Ascension and Tristan da Cunha'),(659,'Saint Kitts and Nevis')," + - "(658,'Saint Kitts-Nevis-Anguilla'),(662,'Saint Lucia'),(663,'Saint Martin')," + - "(666,'Saint Pierre and Miquelon'),(670,'Saint Vincent and the Grenadines'),(882,'Samoa')," + - "(674,'San Marino'),(678,'Sao Tome and Principe'),(682,'Saudi Arabia'),(686,'Senegal'),(688,'Serbia')," + - "(891,'Serbia and Montenegro'),(690,'Seychelles'),(694,'Sierra Leone'),(698,'Sikkim'),(702,'Singapore')," + - "(534,'Sint Marteen'),(703,'Slovakia'),(705,'Slovenia'),(890,'Socialist Federal Republic of Yugoslavia')," + - "(090,'Solomon Islands'),(706,'Somalia'),(710,'South Africa')," + - "(239,'South Georgia and the South Sandwich Islands'),(728,'South Sudan'),(724,'Spain'),(144,'Sri Lanka')," + - "(275,'State of Palestine'),(729,'Sudan'),(736,'Sudan'),(740,'Suriname'),(744,'Svalbard and Jan Mayen')," + - "(748,'Swaziland'),(752,'Sweden'),(756,'Switzerland'),(760,'Syrian Arab Republic')," + - "(158,'Taiwan, Province of China'),(762,'Tajikistan'),(764,'Thailand')," + - "(807,'The former Yugoslav Republic of Macedonia'),(626,'Timor-Leste'),(768,'Togo'),(772,'Tokelau')," + - "(776,'Tonga'),(780,'Trinidad and Tobago'),(582,'Trust Territory of the Pacific Islands'),(788,'Tunisia')," + - "(792,'Turkey'),(795,'Turkmenistan'),(796,'Turks and Caicos Islands'),(798,'Tuvalu')," + - "(849,'U.S. Miscellaneous Pacific Islands'),(800,'Uganda'),(804,'Ukraine'),(784,'United Arab Emirates')," + - "(826,'United Kingdom'),(834,'United Republic of Tanzania'),(581,'United States Minor Outlying Islands')," + - "(840,'United States of America'),(858,'Uruguay'),(810,'USSR'),(860,'Uzbekistan'),(548,'Vanuatu')," + - "(704,'Viet-Nam'),(850,'Virgin Islands, U.S.'),(872,'Wake Island'),(876,'Wallis and Futuna')," + - "(732,'Western Sahara'),(887,'Yemen'),(886,'Yemen Arab Republic'),(894,'Zambia'),(716,'Zimbabwe');"; + public static readonly string Iso3166NumericValues = + "INSERT INTO `iso3166_1_numeric` VALUES (004,'Afghanistan'),(248,'Åland Islands'),(008,'Albania')," + + "(012,'Algeria'),(016,'American Samoa'),(020,'Andorra'),(024,'Angola'),(660,'Anguilla'),(010,'Antarctica')," + + "(028,'Antigua and Barbuda'),(032,'Argentina'),(051,'Armenia'),(533,'Aruba'),(036,'Australia')," + + "(040,'Austria'),(031,'Azerbaijan'),(044,'Bahamas'),(048,'Bahrain'),(050,'Bangladesh'),(052,'Barbados')," + + "(112,'Belarus'),(056,'Belgium'),(084,'Belize'),(204,'Benin'),(060,'Bermuda'),(064,'Bhutan')," + + "(862,'Bolivarian Republic of Venezuela'),(535,'Bonaire, Sint Eustatius and Saba')," + + "(070,'Bosnia and Herzegovina'),(072,'Botswana'),(074,'Bouvet Island'),(076,'Brazil')," + + "(080,'British Antarctic Territory'),(086,'British Indian Ocean Territory'),(092,'British Virgin Islands')," + + "(096,'Brunei Darussalam'),(100,'Bulgaria'),(854,'Burkina Faso'),(108,'Burundi'),(132,'Cabo Verde')," + + "(116,'Cambodia'),(120,'Cameroon'),(124,'Canada'),(128,'Canton and Enderbury Islands')," + + "(136,'Cayman Islands'),(140,'Central African Republic'),(148,'Chad'),(830,'Channel Islands'),(152,'Chile')," + + "(156,'China'),(162,'Christmas Island'),(166,'Cocos (Keeling) Islands'),(170,'Colombia'),(174,'Comoros')," + + "(178,'Congo'),(184,'Cook Islands'),(188,'Costa Rica'),(384,'Côte d\\'Ivoire'),(191,'Croatia'),(192,'Cuba')," + + "(531,'Curaçao'),(196,'Cyprus'),(203,'Czechia'),(200,'Czechoslovakia')," + + "(408,'Democratic People\\'s Republic of Korea'),(180,'Democratic Republic of the Congo')," + + "(720,'Democratic Yemen'),(208,'Denmark'),(262,'Djibouti'),(212,'Dominica'),(214,'Dominican Republic')," + + "(216,'Dronning Maud Land'),(218,'Ecuador'),(818,'Egypt'),(222,'El Salvador'),(226,'Equatorial Guinea')," + + "(232,'Eritrea'),(233,'Estonia'),(230,'Ethiopia'),(231,'Ethiopia'),(238,'Falkland Islands (Malvinas)')," + + "(234,'Faroe Islands'),(280,'Federal Republic of Germany'),(583,'Federated States of Micronesia')," + + "(242,'Fiji'),(246,'Finland'),(250,'France'),(249,'France, Metropolitan'),(254,'French Guiana')," + + "(258,'French Polynesia'),(260,'French Southern Territories'),(266,'Gabon'),(270,'Gambia')," + + "(274,'Gaza Strip (Palestine)'),(268,'Georgia'),(278,'German Democratic Republic'),(276,'Germany')," + + "(288,'Ghana'),(292,'Gibraltar'),(300,'Greece'),(304,'Greenland'),(308,'Grenada'),(312,'Guadeloupe')," + + "(316,'Guam'),(320,'Guatemala'),(831,'Guernsey'),(324,'Guinea'),(624,'Guinea-Bissau'),(328,'Guyana')," + + "(332,'Haiti'),(334,'Heard Island and McDonald Islands'),(336,'Holy See'),(340,'Honduras')," + + "(344,'Hong Kong'),(348,'Hungary'),(352,'Iceland'),(356,'India'),(360,'Indonesia'),(368,'Iraq')," + + "(372,'Ireland'),(364,'Islamic Republic of Iran'),(833,'Isle of Man'),(376,'Israel'),(380,'Italy')," + + "(388,'Jamaica'),(392,'Japan'),(832,'Jersey'),(396,'Johnston Island'),(400,'Jordan'),(398,'Kazakhstan')," + + "(404,'Kenya'),(296,'Kiribati'),(414,'Kuwait'),(417,'Kyrgyzstan'),(418,'Lao People\\'s Democratic Republic')," + + "(428,'Latvia'),(422,'Lebanon'),(426,'Lesotho'),(430,'Liberia'),(434,'Libya'),(438,'Liechtenstein')," + + "(440,'Lithuania'),(442,'Luxembourg'),(446,'Macao'),(450,'Madagascar'),(454,'Malawi'),(458,'Malaysia')," + + "(462,'Maldives'),(466,'Mali'),(470,'Malta'),(584,'Marshall Islands'),(474,'Martinique'),(478,'Mauritania')," + + "(480,'Mauritius'),(175,'Mayotte'),(484,'Mexico'),(488,'Midway Islands'),(492,'Monaco'),(496,'Mongolia')," + + "(499,'Montenegro'),(500,'Montserrat'),(504,'Morocco'),(508,'Mozambique'),(104,'Myanmar'),(516,'Namibia')," + + "(520,'Nauru'),(524,'Nepal'),(528,'Netherlands'),(530,'Netherlands Antilles'),(532,'Netherlands Antilles')," + + "(536,'Neutral Zone'),(540,'New Caledonia'),(554,'New Zealand'),(558,'Nicaragua'),(562,'Niger')," + + "(566,'Nigeria'),(570,'Niue'),(574,'Norfolk Island'),(580,'Northern Mariana Islands'),(578,'Norway')," + + "(512,'Oman'),(586,'Pakistan'),(585,'Palau'),(590,'Panama'),(591,'Panama'),(594,'Panama Canal Zone')," + + "(598,'Papua New Guinea'),(600,'Paraguay'),(604,'Peru'),(608,'Philippines'),(612,'Pitcairn')," + + "(068,'Plurinational State of Bolivia'),(616,'Poland'),(620,'Portugal'),(630,'Puerto Rico'),(634,'Qatar')," + + "(410,'Republic of Korea'),(498,'Republic of Moldova'),(714,'Republic of Viet-Nam'),(638,'Réunion')," + + "(642,'Romania'),(643,'Russian Federation'),(646,'Rwanda'),(650,'Ryukyu Islands'),(652,'Saint Barthélemy')," + + "(654,'Saint Helena, Ascension and Tristan da Cunha'),(659,'Saint Kitts and Nevis')," + + "(658,'Saint Kitts-Nevis-Anguilla'),(662,'Saint Lucia'),(663,'Saint Martin')," + + "(666,'Saint Pierre and Miquelon'),(670,'Saint Vincent and the Grenadines'),(882,'Samoa')," + + "(674,'San Marino'),(678,'Sao Tome and Principe'),(682,'Saudi Arabia'),(686,'Senegal'),(688,'Serbia')," + + "(891,'Serbia and Montenegro'),(690,'Seychelles'),(694,'Sierra Leone'),(698,'Sikkim'),(702,'Singapore')," + + "(534,'Sint Marteen'),(703,'Slovakia'),(705,'Slovenia'),(890,'Socialist Federal Republic of Yugoslavia')," + + "(090,'Solomon Islands'),(706,'Somalia'),(710,'South Africa')," + + "(239,'South Georgia and the South Sandwich Islands'),(728,'South Sudan'),(724,'Spain'),(144,'Sri Lanka')," + + "(275,'State of Palestine'),(729,'Sudan'),(736,'Sudan'),(740,'Suriname'),(744,'Svalbard and Jan Mayen')," + + "(748,'Swaziland'),(752,'Sweden'),(756,'Switzerland'),(760,'Syrian Arab Republic')," + + "(158,'Taiwan, Province of China'),(762,'Tajikistan'),(764,'Thailand')," + + "(807,'The former Yugoslav Republic of Macedonia'),(626,'Timor-Leste'),(768,'Togo'),(772,'Tokelau')," + + "(776,'Tonga'),(780,'Trinidad and Tobago'),(582,'Trust Territory of the Pacific Islands'),(788,'Tunisia')," + + "(792,'Turkey'),(795,'Turkmenistan'),(796,'Turks and Caicos Islands'),(798,'Tuvalu')," + + "(849,'U.S. Miscellaneous Pacific Islands'),(800,'Uganda'),(804,'Ukraine'),(784,'United Arab Emirates')," + + "(826,'United Kingdom'),(834,'United Republic of Tanzania'),(581,'United States Minor Outlying Islands')," + + "(840,'United States of America'),(858,'Uruguay'),(810,'USSR'),(860,'Uzbekistan'),(548,'Vanuatu')," + + "(704,'Viet-Nam'),(850,'Virgin Islands, U.S.'),(872,'Wake Island'),(876,'Wallis and Futuna')," + + "(732,'Western Sahara'),(887,'Yemen'),(886,'Yemen Arab Republic'),(894,'Zambia'),(716,'Zimbabwe');"; - public static readonly string CompaniesForeignKeys = - "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_sold_to` (sold_to) REFERENCES `companies` (`id`);\n" + - "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_country` (country) REFERENCES `iso3166_1_numeric` (`id`);"; - } + public static readonly string CompaniesForeignKeys = + "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_sold_to` (sold_to) REFERENCES `companies` (`id`);\n" + + "ALTER TABLE `companies` ADD FOREIGN KEY `fk_companies_country` (country) REFERENCES `iso3166_1_numeric` (`id`);"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V7.cs b/Marechai.Database/Schemas/Sql/V7.cs index 23a18626..b1dbd072 100644 --- a/Marechai.Database/Schemas/Sql/V7.cs +++ b/Marechai.Database/Schemas/Sql/V7.cs @@ -23,84 +23,85 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V7 { - public static class V7 - { - public static readonly string Admins = V6.Admins; + public static readonly string Admins = V6.Admins; - public static readonly string BrowserTests = V6.BrowserTests; + public static readonly string BrowserTests = V6.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('7');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('7');"; - public static readonly string Companies = "CREATE TABLE `companies` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`name` varchar(128) NOT NULL DEFAULT '',\n" + - "`founded` datetime DEFAULT NULL,\n" + - "`website` varchar(255) DEFAULT NULL,\n" + - "`twitter` varchar(45) DEFAULT NULL,\n" + - "`facebook` varchar(45) DEFAULT NULL,\n" + - "`sold` datetime DEFAULT NULL,\n" + - "`sold_to` int(11) DEFAULT NULL,\n" + - "`address` varchar(80) DEFAULT NULL,\n" + - "`city` varchar(80) DEFAULT NULL,\n" + - "`province` varchar(80) DEFAULT NULL,\n" + - "`postal_code` varchar(25) DEFAULT NULL,\n" + - "`country` smallint(3) UNSIGNED ZEROFILL DEFAULT NULL,\n" + - "`status` int NOT NULL,\n" + "PRIMARY KEY (`id`),\n" + - "KEY `idx_companies_name` (`name`),\n" + - "KEY `idx_companies_founded` (`founded`),\n" + - "KEY `idx_companies_website` (`website`),\n" + - "KEY `idx_companies_twitter` (`twitter`),\n" + - "KEY `idx_companies_facebook` (`facebook`),\n" + - "KEY `idx_companies_sold` (`sold`),\n" + - "KEY `idx_companies_sold_to` (`sold_to`),\n" + - "KEY `idx_companies_address` (`address`),\n" + - "KEY `idx_companies_city` (`city`),\n" + - "KEY `idx_companies_province` (`province`),\n" + - "KEY `idx_companies_postal_code` (`postal_code`),\n" + - "KEY `idx_companies_status` (`status`),\n" + - "KEY `idx_companies_country` (`country`));"; + public static readonly string Companies = "CREATE TABLE `companies` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`name` varchar(128) NOT NULL DEFAULT '',\n" + + "`founded` datetime DEFAULT NULL,\n" + + "`website` varchar(255) DEFAULT NULL,\n" + + "`twitter` varchar(45) DEFAULT NULL,\n" + + "`facebook` varchar(45) DEFAULT NULL,\n" + + "`sold` datetime DEFAULT NULL,\n" + + "`sold_to` int(11) DEFAULT NULL,\n" + + "`address` varchar(80) DEFAULT NULL,\n" + + "`city` varchar(80) DEFAULT NULL,\n" + + "`province` varchar(80) DEFAULT NULL,\n" + + "`postal_code` varchar(25) DEFAULT NULL,\n" + + "`country` smallint(3) UNSIGNED ZEROFILL DEFAULT NULL,\n" + + "`status` int NOT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_companies_name` (`name`),\n" + + "KEY `idx_companies_founded` (`founded`),\n" + + "KEY `idx_companies_website` (`website`),\n" + + "KEY `idx_companies_twitter` (`twitter`),\n" + + "KEY `idx_companies_facebook` (`facebook`),\n" + + "KEY `idx_companies_sold` (`sold`),\n" + + "KEY `idx_companies_sold_to` (`sold_to`),\n" + + "KEY `idx_companies_address` (`address`),\n" + + "KEY `idx_companies_city` (`city`),\n" + + "KEY `idx_companies_province` (`province`),\n" + + "KEY `idx_companies_postal_code` (`postal_code`),\n" + + "KEY `idx_companies_status` (`status`),\n" + + "KEY `idx_companies_country` (`country`));"; - public static readonly string Computers = V6.Computers; + public static readonly string Computers = V6.Computers; - public static readonly string Consoles = V6.Consoles; + public static readonly string Consoles = V6.Consoles; - public static readonly string DiskFormats = V6.DiskFormats; + public static readonly string DiskFormats = V6.DiskFormats; - public static readonly string Forbidden = V6.Forbidden; + public static readonly string Forbidden = V6.Forbidden; - public static readonly string Gpus = V6.Gpus; + public static readonly string Gpus = V6.Gpus; - public static readonly string Logs = V6.Logs; + public static readonly string Logs = V6.Logs; - public static readonly string MoneyDonations = V6.MoneyDonations; + public static readonly string MoneyDonations = V6.MoneyDonations; - public static readonly string MusicSynths = V6.MusicSynths; + public static readonly string MusicSynths = V6.MusicSynths; - public static readonly string News = V6.News; + public static readonly string News = V6.News; - public static readonly string OwnedComputers = V6.OwnedComputers; + public static readonly string OwnedComputers = V6.OwnedComputers; - public static readonly string OwnedConsoles = V6.OwnedConsoles; + public static readonly string OwnedConsoles = V6.OwnedConsoles; - public static readonly string Processors = V6.Processors; + public static readonly string Processors = V6.Processors; - public static readonly string SoundSynths = V6.SoundSynths; + public static readonly string SoundSynths = V6.SoundSynths; - public static readonly string ComputersForeignKeys = V6.ComputersForeignKeys; + public static readonly string ComputersForeignKeys = V6.ComputersForeignKeys; - public static readonly string ConsolesForeignKeys = V6.ConsolesForeignKeys; + public static readonly string ConsolesForeignKeys = V6.ConsolesForeignKeys; - public static readonly string Iso3166Numeric = V6.Iso3166Numeric; + public static readonly string Iso3166Numeric = V6.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V6.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V6.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V6.CompaniesForeignKeys; - } + public static readonly string CompaniesForeignKeys = V6.CompaniesForeignKeys; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V8.cs b/Marechai.Database/Schemas/Sql/V8.cs index d2172770..d057ecdc 100644 --- a/Marechai.Database/Schemas/Sql/V8.cs +++ b/Marechai.Database/Schemas/Sql/V8.cs @@ -23,69 +23,70 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V8 { - public static class V8 - { - public static readonly string Admins = V7.Admins; + public static readonly string Admins = V7.Admins; - public static readonly string BrowserTests = V7.BrowserTests; + public static readonly string BrowserTests = V7.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('8');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('8');"; - public static readonly string Companies = V7.Companies; + public static readonly string Companies = V7.Companies; - public static readonly string Computers = V7.Computers; + public static readonly string Computers = V7.Computers; - public static readonly string Consoles = V7.Consoles; + public static readonly string Consoles = V7.Consoles; - public static readonly string DiskFormats = V7.DiskFormats; + public static readonly string DiskFormats = V7.DiskFormats; - public static readonly string Forbidden = V7.Forbidden; + public static readonly string Forbidden = V7.Forbidden; - public static readonly string Gpus = V7.Gpus; + public static readonly string Gpus = V7.Gpus; - public static readonly string Logs = V7.Logs; + public static readonly string Logs = V7.Logs; - public static readonly string MoneyDonations = V7.MoneyDonations; + public static readonly string MoneyDonations = V7.MoneyDonations; - public static readonly string MusicSynths = V7.MusicSynths; + public static readonly string MusicSynths = V7.MusicSynths; - public static readonly string News = V7.News; + public static readonly string News = V7.News; - public static readonly string OwnedComputers = V7.OwnedComputers; + public static readonly string OwnedComputers = V7.OwnedComputers; - public static readonly string OwnedConsoles = V7.OwnedConsoles; + public static readonly string OwnedConsoles = V7.OwnedConsoles; - public static readonly string Processors = V7.Processors; + public static readonly string Processors = V7.Processors; - public static readonly string SoundSynths = V7.SoundSynths; + public static readonly string SoundSynths = V7.SoundSynths; - public static readonly string ComputersForeignKeys = V7.ComputersForeignKeys; + public static readonly string ComputersForeignKeys = V7.ComputersForeignKeys; - public static readonly string ConsolesForeignKeys = V7.ConsolesForeignKeys; + public static readonly string ConsolesForeignKeys = V7.ConsolesForeignKeys; - public static readonly string Iso3166Numeric = V7.Iso3166Numeric; + public static readonly string Iso3166Numeric = V7.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V7.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V7.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V7.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V7.CompaniesForeignKeys; - public static readonly string CompanyLogos = "CREATE TABLE IF NOT EXISTS `company_logos` (\n" + - "`id` INT NOT NULL AUTO_INCREMENT,\n" + - "`company_id` INT(11) NOT NULL,\n" + - "`year` INT(4) DEFAULT NULL,\n" + - "`logo_guid` CHAR(36) NOT NULL,\n" + - "PRIMARY KEY (`id`, `company_id`, `logo_guid`),\n" + - "UNIQUE INDEX `idx_id` (`id` ASC),\n" + - "INDEX `idx_company_id` (`company_id` ASC),\n" + - "INDEX `idx_guid` (`logo_guid` ASC),\n" + - "CONSTRAINT `fk_company_logos_company1`\n" + - "FOREIGN KEY (`company_id`)\n" + "REFERENCES `companies` (`id`))"; - } + public static readonly string CompanyLogos = "CREATE TABLE IF NOT EXISTS `company_logos` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`company_id` INT(11) NOT NULL,\n" + + "`year` INT(4) DEFAULT NULL,\n" + + "`logo_guid` CHAR(36) NOT NULL,\n" + + "PRIMARY KEY (`id`, `company_id`, `logo_guid`),\n" + + "UNIQUE INDEX `idx_id` (`id` ASC),\n" + + "INDEX `idx_company_id` (`company_id` ASC),\n" + + "INDEX `idx_guid` (`logo_guid` ASC),\n" + + "CONSTRAINT `fk_company_logos_company1`\n" + + "FOREIGN KEY (`company_id`)\n" + + "REFERENCES `companies` (`id`))"; } \ No newline at end of file diff --git a/Marechai.Database/Schemas/Sql/V9.cs b/Marechai.Database/Schemas/Sql/V9.cs index 692af1ec..9790e2e2 100644 --- a/Marechai.Database/Schemas/Sql/V9.cs +++ b/Marechai.Database/Schemas/Sql/V9.cs @@ -23,68 +23,69 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ -namespace Marechai.Database.Schemas.Sql +namespace Marechai.Database.Schemas.Sql; + +public static class V9 { - public static class V9 - { - public static readonly string Admins = V8.Admins; + public static readonly string Admins = V8.Admins; - public static readonly string BrowserTests = V8.BrowserTests; + public static readonly string BrowserTests = V8.BrowserTests; - public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + - "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + - "`version` int(11) NOT NULL,\n" + - "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + - "PRIMARY KEY (`id`)\n" + ");\n" + - "INSERT INTO marechai_db (version) VALUES ('9');"; + public static readonly string MarechaiDb = "CREATE TABLE `marechai_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + + ");\n" + + "INSERT INTO marechai_db (version) VALUES ('9');"; - public static readonly string Companies = V8.Companies; + public static readonly string Companies = V8.Companies; - public static readonly string Computers = V8.Computers; + public static readonly string Computers = V8.Computers; - public static readonly string Consoles = V8.Consoles; + public static readonly string Consoles = V8.Consoles; - public static readonly string DiskFormats = V8.DiskFormats; + public static readonly string DiskFormats = V8.DiskFormats; - public static readonly string Forbidden = V8.Forbidden; + public static readonly string Forbidden = V8.Forbidden; - public static readonly string Gpus = V8.Gpus; + public static readonly string Gpus = V8.Gpus; - public static readonly string Logs = V8.Logs; + public static readonly string Logs = V8.Logs; - public static readonly string MoneyDonations = V8.MoneyDonations; + public static readonly string MoneyDonations = V8.MoneyDonations; - public static readonly string MusicSynths = V8.MusicSynths; + public static readonly string MusicSynths = V8.MusicSynths; - public static readonly string News = V8.News; + public static readonly string News = V8.News; - public static readonly string OwnedComputers = V8.OwnedComputers; + public static readonly string OwnedComputers = V8.OwnedComputers; - public static readonly string OwnedConsoles = V8.OwnedConsoles; + public static readonly string OwnedConsoles = V8.OwnedConsoles; - public static readonly string Processors = V8.Processors; + public static readonly string Processors = V8.Processors; - public static readonly string SoundSynths = V8.SoundSynths; + public static readonly string SoundSynths = V8.SoundSynths; - public static readonly string ComputersForeignKeys = V8.ComputersForeignKeys; + public static readonly string ComputersForeignKeys = V8.ComputersForeignKeys; - public static readonly string ConsolesForeignKeys = V8.ConsolesForeignKeys; + public static readonly string ConsolesForeignKeys = V8.ConsolesForeignKeys; - public static readonly string Iso3166Numeric = V8.Iso3166Numeric; + public static readonly string Iso3166Numeric = V8.Iso3166Numeric; - public static readonly string Iso3166NumericValues = V8.Iso3166NumericValues; + public static readonly string Iso3166NumericValues = V8.Iso3166NumericValues; - public static readonly string CompaniesForeignKeys = V8.CompaniesForeignKeys; + public static readonly string CompaniesForeignKeys = V8.CompaniesForeignKeys; - public static readonly string CompanyLogos = V8.CompanyLogos; + public static readonly string CompanyLogos = V8.CompanyLogos; - public static readonly string CompanyDescriptions = "CREATE TABLE `company_descriptions` (\n" + - "`id` INT NOT NULL AUTO_INCREMENT,\n" + - "`company_id` INT NOT NULL,\n" + "`text` text,\n" + - "PRIMARY KEY (`id`),\n" + - "INDEX `idx_company_id` (`company_id` ASC),\n" + - "FULLTEXT KEY `idx_text` (`text`),\n" + - "CONSTRAINT `fk_company_id` FOREIGN KEY (`id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n" + - ")"; - } + public static readonly string CompanyDescriptions = "CREATE TABLE `company_descriptions` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`company_id` INT NOT NULL,\n" + + "`text` text,\n" + + "PRIMARY KEY (`id`),\n" + + "INDEX `idx_company_id` (`company_id` ASC),\n" + + "FULLTEXT KEY `idx_text` (`text`),\n" + + "CONSTRAINT `fk_company_id` FOREIGN KEY (`id`) REFERENCES `companies` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n" + + ")"; } \ No newline at end of file diff --git a/Marechai.Database/Seeders/All.cs b/Marechai.Database/Seeders/All.cs index 1d276419..71424405 100644 --- a/Marechai.Database/Seeders/All.cs +++ b/Marechai.Database/Seeders/All.cs @@ -28,92 +28,91 @@ using Marechai.Database.Models; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Configuration; -namespace Marechai.Database.Seeders +namespace Marechai.Database.Seeders; + +public static class All { - public static class All + public static void Seed(MarechaiContext context, UserManager userManager, + RoleManager roleManager, IConfiguration configuration) { - public static void Seed(MarechaiContext context, UserManager userManager, - RoleManager roleManager, IConfiguration configuration) + DateTime start, end; + + start = DateTime.Now; + Console.WriteLine("\u001b[31;1mImporting ISO-639 codes...\u001b[0m"); + + try { - DateTime start, end; - - start = DateTime.Now; - Console.WriteLine("\u001b[31;1mImporting ISO-639 codes...\u001b[0m"); - - try - { - Iso639.Seed(context); - } - catch(Exception e) - { - Console.WriteLine("Exception {0} importing ISO-639 codes, saving changes and continuing...", e); - } - - context.SaveChanges(); - - end = DateTime.Now; - - Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", - (end - start).TotalSeconds); - - start = DateTime.Now; - Console.WriteLine("\u001b[31;1mImporting ISO-4217 codes...\u001b[0m"); - - try - { - Iso4217.Seed(context); - } - catch(Exception e) - { - Console.WriteLine("Exception {0} importing ISO-4217 codes, saving changes and continuing...", e); - } - - context.SaveChanges(); - - end = DateTime.Now; - - Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", - (end - start).TotalSeconds); - - start = DateTime.Now; - Console.WriteLine("\u001b[31;1mSeeding document roles...\u001b[0m"); - DocumentRoles.Seed(context); - end = DateTime.Now; - - Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", - (end - start).TotalSeconds); - - start = DateTime.Now; - Console.WriteLine("\u001b[31;1mSeeding licenses...\u001b[0m"); - License.Seed(context); - end = DateTime.Now; - - Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", - (end - start).TotalSeconds); - - start = DateTime.Now; - Console.WriteLine("\u001b[31;1mSeeding application roles...\u001b[0m"); - Roles.Seed(roleManager, configuration); - end = DateTime.Now; - - Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", - (end - start).TotalSeconds); - - start = DateTime.Now; - Console.WriteLine("\u001b[31;1mSeeding application users...\u001b[0m"); - Users.Seed(userManager, roleManager); - end = DateTime.Now; - - Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", - (end - start).TotalSeconds); - - start = DateTime.Now; - Console.WriteLine("\u001b[31;1mSaving changes...\u001b[0m"); - context.SaveChanges(); - end = DateTime.Now; - - Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", - (end - start).TotalSeconds); + Iso639.Seed(context); } + catch(Exception e) + { + Console.WriteLine("Exception {0} importing ISO-639 codes, saving changes and continuing...", e); + } + + context.SaveChanges(); + + end = DateTime.Now; + + Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", + (end - start).TotalSeconds); + + start = DateTime.Now; + Console.WriteLine("\u001b[31;1mImporting ISO-4217 codes...\u001b[0m"); + + try + { + Iso4217.Seed(context); + } + catch(Exception e) + { + Console.WriteLine("Exception {0} importing ISO-4217 codes, saving changes and continuing...", e); + } + + context.SaveChanges(); + + end = DateTime.Now; + + Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", + (end - start).TotalSeconds); + + start = DateTime.Now; + Console.WriteLine("\u001b[31;1mSeeding document roles...\u001b[0m"); + DocumentRoles.Seed(context); + end = DateTime.Now; + + Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", + (end - start).TotalSeconds); + + start = DateTime.Now; + Console.WriteLine("\u001b[31;1mSeeding licenses...\u001b[0m"); + License.Seed(context); + end = DateTime.Now; + + Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", + (end - start).TotalSeconds); + + start = DateTime.Now; + Console.WriteLine("\u001b[31;1mSeeding application roles...\u001b[0m"); + Roles.Seed(roleManager, configuration); + end = DateTime.Now; + + Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", + (end - start).TotalSeconds); + + start = DateTime.Now; + Console.WriteLine("\u001b[31;1mSeeding application users...\u001b[0m"); + Users.Seed(userManager, roleManager); + end = DateTime.Now; + + Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", + (end - start).TotalSeconds); + + start = DateTime.Now; + Console.WriteLine("\u001b[31;1mSaving changes...\u001b[0m"); + context.SaveChanges(); + end = DateTime.Now; + + Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", + (end - start).TotalSeconds); } } \ No newline at end of file diff --git a/Marechai.Database/Seeders/DocumentRoles.cs b/Marechai.Database/Seeders/DocumentRoles.cs index a8f35aa2..87ba60a1 100644 --- a/Marechai.Database/Seeders/DocumentRoles.cs +++ b/Marechai.Database/Seeders/DocumentRoles.cs @@ -30,1675 +30,1673 @@ using Marechai.Database.Models; // ReSharper disable StringLiteralTypo -namespace Marechai.Database.Seeders +namespace Marechai.Database.Seeders; + +public static class DocumentRoles { - public static class DocumentRoles + public static void Seed(MarechaiContext context) { - public static void Seed(MarechaiContext context) + var existingRoles = context.DocumentRoles.ToList(); + List newDocumentRoles = []; + var updatedDocumentRolesCount = 0; + + foreach(DocumentRole role in new[] + { + new DocumentRole + { + Id = "abr", + Name = "Abridger", + Enabled = true + }, + new DocumentRole + { + Id = "acp", + Name = "Art copyist", + Enabled = true + }, + new DocumentRole + { + Id = "act", + Name = "Actor", + Enabled = true + }, + new DocumentRole + { + Id = "adi", + Name = "Art director", + Enabled = true + }, + new DocumentRole + { + Id = "adp", + Name = "Adapter", + Enabled = true + }, + new DocumentRole + { + Id = "aft", + Name = "Author of afterword, colophon, etc.", + Enabled = true + }, + new DocumentRole + { + Id = "anl", + Name = "Analyst", + Enabled = true + }, + new DocumentRole + { + Id = "anm", + Name = "Animator", + Enabled = true + }, + new DocumentRole + { + Id = "ann", + Name = "Annotator", + Enabled = true + }, + new DocumentRole + { + Id = "ant", + Name = "Bibliographic antecedent", + Enabled = true + }, + new DocumentRole + { + Id = "ape", + Name = "Appellee", + Enabled = true + }, + new DocumentRole + { + Id = "apl", + Name = "Appellant", + Enabled = true + }, + new DocumentRole + { + Id = "app", + Name = "Applicant", + Enabled = true + }, + new DocumentRole + { + Id = "aqt", + Name = "Author in quotations or text abstracts", + Enabled = true + }, + new DocumentRole + { + Id = "arc", + Name = "Architect", + Enabled = true + }, + new DocumentRole + { + Id = "ard", + Name = "Artistic director", + Enabled = true + }, + new DocumentRole + { + Id = "arr", + Name = "Arranger", + Enabled = true + }, + new DocumentRole + { + Id = "art", + Name = "Artist", + Enabled = true + }, + new DocumentRole + { + Id = "asg", + Name = "Assignee", + Enabled = true + }, + new DocumentRole + { + Id = "asn", + Name = "Associated name", + Enabled = true + }, + new DocumentRole + { + Id = "ato", + Name = "Autographer", + Enabled = true + }, + new DocumentRole + { + Id = "att", + Name = "Attributed name", + Enabled = true + }, + new DocumentRole + { + Id = "auc", + Name = "Auctioneer", + Enabled = true + }, + new DocumentRole + { + Id = "aud", + Name = "Author of dialog", + Enabled = true + }, + new DocumentRole + { + Id = "aui", + Name = "Author of introduction, etc.", + Enabled = true + }, + new DocumentRole + { + Id = "aus", + Name = "Screenwriter", + Enabled = true + }, + new DocumentRole + { + Id = "aut", + Name = "Author", + Enabled = true + }, + new DocumentRole + { + Id = "bdd", + Name = "Binding designer", + Enabled = true + }, + new DocumentRole + { + Id = "bjd", + Name = "Bookjacket designer", + Enabled = true + }, + new DocumentRole + { + Id = "bkd", + Name = "Book designer", + Enabled = true + }, + new DocumentRole + { + Id = "bkp", + Name = "Book producer", + Enabled = true + }, + new DocumentRole + { + Id = "blw", + Name = "Blurb writer", + Enabled = true + }, + new DocumentRole + { + Id = "bnd", + Name = "Binder", + Enabled = true + }, + new DocumentRole + { + Id = "bpd", + Name = "Bookplate designer", + Enabled = true + }, + new DocumentRole + { + Id = "brd", + Name = "Broadcaster", + Enabled = true + }, + new DocumentRole + { + Id = "brl", + Name = "Braille embosser", + Enabled = true + }, + new DocumentRole + { + Id = "bsl", + Name = "Bookseller", + Enabled = true + }, + new DocumentRole + { + Id = "cas", + Name = "Caster", + Enabled = true + }, + new DocumentRole + { + Id = "ccp", + Name = "Conceptor", + Enabled = true + }, + new DocumentRole + { + Id = "chr", + Name = "Choreographer", + Enabled = true + }, + new DocumentRole + { + Id = "clb", + Name = "Collaborator", + Enabled = false + }, + new DocumentRole + { + Id = "cli", + Name = "Client", + Enabled = true + }, + new DocumentRole + { + Id = "cll", + Name = "Calligrapher", + Enabled = true + }, + new DocumentRole + { + Id = "clr", + Name = "Colorist", + Enabled = true + }, + new DocumentRole + { + Id = "clt", + Name = "Collotyper", + Enabled = true + }, + new DocumentRole + { + Id = "cmm", + Name = "Commentator", + Enabled = true + }, + new DocumentRole + { + Id = "cmp", + Name = "Composer", + Enabled = true + }, + new DocumentRole + { + Id = "cmt", + Name = "Compositor", + Enabled = true + }, + new DocumentRole + { + Id = "cnd", + Name = "Conductor", + Enabled = true + }, + new DocumentRole + { + Id = "cng", + Name = "Cinematographer", + Enabled = true + }, + new DocumentRole + { + Id = "cns", + Name = "Censor", + Enabled = true + }, + new DocumentRole + { + Id = "coe", + Name = "Contestant-appellee", + Enabled = true + }, + new DocumentRole + { + Id = "col", + Name = "Collector", + Enabled = true + }, + new DocumentRole + { + Id = "com", + Name = "Compiler", + Enabled = true + }, + new DocumentRole + { + Id = "con", + Name = "Conservator", + Enabled = true + }, + new DocumentRole + { + Id = "cor", + Name = "Collection registrar", + Enabled = true + }, + new DocumentRole + { + Id = "cos", + Name = "Contestant", + Enabled = true + }, + new DocumentRole + { + Id = "cot", + Name = "Contestant-appellant", + Enabled = true + }, + new DocumentRole + { + Id = "cou", + Name = "Court governed", + Enabled = true + }, + new DocumentRole + { + Id = "cov", + Name = "Cover designer", + Enabled = true + }, + new DocumentRole + { + Id = "cpc", + Name = "Copyright claimant", + Enabled = true + }, + new DocumentRole + { + Id = "cpe", + Name = "Complainant-appellee", + Enabled = true + }, + new DocumentRole + { + Id = "cph", + Name = "Copyright holder", + Enabled = true + }, + new DocumentRole + { + Id = "cpl", + Name = "Complainant", + Enabled = true + }, + new DocumentRole + { + Id = "cpt", + Name = "Complainant-appellant", + Enabled = true + }, + new DocumentRole + { + Id = "cre", + Name = "Creator", + Enabled = true + }, + new DocumentRole + { + Id = "crp", + Name = "Correspondent", + Enabled = true + }, + new DocumentRole + { + Id = "crr", + Name = "Corrector", + Enabled = true + }, + new DocumentRole + { + Id = "crt", + Name = "Court reporter", + Enabled = true + }, + new DocumentRole + { + Id = "csl", + Name = "Consultant", + Enabled = true + }, + new DocumentRole + { + Id = "csp", + Name = "Consultant to a project", + Enabled = true + }, + new DocumentRole + { + Id = "cst", + Name = "Costume designer", + Enabled = true + }, + new DocumentRole + { + Id = "ctb", + Name = "Contributor", + Enabled = true + }, + new DocumentRole + { + Id = "cte", + Name = "Contestee-appellee", + Enabled = true + }, + new DocumentRole + { + Id = "ctg", + Name = "Cartographer", + Enabled = true + }, + new DocumentRole + { + Id = "ctr", + Name = "Contractor", + Enabled = true + }, + new DocumentRole + { + Id = "cts", + Name = "Contestee", + Enabled = true + }, + new DocumentRole + { + Id = "ctt", + Name = "Contestee-appellant", + Enabled = true + }, + new DocumentRole + { + Id = "cur", + Name = "Curator", + Enabled = true + }, + new DocumentRole + { + Id = "cwt", + Name = "Commentator for written text", + Enabled = true + }, + new DocumentRole + { + Id = "dbp", + Name = "Distribution place", + Enabled = true + }, + new DocumentRole + { + Id = "dfd", + Name = "Defendant", + Enabled = true + }, + new DocumentRole + { + Id = "dfe", + Name = "Defendant-appellee", + Enabled = true + }, + new DocumentRole + { + Id = "dft", + Name = "Defendant-appellant", + Enabled = true + }, + new DocumentRole + { + Id = "dgg", + Name = "Degree granting institution", + Enabled = true + }, + new DocumentRole + { + Id = "dgs", + Name = "Degree supervisor", + Enabled = true + }, + new DocumentRole + { + Id = "dis", + Name = "Dissertant", + Enabled = true + }, + new DocumentRole + { + Id = "dln", + Name = "Delineator", + Enabled = true + }, + new DocumentRole + { + Id = "dnc", + Name = "Dancer", + Enabled = true + }, + new DocumentRole + { + Id = "dnr", + Name = "Donor", + Enabled = true + }, + new DocumentRole + { + Id = "dpc", + Name = "Depicted", + Enabled = true + }, + new DocumentRole + { + Id = "dpt", + Name = "Depositor", + Enabled = true + }, + new DocumentRole + { + Id = "drm", + Name = "Draftsman", + Enabled = true + }, + new DocumentRole + { + Id = "drt", + Name = "Director", + Enabled = true + }, + new DocumentRole + { + Id = "dsr", + Name = "Designer", + Enabled = true + }, + new DocumentRole + { + Id = "dst", + Name = "Distributor", + Enabled = true + }, + new DocumentRole + { + Id = "dtc", + Name = "Data contributor", + Enabled = true + }, + new DocumentRole + { + Id = "dte", + Name = "Dedicatee", + Enabled = true + }, + new DocumentRole + { + Id = "dtm", + Name = "Data manager", + Enabled = true + }, + new DocumentRole + { + Id = "dto", + Name = "Dedicator", + Enabled = true + }, + new DocumentRole + { + Id = "dub", + Name = "Dubious author", + Enabled = true + }, + new DocumentRole + { + Id = "edc", + Name = "Editor of compilation", + Enabled = true + }, + new DocumentRole + { + Id = "edm", + Name = "Editor of moving image work", + Enabled = true + }, + new DocumentRole + { + Id = "edt", + Name = "Editor", + Enabled = true + }, + new DocumentRole + { + Id = "egr", + Name = "Engraver", + Enabled = true + }, + new DocumentRole + { + Id = "elg", + Name = "Electrician", + Enabled = true + }, + new DocumentRole + { + Id = "elt", + Name = "Electrotyper", + Enabled = true + }, + new DocumentRole + { + Id = "eng", + Name = "Engineer", + Enabled = true + }, + new DocumentRole + { + Id = "enj", + Name = "Enacting jurisdiction", + Enabled = true + }, + new DocumentRole + { + Id = "etr", + Name = "Etcher", + Enabled = true + }, + new DocumentRole + { + Id = "evp", + Name = "Event place", + Enabled = true + }, + new DocumentRole + { + Id = "exp", + Name = "Expert", + Enabled = true + }, + new DocumentRole + { + Id = "fac", + Name = "Facsimilist", + Enabled = true + }, + new DocumentRole + { + Id = "fds", + Name = "Film distributor", + Enabled = true + }, + new DocumentRole + { + Id = "fld", + Name = "Field director", + Enabled = true + }, + new DocumentRole + { + Id = "flm", + Name = "Film editor", + Enabled = true + }, + new DocumentRole + { + Id = "fmd", + Name = "Film director", + Enabled = true + }, + new DocumentRole + { + Id = "fmk", + Name = "Filmmaker", + Enabled = true + }, + new DocumentRole + { + Id = "fmo", + Name = "Former owner", + Enabled = true + }, + new DocumentRole + { + Id = "fmp", + Name = "Film producer", + Enabled = true + }, + new DocumentRole + { + Id = "fnd", + Name = "Funder", + Enabled = true + }, + new DocumentRole + { + Id = "fpy", + Name = "First party", + Enabled = true + }, + new DocumentRole + { + Id = "frg", + Name = "Forger", + Enabled = true + }, + new DocumentRole + { + Id = "gis", + Name = "Geographic information specialist", + Enabled = true + }, + new DocumentRole + { + Id = "grt", + Name = "Graphic technician", + Enabled = false + }, + new DocumentRole + { + Id = "his", + Name = "Host institution", + Enabled = true + }, + new DocumentRole + { + Id = "hnr", + Name = "Honoree", + Enabled = true + }, + new DocumentRole + { + Id = "hst", + Name = "Host", + Enabled = true + }, + new DocumentRole + { + Id = "ill", + Name = "Illustrator", + Enabled = true + }, + new DocumentRole + { + Id = "ilu", + Name = "Illuminator", + Enabled = true + }, + new DocumentRole + { + Id = "ins", + Name = "Inscriber", + Enabled = true + }, + new DocumentRole + { + Id = "inv", + Name = "Inventor", + Enabled = true + }, + new DocumentRole + { + Id = "isb", + Name = "Issuing body", + Enabled = true + }, + new DocumentRole + { + Id = "itr", + Name = "Instrumentalist", + Enabled = true + }, + new DocumentRole + { + Id = "ive", + Name = "Interviewee", + Enabled = true + }, + new DocumentRole + { + Id = "ivr", + Name = "Interviewer", + Enabled = true + }, + new DocumentRole + { + Id = "jud", + Name = "Judge", + Enabled = true + }, + new DocumentRole + { + Id = "jug", + Name = "Jurisdiction governed", + Enabled = true + }, + new DocumentRole + { + Id = "lbr", + Name = "Laboratory", + Enabled = true + }, + new DocumentRole + { + Id = "lbt", + Name = "Librettist", + Enabled = true + }, + new DocumentRole + { + Id = "ldr", + Name = "Laboratory director", + Enabled = true + }, + new DocumentRole + { + Id = "led", + Name = "Lead", + Enabled = true + }, + new DocumentRole + { + Id = "lee", + Name = "Libelee-appellee", + Enabled = true + }, + new DocumentRole + { + Id = "lel", + Name = "Libelee", + Enabled = true + }, + new DocumentRole + { + Id = "len", + Name = "Lender", + Enabled = true + }, + new DocumentRole + { + Id = "let", + Name = "Libelee-appellant", + Enabled = true + }, + new DocumentRole + { + Id = "lgd", + Name = "Lighting designer", + Enabled = true + }, + new DocumentRole + { + Id = "lie", + Name = "Libelant-appellee", + Enabled = true + }, + new DocumentRole + { + Id = "lil", + Name = "Libelant", + Enabled = true + }, + new DocumentRole + { + Id = "lit", + Name = "Libelant-appellant", + Enabled = true + }, + new DocumentRole + { + Id = "lsa", + Name = "Landscape architect", + Enabled = true + }, + new DocumentRole + { + Id = "lse", + Name = "Licensee", + Enabled = true + }, + new DocumentRole + { + Id = "lso", + Name = "Licensor", + Enabled = true + }, + new DocumentRole + { + Id = "ltg", + Name = "Lithographer", + Enabled = true + }, + new DocumentRole + { + Id = "lyr", + Name = "Lyricist", + Enabled = true + }, + new DocumentRole + { + Id = "mcp", + Name = "Music copyist", + Enabled = true + }, + new DocumentRole + { + Id = "mdc", + Name = "Metadata contact", + Enabled = true + }, + new DocumentRole + { + Id = "med", + Name = "Medium", + Enabled = true + }, + new DocumentRole + { + Id = "mfp", + Name = "Manufacture place", + Enabled = true + }, + new DocumentRole + { + Id = "mfr", + Name = "Manufacturer", + Enabled = true + }, + new DocumentRole + { + Id = "mod", + Name = "Moderator", + Enabled = true + }, + new DocumentRole + { + Id = "mon", + Name = "Monitor", + Enabled = true + }, + new DocumentRole + { + Id = "mrb", + Name = "Marbler", + Enabled = true + }, + new DocumentRole + { + Id = "mrk", + Name = "Markup editor", + Enabled = true + }, + new DocumentRole + { + Id = "msd", + Name = "Musical director", + Enabled = true + }, + new DocumentRole + { + Id = "mte", + Name = "Metal-engraver", + Enabled = true + }, + new DocumentRole + { + Id = "mtk", + Name = "Minute taker", + Enabled = true + }, + new DocumentRole + { + Id = "mus", + Name = "Musician", + Enabled = true + }, + new DocumentRole + { + Id = "nrt", + Name = "Narrator", + Enabled = true + }, + new DocumentRole + { + Id = "opn", + Name = "Opponent", + Enabled = true + }, + new DocumentRole + { + Id = "org", + Name = "Originator", + Enabled = true + }, + new DocumentRole + { + Id = "orm", + Name = "Organizer", + Enabled = true + }, + new DocumentRole + { + Id = "osp", + Name = "Onscreen presenter", + Enabled = true + }, + new DocumentRole + { + Id = "oth", + Name = "Other", + Enabled = true + }, + new DocumentRole + { + Id = "own", + Name = "Owner", + Enabled = true + }, + new DocumentRole + { + Id = "pan", + Name = "Panelist", + Enabled = true + }, + new DocumentRole + { + Id = "pat", + Name = "Patron", + Enabled = true + }, + new DocumentRole + { + Id = "pbd", + Name = "Publishing director", + Enabled = true + }, + new DocumentRole + { + Id = "pbl", + Name = "Publisher", + Enabled = true + }, + new DocumentRole + { + Id = "pdr", + Name = "Project director", + Enabled = true + }, + new DocumentRole + { + Id = "pfr", + Name = "Proofreader", + Enabled = true + }, + new DocumentRole + { + Id = "pht", + Name = "Photographer", + Enabled = true + }, + new DocumentRole + { + Id = "plt", + Name = "Platemaker", + Enabled = true + }, + new DocumentRole + { + Id = "pma", + Name = "Permitting agency", + Enabled = true + }, + new DocumentRole + { + Id = "pmn", + Name = "Production manager", + Enabled = true + }, + new DocumentRole + { + Id = "pop", + Name = "Printer of plates", + Enabled = true + }, + new DocumentRole + { + Id = "ppm", + Name = "Papermaker", + Enabled = true + }, + new DocumentRole + { + Id = "ppt", + Name = "Puppeteer", + Enabled = true + }, + new DocumentRole + { + Id = "pra", + Name = "Praeses", + Enabled = true + }, + new DocumentRole + { + Id = "prc", + Name = "Process contact", + Enabled = true + }, + new DocumentRole + { + Id = "prd", + Name = "Production personnel", + Enabled = true + }, + new DocumentRole + { + Id = "pre", + Name = "Presenter", + Enabled = true + }, + new DocumentRole + { + Id = "prf", + Name = "Performer", + Enabled = true + }, + new DocumentRole + { + Id = "prg", + Name = "Programmer", + Enabled = true + }, + new DocumentRole + { + Id = "prm", + Name = "Printmaker", + Enabled = true + }, + new DocumentRole + { + Id = "prn", + Name = "Production company", + Enabled = true + }, + new DocumentRole + { + Id = "pro", + Name = "Producer", + Enabled = true + }, + new DocumentRole + { + Id = "prp", + Name = "Production place", + Enabled = true + }, + new DocumentRole + { + Id = "prs", + Name = "Production designer", + Enabled = true + }, + new DocumentRole + { + Id = "prt", + Name = "Printer", + Enabled = true + }, + new DocumentRole + { + Id = "prv", + Name = "Provider", + Enabled = true + }, + new DocumentRole + { + Id = "pta", + Name = "Patent applicant", + Enabled = true + }, + new DocumentRole + { + Id = "pte", + Name = "Plaintiff-appellee", + Enabled = true + }, + new DocumentRole + { + Id = "ptf", + Name = "Plaintiff", + Enabled = true + }, + new DocumentRole + { + Id = "pth", + Name = "Patent holder", + Enabled = true + }, + new DocumentRole + { + Id = "ptt", + Name = "Plaintiff-appellant", + Enabled = true + }, + new DocumentRole + { + Id = "pup", + Name = "Publication place", + Enabled = true + }, + new DocumentRole + { + Id = "rbr", + Name = "Rubricator", + Enabled = true + }, + new DocumentRole + { + Id = "rcd", + Name = "Recordist", + Enabled = true + }, + new DocumentRole + { + Id = "rce", + Name = "Recording engineer", + Enabled = true + }, + new DocumentRole + { + Id = "rcp", + Name = "Addressee", + Enabled = true + }, + new DocumentRole + { + Id = "rdd", + Name = "Radio director", + Enabled = true + }, + new DocumentRole + { + Id = "red", + Name = "Redaktor", + Enabled = true + }, + new DocumentRole + { + Id = "ren", + Name = "Renderer", + Enabled = true + }, + new DocumentRole + { + Id = "res", + Name = "Researcher", + Enabled = true + }, + new DocumentRole + { + Id = "rev", + Name = "Reviewer", + Enabled = true + }, + new DocumentRole + { + Id = "rpc", + Name = "Radio producer", + Enabled = true + }, + new DocumentRole + { + Id = "rps", + Name = "Repository", + Enabled = true + }, + new DocumentRole + { + Id = "rpt", + Name = "Reporter", + Enabled = true + }, + new DocumentRole + { + Id = "rpy", + Name = "Responsible party", + Enabled = true + }, + new DocumentRole + { + Id = "rse", + Name = "Respondent-appellee", + Enabled = true + }, + new DocumentRole + { + Id = "rsg", + Name = "Restager", + Enabled = true + }, + new DocumentRole + { + Id = "rsp", + Name = "Respondent", + Enabled = true + }, + new DocumentRole + { + Id = "rsr", + Name = "Restorationist", + Enabled = true + }, + new DocumentRole + { + Id = "rst", + Name = "Respondent-appellant", + Enabled = true + }, + new DocumentRole + { + Id = "rth", + Name = "Research team head", + Enabled = true + }, + new DocumentRole + { + Id = "rtm", + Name = "Research team member", + Enabled = true + }, + new DocumentRole + { + Id = "sad", + Name = "Scientific advisor", + Enabled = true + }, + new DocumentRole + { + Id = "sce", + Name = "Scenarist", + Enabled = true + }, + new DocumentRole + { + Id = "scl", + Name = "Sculptor", + Enabled = true + }, + new DocumentRole + { + Id = "scr", + Name = "Scribe", + Enabled = true + }, + new DocumentRole + { + Id = "sds", + Name = "Sound designer", + Enabled = true + }, + new DocumentRole + { + Id = "sec", + Name = "Secretary", + Enabled = true + }, + new DocumentRole + { + Id = "sgd", + Name = "Stage director", + Enabled = true + }, + new DocumentRole + { + Id = "sgn", + Name = "Signer", + Enabled = true + }, + new DocumentRole + { + Id = "sht", + Name = "Supporting host", + Enabled = true + }, + new DocumentRole + { + Id = "sll", + Name = "Seller", + Enabled = true + }, + new DocumentRole + { + Id = "sng", + Name = "Singer", + Enabled = true + }, + new DocumentRole + { + Id = "spk", + Name = "Speaker", + Enabled = true + }, + new DocumentRole + { + Id = "spn", + Name = "Sponsor", + Enabled = true + }, + new DocumentRole + { + Id = "spy", + Name = "Second party", + Enabled = true + }, + new DocumentRole + { + Id = "srv", + Name = "Surveyor", + Enabled = true + }, + new DocumentRole + { + Id = "std", + Name = "Set designer", + Enabled = true + }, + new DocumentRole + { + Id = "stg", + Name = "Setting", + Enabled = true + }, + new DocumentRole + { + Id = "stl", + Name = "Storyteller", + Enabled = true + }, + new DocumentRole + { + Id = "stm", + Name = "Stage manager", + Enabled = true + }, + new DocumentRole + { + Id = "stn", + Name = "Standards body", + Enabled = true + }, + new DocumentRole + { + Id = "str", + Name = "Stereotyper", + Enabled = true + }, + new DocumentRole + { + Id = "tcd", + Name = "Technical director", + Enabled = true + }, + new DocumentRole + { + Id = "tch", + Name = "Teacher", + Enabled = true + }, + new DocumentRole + { + Id = "ths", + Name = "Thesis advisor", + Enabled = true + }, + new DocumentRole + { + Id = "tld", + Name = "Television director", + Enabled = true + }, + new DocumentRole + { + Id = "tlp", + Name = "Television producer", + Enabled = true + }, + new DocumentRole + { + Id = "trc", + Name = "Transcriber", + Enabled = true + }, + new DocumentRole + { + Id = "trl", + Name = "Translator", + Enabled = true + }, + new DocumentRole + { + Id = "tyd", + Name = "Type designer", + Enabled = true + }, + new DocumentRole + { + Id = "tyg", + Name = "Typographer", + Enabled = true + }, + new DocumentRole + { + Id = "uvp", + Name = "University place", + Enabled = true + }, + new DocumentRole + { + Id = "vac", + Name = "Voice actor", + Enabled = true + }, + new DocumentRole + { + Id = "vdg", + Name = "Videographer", + Enabled = true + }, + new DocumentRole + { + Id = "voc", + Name = "Vocalist", + Enabled = false + }, + new DocumentRole + { + Id = "wac", + Name = "Writer of added commentary", + Enabled = true + }, + new DocumentRole + { + Id = "wal", + Name = "Writer of added lyrics", + Enabled = true + }, + new DocumentRole + { + Id = "wam", + Name = "Writer of accompanying material", + Enabled = true + }, + new DocumentRole + { + Id = "wat", + Name = "Writer of added text", + Enabled = true + }, + new DocumentRole + { + Id = "wdc", + Name = "Woodcutter", + Enabled = true + }, + new DocumentRole + { + Id = "wde", + Name = "Wood engraver", + Enabled = true + }, + new DocumentRole + { + Id = "win", + Name = "Writer of introduction", + Enabled = true + }, + new DocumentRole + { + Id = "wit", + Name = "Witness", + Enabled = true + }, + new DocumentRole + { + Id = "wpr", + Name = "Writer of preface", + Enabled = true + }, + new DocumentRole + { + Id = "wst", + Name = "Writer of supplementary textual content", + Enabled = true + } + }) { - List existingRoles = context.DocumentRoles.ToList(); - List newDocumentRoles = new(); - int updatedDocumentRolesCount = 0; + DocumentRole existingRole = existingRoles.FirstOrDefault(r => r.Id == role.Id); - foreach(DocumentRole role in new[] + if(existingRole is null) + newDocumentRoles.Add(role); + else { - new DocumentRole + var changed = false; + + if(role.Name != existingRole.Name) { - Id = "abr", - Name = "Abridger", - Enabled = true - }, - new DocumentRole - { - Id = "acp", - Name = "Art copyist", - Enabled = true - }, - new DocumentRole - { - Id = "act", - Name = "Actor", - Enabled = true - }, - new DocumentRole - { - Id = "adi", - Name = "Art director", - Enabled = true - }, - new DocumentRole - { - Id = "adp", - Name = "Adapter", - Enabled = true - }, - new DocumentRole - { - Id = "aft", - Name = "Author of afterword, colophon, etc.", - Enabled = true - }, - new DocumentRole - { - Id = "anl", - Name = "Analyst", - Enabled = true - }, - new DocumentRole - { - Id = "anm", - Name = "Animator", - Enabled = true - }, - new DocumentRole - { - Id = "ann", - Name = "Annotator", - Enabled = true - }, - new DocumentRole - { - Id = "ant", - Name = "Bibliographic antecedent", - Enabled = true - }, - new DocumentRole - { - Id = "ape", - Name = "Appellee", - Enabled = true - }, - new DocumentRole - { - Id = "apl", - Name = "Appellant", - Enabled = true - }, - new DocumentRole - { - Id = "app", - Name = "Applicant", - Enabled = true - }, - new DocumentRole - { - Id = "aqt", - Name = "Author in quotations or text abstracts", - Enabled = true - }, - new DocumentRole - { - Id = "arc", - Name = "Architect", - Enabled = true - }, - new DocumentRole - { - Id = "ard", - Name = "Artistic director", - Enabled = true - }, - new DocumentRole - { - Id = "arr", - Name = "Arranger", - Enabled = true - }, - new DocumentRole - { - Id = "art", - Name = "Artist", - Enabled = true - }, - new DocumentRole - { - Id = "asg", - Name = "Assignee", - Enabled = true - }, - new DocumentRole - { - Id = "asn", - Name = "Associated name", - Enabled = true - }, - new DocumentRole - { - Id = "ato", - Name = "Autographer", - Enabled = true - }, - new DocumentRole - { - Id = "att", - Name = "Attributed name", - Enabled = true - }, - new DocumentRole - { - Id = "auc", - Name = "Auctioneer", - Enabled = true - }, - new DocumentRole - { - Id = "aud", - Name = "Author of dialog", - Enabled = true - }, - new DocumentRole - { - Id = "aui", - Name = "Author of introduction, etc.", - Enabled = true - }, - new DocumentRole - { - Id = "aus", - Name = "Screenwriter", - Enabled = true - }, - new DocumentRole - { - Id = "aut", - Name = "Author", - Enabled = true - }, - new DocumentRole - { - Id = "bdd", - Name = "Binding designer", - Enabled = true - }, - new DocumentRole - { - Id = "bjd", - Name = "Bookjacket designer", - Enabled = true - }, - new DocumentRole - { - Id = "bkd", - Name = "Book designer", - Enabled = true - }, - new DocumentRole - { - Id = "bkp", - Name = "Book producer", - Enabled = true - }, - new DocumentRole - { - Id = "blw", - Name = "Blurb writer", - Enabled = true - }, - new DocumentRole - { - Id = "bnd", - Name = "Binder", - Enabled = true - }, - new DocumentRole - { - Id = "bpd", - Name = "Bookplate designer", - Enabled = true - }, - new DocumentRole - { - Id = "brd", - Name = "Broadcaster", - Enabled = true - }, - new DocumentRole - { - Id = "brl", - Name = "Braille embosser", - Enabled = true - }, - new DocumentRole - { - Id = "bsl", - Name = "Bookseller", - Enabled = true - }, - new DocumentRole - { - Id = "cas", - Name = "Caster", - Enabled = true - }, - new DocumentRole - { - Id = "ccp", - Name = "Conceptor", - Enabled = true - }, - new DocumentRole - { - Id = "chr", - Name = "Choreographer", - Enabled = true - }, - new DocumentRole - { - Id = "clb", - Name = "Collaborator", - Enabled = false - }, - new DocumentRole - { - Id = "cli", - Name = "Client", - Enabled = true - }, - new DocumentRole - { - Id = "cll", - Name = "Calligrapher", - Enabled = true - }, - new DocumentRole - { - Id = "clr", - Name = "Colorist", - Enabled = true - }, - new DocumentRole - { - Id = "clt", - Name = "Collotyper", - Enabled = true - }, - new DocumentRole - { - Id = "cmm", - Name = "Commentator", - Enabled = true - }, - new DocumentRole - { - Id = "cmp", - Name = "Composer", - Enabled = true - }, - new DocumentRole - { - Id = "cmt", - Name = "Compositor", - Enabled = true - }, - new DocumentRole - { - Id = "cnd", - Name = "Conductor", - Enabled = true - }, - new DocumentRole - { - Id = "cng", - Name = "Cinematographer", - Enabled = true - }, - new DocumentRole - { - Id = "cns", - Name = "Censor", - Enabled = true - }, - new DocumentRole - { - Id = "coe", - Name = "Contestant-appellee", - Enabled = true - }, - new DocumentRole - { - Id = "col", - Name = "Collector", - Enabled = true - }, - new DocumentRole - { - Id = "com", - Name = "Compiler", - Enabled = true - }, - new DocumentRole - { - Id = "con", - Name = "Conservator", - Enabled = true - }, - new DocumentRole - { - Id = "cor", - Name = "Collection registrar", - Enabled = true - }, - new DocumentRole - { - Id = "cos", - Name = "Contestant", - Enabled = true - }, - new DocumentRole - { - Id = "cot", - Name = "Contestant-appellant", - Enabled = true - }, - new DocumentRole - { - Id = "cou", - Name = "Court governed", - Enabled = true - }, - new DocumentRole - { - Id = "cov", - Name = "Cover designer", - Enabled = true - }, - new DocumentRole - { - Id = "cpc", - Name = "Copyright claimant", - Enabled = true - }, - new DocumentRole - { - Id = "cpe", - Name = "Complainant-appellee", - Enabled = true - }, - new DocumentRole - { - Id = "cph", - Name = "Copyright holder", - Enabled = true - }, - new DocumentRole - { - Id = "cpl", - Name = "Complainant", - Enabled = true - }, - new DocumentRole - { - Id = "cpt", - Name = "Complainant-appellant", - Enabled = true - }, - new DocumentRole - { - Id = "cre", - Name = "Creator", - Enabled = true - }, - new DocumentRole - { - Id = "crp", - Name = "Correspondent", - Enabled = true - }, - new DocumentRole - { - Id = "crr", - Name = "Corrector", - Enabled = true - }, - new DocumentRole - { - Id = "crt", - Name = "Court reporter", - Enabled = true - }, - new DocumentRole - { - Id = "csl", - Name = "Consultant", - Enabled = true - }, - new DocumentRole - { - Id = "csp", - Name = "Consultant to a project", - Enabled = true - }, - new DocumentRole - { - Id = "cst", - Name = "Costume designer", - Enabled = true - }, - new DocumentRole - { - Id = "ctb", - Name = "Contributor", - Enabled = true - }, - new DocumentRole - { - Id = "cte", - Name = "Contestee-appellee", - Enabled = true - }, - new DocumentRole - { - Id = "ctg", - Name = "Cartographer", - Enabled = true - }, - new DocumentRole - { - Id = "ctr", - Name = "Contractor", - Enabled = true - }, - new DocumentRole - { - Id = "cts", - Name = "Contestee", - Enabled = true - }, - new DocumentRole - { - Id = "ctt", - Name = "Contestee-appellant", - Enabled = true - }, - new DocumentRole - { - Id = "cur", - Name = "Curator", - Enabled = true - }, - new DocumentRole - { - Id = "cwt", - Name = "Commentator for written text", - Enabled = true - }, - new DocumentRole - { - Id = "dbp", - Name = "Distribution place", - Enabled = true - }, - new DocumentRole - { - Id = "dfd", - Name = "Defendant", - Enabled = true - }, - new DocumentRole - { - Id = "dfe", - Name = "Defendant-appellee", - Enabled = true - }, - new DocumentRole - { - Id = "dft", - Name = "Defendant-appellant", - Enabled = true - }, - new DocumentRole - { - Id = "dgg", - Name = "Degree granting institution", - Enabled = true - }, - new DocumentRole - { - Id = "dgs", - Name = "Degree supervisor", - Enabled = true - }, - new DocumentRole - { - Id = "dis", - Name = "Dissertant", - Enabled = true - }, - new DocumentRole - { - Id = "dln", - Name = "Delineator", - Enabled = true - }, - new DocumentRole - { - Id = "dnc", - Name = "Dancer", - Enabled = true - }, - new DocumentRole - { - Id = "dnr", - Name = "Donor", - Enabled = true - }, - new DocumentRole - { - Id = "dpc", - Name = "Depicted", - Enabled = true - }, - new DocumentRole - { - Id = "dpt", - Name = "Depositor", - Enabled = true - }, - new DocumentRole - { - Id = "drm", - Name = "Draftsman", - Enabled = true - }, - new DocumentRole - { - Id = "drt", - Name = "Director", - Enabled = true - }, - new DocumentRole - { - Id = "dsr", - Name = "Designer", - Enabled = true - }, - new DocumentRole - { - Id = "dst", - Name = "Distributor", - Enabled = true - }, - new DocumentRole - { - Id = "dtc", - Name = "Data contributor", - Enabled = true - }, - new DocumentRole - { - Id = "dte", - Name = "Dedicatee", - Enabled = true - }, - new DocumentRole - { - Id = "dtm", - Name = "Data manager", - Enabled = true - }, - new DocumentRole - { - Id = "dto", - Name = "Dedicator", - Enabled = true - }, - new DocumentRole - { - Id = "dub", - Name = "Dubious author", - Enabled = true - }, - new DocumentRole - { - Id = "edc", - Name = "Editor of compilation", - Enabled = true - }, - new DocumentRole - { - Id = "edm", - Name = "Editor of moving image work", - Enabled = true - }, - new DocumentRole - { - Id = "edt", - Name = "Editor", - Enabled = true - }, - new DocumentRole - { - Id = "egr", - Name = "Engraver", - Enabled = true - }, - new DocumentRole - { - Id = "elg", - Name = "Electrician", - Enabled = true - }, - new DocumentRole - { - Id = "elt", - Name = "Electrotyper", - Enabled = true - }, - new DocumentRole - { - Id = "eng", - Name = "Engineer", - Enabled = true - }, - new DocumentRole - { - Id = "enj", - Name = "Enacting jurisdiction", - Enabled = true - }, - new DocumentRole - { - Id = "etr", - Name = "Etcher", - Enabled = true - }, - new DocumentRole - { - Id = "evp", - Name = "Event place", - Enabled = true - }, - new DocumentRole - { - Id = "exp", - Name = "Expert", - Enabled = true - }, - new DocumentRole - { - Id = "fac", - Name = "Facsimilist", - Enabled = true - }, - new DocumentRole - { - Id = "fds", - Name = "Film distributor", - Enabled = true - }, - new DocumentRole - { - Id = "fld", - Name = "Field director", - Enabled = true - }, - new DocumentRole - { - Id = "flm", - Name = "Film editor", - Enabled = true - }, - new DocumentRole - { - Id = "fmd", - Name = "Film director", - Enabled = true - }, - new DocumentRole - { - Id = "fmk", - Name = "Filmmaker", - Enabled = true - }, - new DocumentRole - { - Id = "fmo", - Name = "Former owner", - Enabled = true - }, - new DocumentRole - { - Id = "fmp", - Name = "Film producer", - Enabled = true - }, - new DocumentRole - { - Id = "fnd", - Name = "Funder", - Enabled = true - }, - new DocumentRole - { - Id = "fpy", - Name = "First party", - Enabled = true - }, - new DocumentRole - { - Id = "frg", - Name = "Forger", - Enabled = true - }, - new DocumentRole - { - Id = "gis", - Name = "Geographic information specialist", - Enabled = true - }, - new DocumentRole - { - Id = "grt", - Name = "Graphic technician", - Enabled = false - }, - new DocumentRole - { - Id = "his", - Name = "Host institution", - Enabled = true - }, - new DocumentRole - { - Id = "hnr", - Name = "Honoree", - Enabled = true - }, - new DocumentRole - { - Id = "hst", - Name = "Host", - Enabled = true - }, - new DocumentRole - { - Id = "ill", - Name = "Illustrator", - Enabled = true - }, - new DocumentRole - { - Id = "ilu", - Name = "Illuminator", - Enabled = true - }, - new DocumentRole - { - Id = "ins", - Name = "Inscriber", - Enabled = true - }, - new DocumentRole - { - Id = "inv", - Name = "Inventor", - Enabled = true - }, - new DocumentRole - { - Id = "isb", - Name = "Issuing body", - Enabled = true - }, - new DocumentRole - { - Id = "itr", - Name = "Instrumentalist", - Enabled = true - }, - new DocumentRole - { - Id = "ive", - Name = "Interviewee", - Enabled = true - }, - new DocumentRole - { - Id = "ivr", - Name = "Interviewer", - Enabled = true - }, - new DocumentRole - { - Id = "jud", - Name = "Judge", - Enabled = true - }, - new DocumentRole - { - Id = "jug", - Name = "Jurisdiction governed", - Enabled = true - }, - new DocumentRole - { - Id = "lbr", - Name = "Laboratory", - Enabled = true - }, - new DocumentRole - { - Id = "lbt", - Name = "Librettist", - Enabled = true - }, - new DocumentRole - { - Id = "ldr", - Name = "Laboratory director", - Enabled = true - }, - new DocumentRole - { - Id = "led", - Name = "Lead", - Enabled = true - }, - new DocumentRole - { - Id = "lee", - Name = "Libelee-appellee", - Enabled = true - }, - new DocumentRole - { - Id = "lel", - Name = "Libelee", - Enabled = true - }, - new DocumentRole - { - Id = "len", - Name = "Lender", - Enabled = true - }, - new DocumentRole - { - Id = "let", - Name = "Libelee-appellant", - Enabled = true - }, - new DocumentRole - { - Id = "lgd", - Name = "Lighting designer", - Enabled = true - }, - new DocumentRole - { - Id = "lie", - Name = "Libelant-appellee", - Enabled = true - }, - new DocumentRole - { - Id = "lil", - Name = "Libelant", - Enabled = true - }, - new DocumentRole - { - Id = "lit", - Name = "Libelant-appellant", - Enabled = true - }, - new DocumentRole - { - Id = "lsa", - Name = "Landscape architect", - Enabled = true - }, - new DocumentRole - { - Id = "lse", - Name = "Licensee", - Enabled = true - }, - new DocumentRole - { - Id = "lso", - Name = "Licensor", - Enabled = true - }, - new DocumentRole - { - Id = "ltg", - Name = "Lithographer", - Enabled = true - }, - new DocumentRole - { - Id = "lyr", - Name = "Lyricist", - Enabled = true - }, - new DocumentRole - { - Id = "mcp", - Name = "Music copyist", - Enabled = true - }, - new DocumentRole - { - Id = "mdc", - Name = "Metadata contact", - Enabled = true - }, - new DocumentRole - { - Id = "med", - Name = "Medium", - Enabled = true - }, - new DocumentRole - { - Id = "mfp", - Name = "Manufacture place", - Enabled = true - }, - new DocumentRole - { - Id = "mfr", - Name = "Manufacturer", - Enabled = true - }, - new DocumentRole - { - Id = "mod", - Name = "Moderator", - Enabled = true - }, - new DocumentRole - { - Id = "mon", - Name = "Monitor", - Enabled = true - }, - new DocumentRole - { - Id = "mrb", - Name = "Marbler", - Enabled = true - }, - new DocumentRole - { - Id = "mrk", - Name = "Markup editor", - Enabled = true - }, - new DocumentRole - { - Id = "msd", - Name = "Musical director", - Enabled = true - }, - new DocumentRole - { - Id = "mte", - Name = "Metal-engraver", - Enabled = true - }, - new DocumentRole - { - Id = "mtk", - Name = "Minute taker", - Enabled = true - }, - new DocumentRole - { - Id = "mus", - Name = "Musician", - Enabled = true - }, - new DocumentRole - { - Id = "nrt", - Name = "Narrator", - Enabled = true - }, - new DocumentRole - { - Id = "opn", - Name = "Opponent", - Enabled = true - }, - new DocumentRole - { - Id = "org", - Name = "Originator", - Enabled = true - }, - new DocumentRole - { - Id = "orm", - Name = "Organizer", - Enabled = true - }, - new DocumentRole - { - Id = "osp", - Name = "Onscreen presenter", - Enabled = true - }, - new DocumentRole - { - Id = "oth", - Name = "Other", - Enabled = true - }, - new DocumentRole - { - Id = "own", - Name = "Owner", - Enabled = true - }, - new DocumentRole - { - Id = "pan", - Name = "Panelist", - Enabled = true - }, - new DocumentRole - { - Id = "pat", - Name = "Patron", - Enabled = true - }, - new DocumentRole - { - Id = "pbd", - Name = "Publishing director", - Enabled = true - }, - new DocumentRole - { - Id = "pbl", - Name = "Publisher", - Enabled = true - }, - new DocumentRole - { - Id = "pdr", - Name = "Project director", - Enabled = true - }, - new DocumentRole - { - Id = "pfr", - Name = "Proofreader", - Enabled = true - }, - new DocumentRole - { - Id = "pht", - Name = "Photographer", - Enabled = true - }, - new DocumentRole - { - Id = "plt", - Name = "Platemaker", - Enabled = true - }, - new DocumentRole - { - Id = "pma", - Name = "Permitting agency", - Enabled = true - }, - new DocumentRole - { - Id = "pmn", - Name = "Production manager", - Enabled = true - }, - new DocumentRole - { - Id = "pop", - Name = "Printer of plates", - Enabled = true - }, - new DocumentRole - { - Id = "ppm", - Name = "Papermaker", - Enabled = true - }, - new DocumentRole - { - Id = "ppt", - Name = "Puppeteer", - Enabled = true - }, - new DocumentRole - { - Id = "pra", - Name = "Praeses", - Enabled = true - }, - new DocumentRole - { - Id = "prc", - Name = "Process contact", - Enabled = true - }, - new DocumentRole - { - Id = "prd", - Name = "Production personnel", - Enabled = true - }, - new DocumentRole - { - Id = "pre", - Name = "Presenter", - Enabled = true - }, - new DocumentRole - { - Id = "prf", - Name = "Performer", - Enabled = true - }, - new DocumentRole - { - Id = "prg", - Name = "Programmer", - Enabled = true - }, - new DocumentRole - { - Id = "prm", - Name = "Printmaker", - Enabled = true - }, - new DocumentRole - { - Id = "prn", - Name = "Production company", - Enabled = true - }, - new DocumentRole - { - Id = "pro", - Name = "Producer", - Enabled = true - }, - new DocumentRole - { - Id = "prp", - Name = "Production place", - Enabled = true - }, - new DocumentRole - { - Id = "prs", - Name = "Production designer", - Enabled = true - }, - new DocumentRole - { - Id = "prt", - Name = "Printer", - Enabled = true - }, - new DocumentRole - { - Id = "prv", - Name = "Provider", - Enabled = true - }, - new DocumentRole - { - Id = "pta", - Name = "Patent applicant", - Enabled = true - }, - new DocumentRole - { - Id = "pte", - Name = "Plaintiff-appellee", - Enabled = true - }, - new DocumentRole - { - Id = "ptf", - Name = "Plaintiff", - Enabled = true - }, - new DocumentRole - { - Id = "pth", - Name = "Patent holder", - Enabled = true - }, - new DocumentRole - { - Id = "ptt", - Name = "Plaintiff-appellant", - Enabled = true - }, - new DocumentRole - { - Id = "pup", - Name = "Publication place", - Enabled = true - }, - new DocumentRole - { - Id = "rbr", - Name = "Rubricator", - Enabled = true - }, - new DocumentRole - { - Id = "rcd", - Name = "Recordist", - Enabled = true - }, - new DocumentRole - { - Id = "rce", - Name = "Recording engineer", - Enabled = true - }, - new DocumentRole - { - Id = "rcp", - Name = "Addressee", - Enabled = true - }, - new DocumentRole - { - Id = "rdd", - Name = "Radio director", - Enabled = true - }, - new DocumentRole - { - Id = "red", - Name = "Redaktor", - Enabled = true - }, - new DocumentRole - { - Id = "ren", - Name = "Renderer", - Enabled = true - }, - new DocumentRole - { - Id = "res", - Name = "Researcher", - Enabled = true - }, - new DocumentRole - { - Id = "rev", - Name = "Reviewer", - Enabled = true - }, - new DocumentRole - { - Id = "rpc", - Name = "Radio producer", - Enabled = true - }, - new DocumentRole - { - Id = "rps", - Name = "Repository", - Enabled = true - }, - new DocumentRole - { - Id = "rpt", - Name = "Reporter", - Enabled = true - }, - new DocumentRole - { - Id = "rpy", - Name = "Responsible party", - Enabled = true - }, - new DocumentRole - { - Id = "rse", - Name = "Respondent-appellee", - Enabled = true - }, - new DocumentRole - { - Id = "rsg", - Name = "Restager", - Enabled = true - }, - new DocumentRole - { - Id = "rsp", - Name = "Respondent", - Enabled = true - }, - new DocumentRole - { - Id = "rsr", - Name = "Restorationist", - Enabled = true - }, - new DocumentRole - { - Id = "rst", - Name = "Respondent-appellant", - Enabled = true - }, - new DocumentRole - { - Id = "rth", - Name = "Research team head", - Enabled = true - }, - new DocumentRole - { - Id = "rtm", - Name = "Research team member", - Enabled = true - }, - new DocumentRole - { - Id = "sad", - Name = "Scientific advisor", - Enabled = true - }, - new DocumentRole - { - Id = "sce", - Name = "Scenarist", - Enabled = true - }, - new DocumentRole - { - Id = "scl", - Name = "Sculptor", - Enabled = true - }, - new DocumentRole - { - Id = "scr", - Name = "Scribe", - Enabled = true - }, - new DocumentRole - { - Id = "sds", - Name = "Sound designer", - Enabled = true - }, - new DocumentRole - { - Id = "sec", - Name = "Secretary", - Enabled = true - }, - new DocumentRole - { - Id = "sgd", - Name = "Stage director", - Enabled = true - }, - new DocumentRole - { - Id = "sgn", - Name = "Signer", - Enabled = true - }, - new DocumentRole - { - Id = "sht", - Name = "Supporting host", - Enabled = true - }, - new DocumentRole - { - Id = "sll", - Name = "Seller", - Enabled = true - }, - new DocumentRole - { - Id = "sng", - Name = "Singer", - Enabled = true - }, - new DocumentRole - { - Id = "spk", - Name = "Speaker", - Enabled = true - }, - new DocumentRole - { - Id = "spn", - Name = "Sponsor", - Enabled = true - }, - new DocumentRole - { - Id = "spy", - Name = "Second party", - Enabled = true - }, - new DocumentRole - { - Id = "srv", - Name = "Surveyor", - Enabled = true - }, - new DocumentRole - { - Id = "std", - Name = "Set designer", - Enabled = true - }, - new DocumentRole - { - Id = "stg", - Name = "Setting", - Enabled = true - }, - new DocumentRole - { - Id = "stl", - Name = "Storyteller", - Enabled = true - }, - new DocumentRole - { - Id = "stm", - Name = "Stage manager", - Enabled = true - }, - new DocumentRole - { - Id = "stn", - Name = "Standards body", - Enabled = true - }, - new DocumentRole - { - Id = "str", - Name = "Stereotyper", - Enabled = true - }, - new DocumentRole - { - Id = "tcd", - Name = "Technical director", - Enabled = true - }, - new DocumentRole - { - Id = "tch", - Name = "Teacher", - Enabled = true - }, - new DocumentRole - { - Id = "ths", - Name = "Thesis advisor", - Enabled = true - }, - new DocumentRole - { - Id = "tld", - Name = "Television director", - Enabled = true - }, - new DocumentRole - { - Id = "tlp", - Name = "Television producer", - Enabled = true - }, - new DocumentRole - { - Id = "trc", - Name = "Transcriber", - Enabled = true - }, - new DocumentRole - { - Id = "trl", - Name = "Translator", - Enabled = true - }, - new DocumentRole - { - Id = "tyd", - Name = "Type designer", - Enabled = true - }, - new DocumentRole - { - Id = "tyg", - Name = "Typographer", - Enabled = true - }, - new DocumentRole - { - Id = "uvp", - Name = "University place", - Enabled = true - }, - new DocumentRole - { - Id = "vac", - Name = "Voice actor", - Enabled = true - }, - new DocumentRole - { - Id = "vdg", - Name = "Videographer", - Enabled = true - }, - new DocumentRole - { - Id = "voc", - Name = "Vocalist", - Enabled = false - }, - new DocumentRole - { - Id = "wac", - Name = "Writer of added commentary", - Enabled = true - }, - new DocumentRole - { - Id = "wal", - Name = "Writer of added lyrics", - Enabled = true - }, - new DocumentRole - { - Id = "wam", - Name = "Writer of accompanying material", - Enabled = true - }, - new DocumentRole - { - Id = "wat", - Name = "Writer of added text", - Enabled = true - }, - new DocumentRole - { - Id = "wdc", - Name = "Woodcutter", - Enabled = true - }, - new DocumentRole - { - Id = "wde", - Name = "Wood engraver", - Enabled = true - }, - new DocumentRole - { - Id = "win", - Name = "Writer of introduction", - Enabled = true - }, - new DocumentRole - { - Id = "wit", - Name = "Witness", - Enabled = true - }, - new DocumentRole - { - Id = "wpr", - Name = "Writer of preface", - Enabled = true - }, - new DocumentRole - { - Id = "wst", - Name = "Writer of supplementary textual content", - Enabled = true + existingRole.Name = role.Name; + changed = true; } - }) - { - DocumentRole existingRole = existingRoles.FirstOrDefault(r => r.Id == role.Id); - if(existingRole is null) - newDocumentRoles.Add(role); - else + if(role.Enabled != existingRole.Enabled) { - bool changed = false; - - if(role.Name != existingRole.Name) - { - existingRole.Name = role.Name; - changed = true; - } - - if(role.Enabled != existingRole.Enabled) - { - existingRole.Enabled = role.Enabled; - changed = true; - } - - if(changed) - updatedDocumentRolesCount++; + existingRole.Enabled = role.Enabled; + changed = true; } + + if(changed) updatedDocumentRolesCount++; } - - context.DocumentRoles.AddRange(newDocumentRoles); - - Console.WriteLine("{0} document roles will be added.", newDocumentRoles.Count); - Console.WriteLine("{0} document roles will be updated.", updatedDocumentRolesCount); } + + context.DocumentRoles.AddRange(newDocumentRoles); + + Console.WriteLine("{0} document roles will be added.", newDocumentRoles.Count); + Console.WriteLine("{0} document roles will be updated.", updatedDocumentRolesCount); } } \ No newline at end of file diff --git a/Marechai.Database/Seeders/Iso4217.cs b/Marechai.Database/Seeders/Iso4217.cs index 14f6bebd..e42c60df 100644 --- a/Marechai.Database/Seeders/Iso4217.cs +++ b/Marechai.Database/Seeders/Iso4217.cs @@ -32,193 +32,186 @@ using System.Xml.Serialization; using Marechai.Database.Models; using Marechai.Database.Schemas; -namespace Marechai.Database.Seeders +namespace Marechai.Database.Seeders; + +public class Iso4217 { - public class Iso4217 + // Lists from https://www.currency-iso.org/en/home/tables/table-a1.html + public static void Seed(MarechaiContext context) { - // Lists from https://www.currency-iso.org/en/home/tables/table-a1.html - public static void Seed(MarechaiContext context) + if(!Directory.Exists("iso4217")) return; + + var codes = new Iso4217Xml.Root(); + + try { - if(!Directory.Exists("iso4217")) - return; - - var codes = new Iso4217Xml.Root(); - - try + if(File.Exists(Path.Combine("iso4217", "list_one.xml"))) { - if(File.Exists(Path.Combine("iso4217", "list_one.xml"))) - { - using var sr = new StreamReader(Path.Combine("iso4217", "list_one.xml")); - var xs = new XmlSerializer(typeof(Iso4217Xml.Root)); - var listOne = (Iso4217Xml.Root)xs.Deserialize(sr); + using var sr = new StreamReader(Path.Combine("iso4217", "list_one.xml")); + var xs = new XmlSerializer(typeof(Iso4217Xml.Root)); + var listOne = (Iso4217Xml.Root)xs.Deserialize(sr); - if(listOne.Published > codes.Published) - codes.Published = listOne.Published; + if(listOne.Published > codes.Published) codes.Published = listOne.Published; - codes.Current = listOne.Current; - } + codes.Current = listOne.Current; } - catch(Exception) - { - Console.WriteLine("Exception trying to read list one."); - } - - try - { - if(File.Exists(Path.Combine("iso4217", "list_three.xml"))) - { - using var sr = new StreamReader(Path.Combine("iso4217", "list_three.xml")); - var xs = new XmlSerializer(typeof(Iso4217Xml.Root)); - var listThree = (Iso4217Xml.Root)xs.Deserialize(sr); - - if(listThree.Published > codes.Published) - codes.Published = listThree.Published; - - codes.Historical = listThree.Historical; - } - } - catch(Exception) - { - Console.WriteLine("Exception trying to read list three."); - } - - if(codes.Current is null && - codes.Historical is null) - { - Console.WriteLine("No ISO-4217 codes could be read."); - - return; - } - - Dictionary existingCodes = context.Iso4217.ToDictionary(c => c.Code); - Dictionary newCodes = new(); - - long modified = 0; - - codes.Current ??= new Iso4217Xml.Currency[0]; - codes.Historical ??= new Iso4217Xml.Currency[0]; - - foreach(Iso4217Xml.Currency currency in codes.Historical) - { - bool changed = false; - byte minorUnits; - DateTime withdrawn; - - if(currency.Code is null) - continue; - - if(!existingCodes.TryGetValue(currency.Code, out Models.Iso4217 existing)) - { - var newCode = new Models.Iso4217 - { - Code = currency.Code, - Name = currency.Name, - Numeric = currency.Number - }; - - if(byte.TryParse(currency.MinorUnits, out minorUnits)) - newCode.MinorUnits = minorUnits; - - if(DateTime.TryParseExact(currency.Withdrawn, "yyyy'-'MM", CultureInfo.InvariantCulture, - DateTimeStyles.AssumeUniversal, out withdrawn)) - newCode.Withdrawn = withdrawn; - - newCodes[currency.Code] = newCode; - existingCodes[currency.Code] = newCode; - - continue; - } - - if(existing.Code != currency.Code) - { - existing.Code = currency.Code; - changed = true; - } - - if(existing.Name != currency.Name) - { - existing.Name = currency.Name; - changed = true; - } - - if(byte.TryParse(currency.MinorUnits, out minorUnits) && - existing.MinorUnits != minorUnits) - { - existing.MinorUnits = minorUnits; - changed = true; - } - - if(DateTime.TryParseExact(currency.Withdrawn, "yyyy'-'MM", CultureInfo.InvariantCulture, - DateTimeStyles.AssumeUniversal, out withdrawn) && - existing.Withdrawn != withdrawn) - { - existing.Withdrawn = withdrawn; - changed = true; - } - - if(changed) - modified++; - } - - foreach(Iso4217Xml.Currency currency in codes.Current) - { - bool changed = false; - byte minorUnits; - - if(currency.Code is null) - continue; - - if(!existingCodes.TryGetValue(currency.Code, out Models.Iso4217 existing)) - { - var newCode = new Models.Iso4217 - { - Code = currency.Code, - Name = currency.Name, - Numeric = currency.Number - }; - - if(byte.TryParse(currency.MinorUnits, out minorUnits)) - newCode.MinorUnits = minorUnits; - - newCodes[currency.Code] = newCode; - existingCodes[currency.Code] = newCode; - - continue; - } - - if(existing.Code != currency.Code) - { - existing.Code = currency.Code; - changed = true; - } - - if(existing.Name != currency.Name) - { - existing.Name = currency.Name; - changed = true; - } - - if(byte.TryParse(currency.MinorUnits, out minorUnits) && - existing.MinorUnits != minorUnits) - { - existing.MinorUnits = minorUnits; - changed = true; - } - - if(existing.Withdrawn != null) - { - existing.Withdrawn = null; - changed = true; - } - - if(changed) - modified++; - } - - context.Iso4217.AddRange(newCodes.Values); - - Console.WriteLine("{0} currency codes added", newCodes.Count); - Console.WriteLine("{0} currency codes modified", modified); } + catch(Exception) + { + Console.WriteLine("Exception trying to read list one."); + } + + try + { + if(File.Exists(Path.Combine("iso4217", "list_three.xml"))) + { + using var sr = new StreamReader(Path.Combine("iso4217", "list_three.xml")); + var xs = new XmlSerializer(typeof(Iso4217Xml.Root)); + var listThree = (Iso4217Xml.Root)xs.Deserialize(sr); + + if(listThree.Published > codes.Published) codes.Published = listThree.Published; + + codes.Historical = listThree.Historical; + } + } + catch(Exception) + { + Console.WriteLine("Exception trying to read list three."); + } + + if(codes.Current is null && codes.Historical is null) + { + Console.WriteLine("No ISO-4217 codes could be read."); + + return; + } + + var existingCodes = context.Iso4217.ToDictionary(c => c.Code); + Dictionary newCodes = new(); + + long modified = 0; + + codes.Current ??= []; + codes.Historical ??= []; + + foreach(Iso4217Xml.Currency currency in codes.Historical) + { + var changed = false; + byte minorUnits; + DateTime withdrawn; + + if(currency.Code is null) continue; + + if(!existingCodes.TryGetValue(currency.Code, out Models.Iso4217 existing)) + { + var newCode = new Models.Iso4217 + { + Code = currency.Code, + Name = currency.Name, + Numeric = currency.Number + }; + + if(byte.TryParse(currency.MinorUnits, out minorUnits)) newCode.MinorUnits = minorUnits; + + if(DateTime.TryParseExact(currency.Withdrawn, + "yyyy'-'MM", + CultureInfo.InvariantCulture, + DateTimeStyles.AssumeUniversal, + out withdrawn)) + newCode.Withdrawn = withdrawn; + + newCodes[currency.Code] = newCode; + existingCodes[currency.Code] = newCode; + + continue; + } + + if(existing.Code != currency.Code) + { + existing.Code = currency.Code; + changed = true; + } + + if(existing.Name != currency.Name) + { + existing.Name = currency.Name; + changed = true; + } + + if(byte.TryParse(currency.MinorUnits, out minorUnits) && existing.MinorUnits != minorUnits) + { + existing.MinorUnits = minorUnits; + changed = true; + } + + if(DateTime.TryParseExact(currency.Withdrawn, + "yyyy'-'MM", + CultureInfo.InvariantCulture, + DateTimeStyles.AssumeUniversal, + out withdrawn) && + existing.Withdrawn != withdrawn) + { + existing.Withdrawn = withdrawn; + changed = true; + } + + if(changed) modified++; + } + + foreach(Iso4217Xml.Currency currency in codes.Current) + { + var changed = false; + byte minorUnits; + + if(currency.Code is null) continue; + + if(!existingCodes.TryGetValue(currency.Code, out Models.Iso4217 existing)) + { + var newCode = new Models.Iso4217 + { + Code = currency.Code, + Name = currency.Name, + Numeric = currency.Number + }; + + if(byte.TryParse(currency.MinorUnits, out minorUnits)) newCode.MinorUnits = minorUnits; + + newCodes[currency.Code] = newCode; + existingCodes[currency.Code] = newCode; + + continue; + } + + if(existing.Code != currency.Code) + { + existing.Code = currency.Code; + changed = true; + } + + if(existing.Name != currency.Name) + { + existing.Name = currency.Name; + changed = true; + } + + if(byte.TryParse(currency.MinorUnits, out minorUnits) && existing.MinorUnits != minorUnits) + { + existing.MinorUnits = minorUnits; + changed = true; + } + + if(existing.Withdrawn != null) + { + existing.Withdrawn = null; + changed = true; + } + + if(changed) modified++; + } + + context.Iso4217.AddRange(newCodes.Values); + + Console.WriteLine("{0} currency codes added", newCodes.Count); + Console.WriteLine("{0} currency codes modified", modified); } } \ No newline at end of file diff --git a/Marechai.Database/Seeders/Iso639.cs b/Marechai.Database/Seeders/Iso639.cs index 5e8113d0..581ce833 100644 --- a/Marechai.Database/Seeders/Iso639.cs +++ b/Marechai.Database/Seeders/Iso639.cs @@ -30,160 +30,158 @@ using System.Linq; using System.Text; using Marechai.Database.Models; -namespace Marechai.Database.Seeders +namespace Marechai.Database.Seeders; + +public static class Iso639 { - public static class Iso639 + // Data files can be found in https://iso639-3.sil.org/code_tables/download_tables + public static void Seed(MarechaiContext context) { - // Data files can be found in https://iso639-3.sil.org/code_tables/download_tables - public static void Seed(MarechaiContext context) + if(!Directory.Exists("iso639")) return; + + IEnumerable files = Directory.EnumerateFiles("iso639", "iso-639-3_*.tab"); + long modified = 0; + + List codes = []; + + foreach(string file in files) { - if(!Directory.Exists("iso639")) - return; + Console.WriteLine("Importing ISO-639 codes from {0}", file); - IEnumerable files = Directory.EnumerateFiles("iso639", "iso-639-3_*.tab"); - long modified = 0; + using var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None); - List codes = new(); + using var sr = new StreamReader(fs, Encoding.UTF8); - foreach(string file in files) + string line = sr.ReadLine(); + + if(line is null) { - Console.WriteLine("Importing ISO-639 codes from {0}", file); + Console.WriteLine("Invalid data, not proceeding"); - using var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None); + continue; + } - using var sr = new StreamReader(fs, Encoding.UTF8); + string[] pieces = line.Split('\t'); - string line = sr.ReadLine(); + if(pieces.Length != 8 || + pieces[0] != "Id" || + pieces[1] != "Part2B" || + pieces[2] != "Part2T" || + pieces[3] != "Part1" || + pieces[4] != "Scope" || + pieces[5] != "Language_Type" || + pieces[6] != "Ref_Name" || + pieces[7] != "Comment") + { + Console.WriteLine("Invalid data, not proceeding"); - if(line is null) + continue; + } + + line = sr.ReadLine(); + + while(line != null) + { + pieces = line.Split('\t'); + + if(pieces.Length != 8) { - Console.WriteLine("Invalid data, not proceeding"); + Console.WriteLine("Invalid data, continuing with next line"); + line = sr.ReadLine(); continue; } - string[] pieces = line.Split('\t'); - - if(pieces.Length != 8 || - pieces[0] != "Id" || - pieces[1] != "Part2B" || - pieces[2] != "Part2T" || - pieces[3] != "Part1" || - pieces[4] != "Scope" || - pieces[5] != "Language_Type" || - pieces[6] != "Ref_Name" || - pieces[7] != "Comment") + for(var p = 1; p < 8; p++) { - Console.WriteLine("Invalid data, not proceeding"); - - continue; + if(pieces[p] == "") pieces[p] = null; } + codes.Add(new Models.Iso639 + { + Id = pieces[0], + Part2B = pieces[1], + Part2T = pieces[2], + Part1 = pieces[3], + Scope = pieces[4], + Type = pieces[5], + ReferenceName = pieces[6], + Comment = pieces[7] + }); + line = sr.ReadLine(); - - while(line != null) - { - pieces = line.Split('\t'); - - if(pieces.Length != 8) - { - Console.WriteLine("Invalid data, continuing with next line"); - line = sr.ReadLine(); - - continue; - } - - for(int p = 1; p < 8; p++) - if(pieces[p] == "") - pieces[p] = null; - - codes.Add(new Models.Iso639 - { - Id = pieces[0], - Part2B = pieces[1], - Part2T = pieces[2], - Part1 = pieces[3], - Scope = pieces[4], - Type = pieces[5], - ReferenceName = pieces[6], - Comment = pieces[7] - }); - - line = sr.ReadLine(); - } } - - if(codes.Count == 0) - { - Console.WriteLine("No codes found"); - - return; - } - - List existingCodes = context.Iso639.ToList(); - List newCodes = new(); - - foreach(Models.Iso639 code in codes) - { - Models.Iso639 existingCode = existingCodes.FirstOrDefault(c => c.Id == code.Id); - - if(existingCode is null) - newCodes.Add(code); - else - { - bool changed = false; - - if(code.Part2B != existingCode.Part2B) - { - existingCode.Part2B = code.Part2B; - changed = true; - } - - if(code.Part2T != existingCode.Part2T) - { - existingCode.Part2T = code.Part2T; - changed = true; - } - - if(code.Part1 != existingCode.Part1) - { - existingCode.Part1 = code.Part1; - changed = true; - } - - if(code.Scope != existingCode.Scope) - { - existingCode.Scope = code.Scope; - changed = true; - } - - if(code.Type != existingCode.Type) - { - existingCode.Type = code.Type; - changed = true; - } - - if(code.ReferenceName != existingCode.ReferenceName) - { - existingCode.ReferenceName = code.ReferenceName; - changed = true; - } - - if(code.Comment != existingCode.Comment) - { - existingCode.Comment = code.Comment; - changed = true; - } - - if(changed) - modified++; - } - } - - context.Iso639.AddRange(newCodes); - - Console.WriteLine("{0} language codes added", newCodes.Count); - Console.WriteLine("{0} language codes modified", modified); } + + if(codes.Count == 0) + { + Console.WriteLine("No codes found"); + + return; + } + + var existingCodes = context.Iso639.ToList(); + List newCodes = []; + + foreach(Models.Iso639 code in codes) + { + Models.Iso639 existingCode = existingCodes.FirstOrDefault(c => c.Id == code.Id); + + if(existingCode is null) + newCodes.Add(code); + else + { + var changed = false; + + if(code.Part2B != existingCode.Part2B) + { + existingCode.Part2B = code.Part2B; + changed = true; + } + + if(code.Part2T != existingCode.Part2T) + { + existingCode.Part2T = code.Part2T; + changed = true; + } + + if(code.Part1 != existingCode.Part1) + { + existingCode.Part1 = code.Part1; + changed = true; + } + + if(code.Scope != existingCode.Scope) + { + existingCode.Scope = code.Scope; + changed = true; + } + + if(code.Type != existingCode.Type) + { + existingCode.Type = code.Type; + changed = true; + } + + if(code.ReferenceName != existingCode.ReferenceName) + { + existingCode.ReferenceName = code.ReferenceName; + changed = true; + } + + if(code.Comment != existingCode.Comment) + { + existingCode.Comment = code.Comment; + changed = true; + } + + if(changed) modified++; + } + } + + context.Iso639.AddRange(newCodes); + + Console.WriteLine("{0} language codes added", newCodes.Count); + Console.WriteLine("{0} language codes modified", modified); } } \ No newline at end of file diff --git a/Marechai.Database/Seeders/License.cs b/Marechai.Database/Seeders/License.cs index b64f73ff..58ef12f7 100644 --- a/Marechai.Database/Seeders/License.cs +++ b/Marechai.Database/Seeders/License.cs @@ -28,3482 +28,3480 @@ using System.Collections.Generic; using System.Linq; using Marechai.Database.Models; -namespace Marechai.Database.Seeders +namespace Marechai.Database.Seeders; + +public static class License { - public static class License + // Last updated 31 May 2020 using SPDX License List v3.9 + public static void Seed(MarechaiContext context) { - // Last updated 31 May 2020 using SPDX License List v3.9 - public static void Seed(MarechaiContext context) + var existingLicenses = context.Licenses.ToList(); + List newLicenses = []; + var updatedLicencesCount = 0; + + foreach(Models.License license in new[] + { + new Models.License + { + Id = 1, + Name = "Fair use", + FsfApproved = false, + OsiApproved = false + }, + new Models.License + { + Id = 2, + Name = "Advertisement use", + FsfApproved = false, + OsiApproved = false + }, + new Models.License + { + Id = 3, + Name = "All rights reserved", + FsfApproved = false, + OsiApproved = false + }, + new Models.License + { + Id = 4, + Name = "BSD Zero Clause License", + SPDX = "0BSD", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/0BSD.html#licenseText" + }, + new Models.License + { + Id = 5, + Name = "Attribution Assurance License", + SPDX = "AAL", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/AAL.html#licenseText" + }, + new Models.License + { + Id = 6, + Name = "Abstyles License", + SPDX = "Abstyles", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Abstyles.html#licenseText" + }, + new Models.License + { + Id = 7, + Name = "Adobe Systems Incorporated Source Code License Agreement", + SPDX = "Adobe-2006", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Adobe-2006.html#licenseText" + }, + new Models.License + { + Id = 8, + Name = "Adobe Glyph List License", + SPDX = "Adobe-Glyph", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Adobe-Glyph.html#licenseText" + }, + new Models.License + { + Id = 9, + Name = "Amazon Digital Services License", + SPDX = "ADSL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/ADSL.html#licenseText" + }, + new Models.License + { + Id = 10, + Name = "Academic Free License v1.1", + SPDX = "AFL-1.1", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/AFL-1.1.html#licenseText" + }, + new Models.License + { + Id = 11, + Name = "Academic Free License v1.2", + SPDX = "AFL-1.2", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/AFL-1.2.html#licenseText" + }, + new Models.License + { + Id = 12, + Name = "Academic Free License v2.0", + SPDX = "AFL-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/AFL-2.0.html#licenseText" + }, + new Models.License + { + Id = 13, + Name = "Academic Free License v2.1", + SPDX = "AFL-2.1", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/AFL-2.1.html#licenseText" + }, + new Models.License + { + Id = 14, + Name = "Academic Free License v3.0", + SPDX = "AFL-3.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/AFL-3.0.html#licenseText" + }, + new Models.License + { + Id = 15, + Name = "Afmparse License", + SPDX = "Afmparse", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Afmparse.html#licenseText" + }, + new Models.License + { + Id = 16, + Name = "Affero General Public License v1.0 only", + SPDX = "AGPL-1.0-only", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/AGPL-1.0-only.html#licenseText" + }, + new Models.License + { + Id = 17, + Name = "Affero General Public License v1.0 or later", + SPDX = "AGPL-1.0-or-later", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/AGPL-1.0-or-later.html#licenseText" + }, + new Models.License + { + Id = 18, + Name = "GNU Affero General Public License v3.0 only", + SPDX = "AGPL-3.0-only", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/AGPL-3.0-only.html#licenseText" + }, + new Models.License + { + Id = 19, + Name = "GNU Affero General Public License v3.0 or later", + SPDX = "AGPL-3.0-or-later", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/AGPL-3.0-or-later.html#licenseText" + }, + new Models.License + { + Id = 20, + Name = "Aladdin Free Public License", + SPDX = "Aladdin", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Aladdin.html#licenseText" + }, + new Models.License + { + Id = 21, + Name = "AMD's plpa_map.c License", + SPDX = "AMDPLPA", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/AMDPLPA.html#licenseText" + }, + new Models.License + { + Id = 22, + Name = "Apple MIT License", + SPDX = "AML", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/AML.html#licenseText" + }, + new Models.License + { + Id = 23, + Name = "Academy of Motion Picture Arts and Sciences BSD", + SPDX = "AMPAS", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/AMPAS.html#licenseText" + }, + new Models.License + { + Id = 24, + Name = "ANTLR Software Rights Notice", + SPDX = "ANTLR-PD", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/ANTLR-PD.html#licenseText" + }, + new Models.License + { + Id = 25, + Name = "Apache License 1.0", + SPDX = "Apache-1.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/Apache-1.0.html#licenseText" + }, + new Models.License + { + Id = 26, + Name = "Apache License 1.1", + SPDX = "Apache-1.1", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/Apache-1.1.html#licenseText" + }, + new Models.License + { + Id = 27, + Name = "Apache License 2.0", + SPDX = "Apache-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/Apache-2.0.html#licenseText" + }, + new Models.License + { + Id = 28, + Name = "Adobe Postscript AFM License", + SPDX = "APAFML", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/APAFML.html#licenseText" + }, + new Models.License + { + Id = 29, + Name = "Adaptive Public License 1.0", + SPDX = "APL-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/APL-1.0.html#licenseText" + }, + new Models.License + { + Id = 30, + Name = "Apple Public Source License 1.0", + SPDX = "APSL-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/APSL-1.0.html#licenseText" + }, + new Models.License + { + Id = 31, + Name = "Apple Public Source License 1.1", + SPDX = "APSL-1.1", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/APSL-1.1.html#licenseText" + }, + new Models.License + { + Id = 32, + Name = "Apple Public Source License 1.2", + SPDX = "APSL-1.2", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/APSL-1.2.html#licenseText" + }, + new Models.License + { + Id = 33, + Name = "Apple Public Source License 2.0", + SPDX = "APSL-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/APSL-2.0.html#licenseText" + }, + new Models.License + { + Id = 34, + Name = "Artistic License 1.0", + SPDX = "Artistic-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Artistic-1.0.html#licenseText" + }, + new Models.License + { + Id = 35, + Name = "Artistic License 1.0 w/clause 8", + SPDX = "Artistic-1.0-cl8", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Artistic-1.0-cl8.html#licenseText" + }, + new Models.License + { + Id = 36, + Name = "Artistic License 1.0 (Perl)", + SPDX = "Artistic-1.0-Perl", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Artistic-1.0-Perl.html#licenseText" + }, + new Models.License + { + Id = 37, + Name = "Artistic License 2.0", + SPDX = "Artistic-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/Artistic-2.0.html#licenseText" + }, + new Models.License + { + Id = 38, + Name = "Bahyph License", + SPDX = "Bahyph", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Bahyph.html#licenseText" + }, + new Models.License + { + Id = 39, + Name = "Barr License", + SPDX = "Barr", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Barr.html#licenseText" + }, + new Models.License + { + Id = 40, + Name = "Beerware License", + SPDX = "Beerware", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Beerware.html#licenseText" + }, + new Models.License + { + Id = 41, + Name = "BitTorrent Open Source License v1.0", + SPDX = "BitTorrent-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BitTorrent-1.0.html#licenseText" + }, + new Models.License + { + Id = 42, + Name = "BitTorrent Open Source License v1.1", + SPDX = "BitTorrent-1.1", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/BitTorrent-1.1.html#licenseText" + }, + new Models.License + { + Id = 43, + Name = "Borceux license", + SPDX = "Borceux", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Borceux.html#licenseText" + }, + new Models.License + { + Id = 44, + Name = "BSD 1-Clause License", + SPDX = "BSD-1-Clause", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-1-Clause.html#licenseText" + }, + new Models.License + { + Id = 45, + Name = "BSD 2-Clause \"Simplified\" License", + SPDX = "BSD-2-Clause", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/BSD-2-Clause.html#licenseText" + }, + new Models.License + { + Id = 46, + Name = "BSD 2-Clause FreeBSD License", + SPDX = "BSD-2-Clause-FreeBSD", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-2-Clause-FreeBSD.html#licenseText" + }, + new Models.License + { + Id = 47, + Name = "BSD 2-Clause NetBSD License", + SPDX = "BSD-2-Clause-NetBSD", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-2-Clause-NetBSD.html#licenseText" + }, + new Models.License + { + Id = 48, + Name = "BSD-2-Clause Plus Patent License", + SPDX = "BSD-2-Clause-Patent", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/BSD-2-Clause-Patent.html#licenseText" + }, + new Models.License + { + Id = 49, + Name = "BSD 3-Clause \"New\" or \"Revised\" License", + SPDX = "BSD-3-Clause", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/BSD-3-Clause.html#licenseText" + }, + new Models.License + { + Id = 50, + Name = "BSD with attribution", + SPDX = "BSD-3-Clause-Attribution", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-3-Clause-Attribution.html#licenseText" + }, + new Models.License + { + Id = 51, + Name = "BSD 3-Clause Clear License", + SPDX = "BSD-3-Clause-Clear", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-3-Clause-Clear.html#licenseText" + }, + new Models.License + { + Id = 52, + Name = "Lawrence Berkeley National Labs BSD variant license", + SPDX = "BSD-3-Clause-LBNL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-3-Clause-LBNL.html#licenseText" + }, + new Models.License + { + Id = 53, + Name = "BSD 3-Clause No Nuclear License", + SPDX = "BSD-3-Clause-No-Nuclear-License", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-3-Clause-No-Nuclear-License.html#licenseText" + }, + new Models.License + { + Id = 54, + Name = "BSD 3-Clause No Nuclear License 2014", + SPDX = "BSD-3-Clause-No-Nuclear-License-2014", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-3-Clause-No-Nuclear-License-2014.html#licenseText" + }, + new Models.License + { + Id = 55, + Name = "BSD 3-Clause No Nuclear Warranty", + SPDX = "BSD-3-Clause-No-Nuclear-Warranty", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-3-Clause-No-Nuclear-Warranty.html#licenseText" + }, + new Models.License + { + Id = 56, + Name = "BSD 4-Clause \"Original\" or \"Old\" License", + SPDX = "BSD-4-Clause", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-4-Clause.html#licenseText" + }, + new Models.License + { + Id = 57, + Name = "BSD-4-Clause (University of California-Specific)", + SPDX = "BSD-4-Clause-UC", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-4-Clause-UC.html#licenseText" + }, + new Models.License + { + Id = 58, + Name = "BSD Protection License", + SPDX = "BSD-Protection", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-Protection.html#licenseText" + }, + new Models.License + { + Id = 59, + Name = "BSD Source Code Attribution", + SPDX = "BSD-Source-Code", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/BSD-Source-Code.html#licenseText" + }, + new Models.License + { + Id = 60, + Name = "Boost Software License 1.0", + SPDX = "BSL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/BSL-1.0.html#licenseText" + }, + new Models.License + { + Id = 61, + Name = "bzip2 and libbzip2 License v1.0.5", + SPDX = "bzip2-1.0.5", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/bzip2-1.0.5.html#licenseText" + }, + new Models.License + { + Id = 62, + Name = "bzip2 and libbzip2 License v1.0.6", + SPDX = "bzip2-1.0.6", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/bzip2-1.0.6.html#licenseText" + }, + new Models.License + { + Id = 63, + Name = "Caldera License", + SPDX = "Caldera", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Caldera.html#licenseText" + }, + new Models.License + { + Id = 64, + Name = "Computer Associates Trusted Open Source License 1.1", + SPDX = "CATOSL-1.1", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/CATOSL-1.1.html#licenseText" + }, + new Models.License + { + Id = 65, + Name = "Creative Commons Attribution 1.0 Generic", + SPDX = "CC-BY-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-1.0.html#licenseText" + }, + new Models.License + { + Id = 66, + Name = "Creative Commons Attribution 2.0 Generic", + SPDX = "CC-BY-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-2.0.html#licenseText" + }, + new Models.License + { + Id = 67, + Name = "Creative Commons Attribution 2.5 Generic", + SPDX = "CC-BY-2.5", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-2.5.html#licenseText" + }, + new Models.License + { + Id = 68, + Name = "Creative Commons Attribution 3.0 Unported", + SPDX = "CC-BY-3.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-3.0.html#licenseText" + }, + new Models.License + { + Id = 69, + Name = "Creative Commons Attribution 4.0 International", + SPDX = "CC-BY-4.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-4.0.html#licenseText" + }, + new Models.License + { + Id = 70, + Name = "Creative Commons Attribution Non Commercial 1.0 Generic", + SPDX = "CC-BY-NC-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-1.0.html#licenseText" + }, + new Models.License + { + Id = 71, + Name = "Creative Commons Attribution Non Commercial 2.0 Generic", + SPDX = "CC-BY-NC-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-2.0.html#licenseText" + }, + new Models.License + { + Id = 72, + Name = "Creative Commons Attribution Non Commercial 2.5 Generic", + SPDX = "CC-BY-NC-2.5", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-2.5.html#licenseText" + }, + new Models.License + { + Id = 73, + Name = "Creative Commons Attribution Non Commercial 3.0 Unported", + SPDX = "CC-BY-NC-3.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-3.0.html#licenseText" + }, + new Models.License + { + Id = 74, + Name = "Creative Commons Attribution Non Commercial 4.0 International", + SPDX = "CC-BY-NC-4.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-4.0.html#licenseText" + }, + new Models.License + { + Id = 75, + Name = "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic", + SPDX = "CC-BY-NC-ND-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-ND-1.0.html#licenseText" + }, + new Models.License + { + Id = 76, + Name = "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic", + SPDX = "CC-BY-NC-ND-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-ND-2.0.html#licenseText" + }, + new Models.License + { + Id = 77, + Name = "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic", + SPDX = "CC-BY-NC-ND-2.5", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-ND-2.5.html#licenseText" + }, + new Models.License + { + Id = 78, + Name = "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported", + SPDX = "CC-BY-NC-ND-3.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-ND-3.0.html#licenseText" + }, + new Models.License + { + Id = 79, + Name = "Creative Commons Attribution Non Commercial No Derivatives 4.0 International", + SPDX = "CC-BY-NC-ND-4.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-ND-4.0.html#licenseText" + }, + new Models.License + { + Id = 80, + Name = "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic", + SPDX = "CC-BY-NC-SA-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-SA-1.0.html#licenseText" + }, + new Models.License + { + Id = 81, + Name = "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic", + SPDX = "CC-BY-NC-SA-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-SA-2.0.html#licenseText" + }, + new Models.License + { + Id = 82, + Name = "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic", + SPDX = "CC-BY-NC-SA-2.5", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-SA-2.5.html#licenseText" + }, + new Models.License + { + Id = 83, + Name = "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported", + SPDX = "CC-BY-NC-SA-3.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-SA-3.0.html#licenseText" + }, + new Models.License + { + Id = 84, + Name = "Creative Commons Attribution Non Commercial Share Alike 4.0 International", + SPDX = "CC-BY-NC-SA-4.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-NC-SA-4.0.html#licenseText" + }, + new Models.License + { + Id = 85, + Name = "Creative Commons Attribution No Derivatives 1.0 Generic", + SPDX = "CC-BY-ND-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-ND-1.0.html#licenseText" + }, + new Models.License + { + Id = 86, + Name = "Creative Commons Attribution No Derivatives 2.0 Generic", + SPDX = "CC-BY-ND-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-ND-2.0.html#licenseText" + }, + new Models.License + { + Id = 87, + Name = "Creative Commons Attribution No Derivatives 2.5 Generic", + SPDX = "CC-BY-ND-2.5", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-ND-2.5.html#licenseText" + }, + new Models.License + { + Id = 88, + Name = "Creative Commons Attribution No Derivatives 3.0 Unported", + SPDX = "CC-BY-ND-3.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-ND-3.0.html#licenseText" + }, + new Models.License + { + Id = 89, + Name = "Creative Commons Attribution No Derivatives 4.0 International", + SPDX = "CC-BY-ND-4.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-ND-4.0.html#licenseText" + }, + new Models.License + { + Id = 90, + Name = "Creative Commons Attribution Share Alike 1.0 Generic", + SPDX = "CC-BY-SA-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-SA-1.0.html#licenseText" + }, + new Models.License + { + Id = 91, + Name = "Creative Commons Attribution Share Alike 2.0 Generic", + SPDX = "CC-BY-SA-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-SA-2.0.html#licenseText" + }, + new Models.License + { + Id = 92, + Name = "Creative Commons Attribution Share Alike 2.5 Generic", + SPDX = "CC-BY-SA-2.5", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-SA-2.5.html#licenseText" + }, + new Models.License + { + Id = 93, + Name = "Creative Commons Attribution Share Alike 3.0 Unported", + SPDX = "CC-BY-SA-3.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-SA-3.0.html#licenseText" + }, + new Models.License + { + Id = 94, + Name = "Creative Commons Attribution Share Alike 4.0 International", + SPDX = "CC-BY-SA-4.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC-BY-SA-4.0.html#licenseText" + }, + new Models.License + { + Id = 95, + Name = "Creative Commons Zero v1.0 Universal", + SPDX = "CC0-1.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/CC0-1.0.html#licenseText" + }, + new Models.License + { + Id = 96, + Name = "Common Development and Distribution License 1.0", + SPDX = "CDDL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/CDDL-1.0.html#licenseText" + }, + new Models.License + { + Id = 97, + Name = "Common Development and Distribution License 1.1", + SPDX = "CDDL-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CDDL-1.1.html#licenseText" + }, + new Models.License + { + Id = 98, + Name = "Community Data License Agreement Permissive 1.0", + SPDX = "CDLA-Permissive-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CDLA-Permissive-1.0.html#licenseText" + }, + new Models.License + { + Id = 99, + Name = "Community Data License Agreement Sharing 1.0", + SPDX = "CDLA-Sharing-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CDLA-Sharing-1.0.html#licenseText" + }, + new Models.License + { + Id = 100, + Name = "CeCILL Free Software License Agreement v1.0", + SPDX = "CECILL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CECILL-1.0.html#licenseText" + }, + new Models.License + { + Id = 101, + Name = "CeCILL Free Software License Agreement v1.1", + SPDX = "CECILL-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CECILL-1.1.html#licenseText" + }, + new Models.License + { + Id = 102, + Name = "CeCILL Free Software License Agreement v2.0", + SPDX = "CECILL-2.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/CECILL-2.0.html#licenseText" + }, + new Models.License + { + Id = 103, + Name = "CeCILL Free Software License Agreement v2.1", + SPDX = "CECILL-2.1", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/CECILL-2.1.html#licenseText" + }, + new Models.License + { + Id = 104, + Name = "CeCILL-B Free Software License Agreement", + SPDX = "CECILL-B", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/CECILL-B.html#licenseText" + }, + new Models.License + { + Id = 105, + Name = "CeCILL-C Free Software License Agreement", + SPDX = "CECILL-C", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/CECILL-C.html#licenseText" + }, + new Models.License + { + Id = 106, + Name = "CERN Open Hardware License v1.1", + SPDX = "CERN-OHL-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CERN-OHL-1.1.html#licenseText" + }, + new Models.License + { + Id = 107, + Name = "CERN Open Hardware Licence v1.2", + SPDX = "CERN-OHL-1.2", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CERN-OHL-1.2.html#licenseText" + }, + new Models.License + { + Id = 108, + Name = "Clarified Artistic License", + SPDX = "ClArtistic", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/ClArtistic.html#licenseText" + }, + new Models.License + { + Id = 109, + Name = "CNRI Jython License", + SPDX = "CNRI-Jython", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CNRI-Jython.html#licenseText" + }, + new Models.License + { + Id = 110, + Name = "CNRI Python License", + SPDX = "CNRI-Python", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/CNRI-Python.html#licenseText" + }, + new Models.License + { + Id = 111, + Name = "CNRI Python Open Source GPL Compatible License Agreement", + SPDX = "CNRI-Python-GPL-Compatible", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CNRI-Python-GPL-Compatible.html#licenseText" + }, + new Models.License + { + Id = 112, + Name = "Condor Public License v1.1", + SPDX = "Condor-1.1", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/Condor-1.1.html#licenseText" + }, + new Models.License + { + Id = 113, + Name = "copyleft-next 0.3.0", + SPDX = "copyleft-next-0.3.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/copyleft-next-0.3.0.html#licenseText" + }, + new Models.License + { + Id = 114, + Name = "copyleft-next 0.3.1", + SPDX = "copyleft-next-0.3.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/copyleft-next-0.3.1.html#licenseText" + }, + new Models.License + { + Id = 115, + Name = "Common Public Attribution License 1.0", + SPDX = "CPAL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/CPAL-1.0.html#licenseText" + }, + new Models.License + { + Id = 116, + Name = "Common Public License 1.0", + SPDX = "CPL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/CPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 117, + Name = "Code Project Open License 1.02", + SPDX = "CPOL-1.02", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CPOL-1.02.html#licenseText" + }, + new Models.License + { + Id = 118, + Name = "Crossword License", + SPDX = "Crossword", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Crossword.html#licenseText" + }, + new Models.License + { + Id = 119, + Name = "CrystalStacker License", + SPDX = "CrystalStacker", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CrystalStacker.html#licenseText" + }, + new Models.License + { + Id = 120, + Name = "CUA Office Public License v1.0", + SPDX = "CUA-OPL-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/CUA-OPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 121, + Name = "Cube License", + SPDX = "Cube", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Cube.html#licenseText" + }, + new Models.License + { + Id = 122, + Name = "curl License", + SPDX = "curl", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/curl.html#licenseText" + }, + new Models.License + { + Id = 123, + Name = "Deutsche Freie Software Lizenz", + SPDX = "D-FSL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/D-FSL-1.0.html#licenseText" + }, + new Models.License + { + Id = 124, + Name = "diffmark license", + SPDX = "diffmark", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/diffmark.html#licenseText" + }, + new Models.License + { + Id = 125, + Name = "DOC License", + SPDX = "DOC", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/DOC.html#licenseText" + }, + new Models.License + { + Id = 126, + Name = "Dotseqn License", + SPDX = "Dotseqn", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Dotseqn.html#licenseText" + }, + new Models.License + { + Id = 127, + Name = "DSDP License", + SPDX = "DSDP", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/DSDP.html#licenseText" + }, + new Models.License + { + Id = 128, + Name = "dvipdfm License", + SPDX = "dvipdfm", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/dvipdfm.html#licenseText" + }, + new Models.License + { + Id = 129, + Name = "Educational Community License v1.0", + SPDX = "ECL-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/ECL-1.0.html#licenseText" + }, + new Models.License + { + Id = 130, + Name = "Educational Community License v2.0", + SPDX = "ECL-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/ECL-2.0.html#licenseText" + }, + new Models.License + { + Id = 131, + Name = "Eiffel Forum License v1.0", + SPDX = "EFL-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/EFL-1.0.html#licenseText" + }, + new Models.License + { + Id = 132, + Name = "Eiffel Forum License v2.0", + SPDX = "EFL-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/EFL-2.0.html#licenseText" + }, + new Models.License + { + Id = 133, + Name = "eGenix.com Public License 1.1.0", + SPDX = "eGenix", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/eGenix.html#licenseText" + }, + new Models.License + { + Id = 134, + Name = "Entessa Public License v1.0", + SPDX = "Entessa", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Entessa.html#licenseText" + }, + new Models.License + { + Id = 135, + Name = "Eclipse Public License 1.0", + SPDX = "EPL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/EPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 136, + Name = "Eclipse Public License 2.0", + SPDX = "EPL-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/EPL-2.0.html#licenseText" + }, + new Models.License + { + Id = 137, + Name = "Erlang Public License v1.1", + SPDX = "ErlPL-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/ErlPL-1.1.html#licenseText" + }, + new Models.License + { + Id = 138, + Name = "EU DataGrid Software License", + SPDX = "EUDatagrid", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/EUDatagrid.html#licenseText" + }, + new Models.License + { + Id = 139, + Name = "European Union Public License 1.0", + SPDX = "EUPL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/EUPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 140, + Name = "European Union Public License 1.1", + SPDX = "EUPL-1.1", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/EUPL-1.1.html#licenseText" + }, + new Models.License + { + Id = 141, + Name = "European Union Public License 1.2", + SPDX = "EUPL-1.2", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/EUPL-1.2.html#licenseText" + }, + new Models.License + { + Id = 142, + Name = "Eurosym License", + SPDX = "Eurosym", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Eurosym.html#licenseText" + }, + new Models.License + { + Id = 143, + Name = "Fair License", + SPDX = "Fair", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Fair.html#licenseText" + }, + new Models.License + { + Id = 144, + Name = "Frameworx Open License 1.0", + SPDX = "Frameworx-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Frameworx-1.0.html#licenseText" + }, + new Models.License + { + Id = 145, + Name = "FreeImage Public License v1.0", + SPDX = "FreeImage", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/FreeImage.html#licenseText" + }, + new Models.License + { + Id = 146, + Name = "FSF All Permissive License", + SPDX = "FSFAP", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/FSFAP.html#licenseText" + }, + new Models.License + { + Id = 147, + Name = "FSF Unlimited License", + SPDX = "FSFUL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/FSFUL.html#licenseText" + }, + new Models.License + { + Id = 148, + Name = "FSF Unlimited License (with License Retention)", + SPDX = "FSFULLR", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/FSFULLR.html#licenseText" + }, + new Models.License + { + Id = 149, + Name = "Freetype Project License", + SPDX = "FTL", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/FTL.html#licenseText" + }, + new Models.License + { + Id = 150, + Name = "GNU Free Documentation License v1.1 only", + SPDX = "GFDL-1.1-only", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/GFDL-1.1-only.html#licenseText" + }, + new Models.License + { + Id = 151, + Name = "GNU Free Documentation License v1.1 or later", + SPDX = "GFDL-1.1-or-later", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/GFDL-1.1-or-later.html#licenseText" + }, + new Models.License + { + Id = 152, + Name = "GNU Free Documentation License v1.2 only", + SPDX = "GFDL-1.2-only", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/GFDL-1.2-only.html#licenseText" + }, + new Models.License + { + Id = 153, + Name = "GNU Free Documentation License v1.2 or later", + SPDX = "GFDL-1.2-or-later", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/GFDL-1.2-or-later.html#licenseText" + }, + new Models.License + { + Id = 154, + Name = "GNU Free Documentation License v1.3 only", + SPDX = "GFDL-1.3-only", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/GFDL-1.3-only.html#licenseText" + }, + new Models.License + { + Id = 155, + Name = "GNU Free Documentation License v1.3 or later", + SPDX = "GFDL-1.3-or-later", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/GFDL-1.3-or-later.html#licenseText" + }, + new Models.License + { + Id = 156, + Name = "Giftware License", + SPDX = "Giftware", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Giftware.html#licenseText" + }, + new Models.License + { + Id = 157, + Name = "GL2PS License", + SPDX = "GL2PS", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/GL2PS.html#licenseText" + }, + new Models.License + { + Id = 158, + Name = "3dfx Glide License", + SPDX = "Glide", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Glide.html#licenseText" + }, + new Models.License + { + Id = 159, + Name = "Glulxe License", + SPDX = "Glulxe", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Glulxe.html#licenseText" + }, + new Models.License + { + Id = 160, + Name = "gnuplot License", + SPDX = "gnuplot", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/gnuplot.html#licenseText" + }, + new Models.License + { + Id = 161, + Name = "GNU General Public License v1.0 only", + SPDX = "GPL-1.0-only", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/GPL-1.0-only.html#licenseText" + }, + new Models.License + { + Id = 162, + Name = "GNU General Public License v1.0 or later", + SPDX = "GPL-1.0-or-later", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/GPL-1.0-or-later.html#licenseText" + }, + new Models.License + { + Id = 163, + Name = "GNU General Public License v2.0 only", + SPDX = "GPL-2.0-only", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/GPL-2.0-only.html#licenseText" + }, + new Models.License + { + Id = 164, + Name = "GNU General Public License v2.0 or later", + SPDX = "GPL-2.0-or-later", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText" + }, + new Models.License + { + Id = 165, + Name = "GNU General Public License v3.0 only", + SPDX = "GPL-3.0-only", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/GPL-3.0-only.html#licenseText" + }, + new Models.License + { + Id = 166, + Name = "GNU General Public License v3.0 or later", + SPDX = "GPL-3.0-or-later", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/GPL-3.0-or-later.html#licenseText" + }, + new Models.License + { + Id = 167, + Name = "gSOAP Public License v1.3b", + SPDX = "gSOAP-1.3b", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/gSOAP-1.3b.html#licenseText" + }, + new Models.License + { + Id = 168, + Name = "Haskell Language Report License", + SPDX = "HaskellReport", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/HaskellReport.html#licenseText" + }, + new Models.License + { + Id = 169, + Name = "Historical Permission Notice and Disclaimer", + SPDX = "HPND", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/HPND.html#licenseText" + }, + new Models.License + { + Id = 170, + Name = "Historical Permission Notice and Disclaimer - sell variant", + SPDX = "HPND-sell-variant", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/HPND-sell-variant.html#licenseText" + }, + new Models.License + { + Id = 171, + Name = "IBM PowerPC Initialization and Boot Software", + SPDX = "IBM-pibs", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/IBM-pibs.html#licenseText" + }, + new Models.License + { + Id = 172, + Name = "ICU License", + SPDX = "ICU", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/ICU.html#licenseText" + }, + new Models.License + { + Id = 173, + Name = "Independent JPEG Group License", + SPDX = "IJG", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/IJG.html#licenseText" + }, + new Models.License + { + Id = 174, + Name = "ImageMagick License", + SPDX = "ImageMagick", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/ImageMagick.html#licenseText" + }, + new Models.License + { + Id = 175, + Name = "iMatix Standard Function Library Agreement", + SPDX = "iMatix", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/iMatix.html#licenseText" + }, + new Models.License + { + Id = 176, + Name = "Imlib2 License", + SPDX = "Imlib2", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/Imlib2.html#licenseText" + }, + new Models.License + { + Id = 177, + Name = "Info-ZIP License", + SPDX = "Info-ZIP", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Info-ZIP.html#licenseText" + }, + new Models.License + { + Id = 178, + Name = "Intel Open Source License", + SPDX = "Intel", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/Intel.html#licenseText" + }, + new Models.License + { + Id = 179, + Name = "Intel ACPI Software License Agreement", + SPDX = "Intel-ACPI", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Intel-ACPI.html#licenseText" + }, + new Models.License + { + Id = 180, + Name = "Interbase Public License v1.0", + SPDX = "Interbase-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Interbase-1.0.html#licenseText" + }, + new Models.License + { + Id = 181, + Name = "IPA Font License", + SPDX = "IPA", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/IPA.html#licenseText" + }, + new Models.License + { + Id = 182, + Name = "IBM Public License v1.0", + SPDX = "IPL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/IPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 183, + Name = "ISC License", + SPDX = "ISC", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/ISC.html#licenseText" + }, + new Models.License + { + Id = 184, + Name = "JasPer License", + SPDX = "JasPer-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/JasPer-2.0.html#licenseText" + }, + new Models.License + { + Id = 185, + Name = "Japan Network Information Center License", + SPDX = "JPNIC", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/JPNIC.html#licenseText" + }, + new Models.License + { + Id = 186, + Name = "JSON License", + SPDX = "JSON", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/JSON.html#licenseText" + }, + new Models.License + { + Id = 187, + Name = "Licence Art Libre 1.2", + SPDX = "LAL-1.2", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/LAL-1.2.html#licenseText" + }, + new Models.License + { + Id = 188, + Name = "Licence Art Libre 1.3", + SPDX = "LAL-1.3", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/LAL-1.3.html#licenseText" + }, + new Models.License + { + Id = 189, + Name = "Latex2e License", + SPDX = "Latex2e", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Latex2e.html#licenseText" + }, + new Models.License + { + Id = 190, + Name = "Leptonica License", + SPDX = "Leptonica", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Leptonica.html#licenseText" + }, + new Models.License + { + Id = 191, + Name = "GNU Library General Public License v2 only", + SPDX = "LGPL-2.0-only", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/LGPL-2.0-only.html#licenseText" + }, + new Models.License + { + Id = 192, + Name = "GNU Library General Public License v2 or later", + SPDX = "LGPL-2.0-or-later", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/LGPL-2.0-or-later.html#licenseText" + }, + new Models.License + { + Id = 193, + Name = "GNU Lesser General Public License v2.1 only", + SPDX = "LGPL-2.1-only", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/LGPL-2.1-only.html#licenseText" + }, + new Models.License + { + Id = 194, + Name = "GNU Lesser General Public License v2.1 or later", + SPDX = "LGPL-2.1-or-later", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/LGPL-2.1-or-later.html#licenseText" + }, + new Models.License + { + Id = 195, + Name = "GNU Lesser General Public License v3.0 only", + SPDX = "LGPL-3.0-only", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/LGPL-3.0-only.html#licenseText" + }, + new Models.License + { + Id = 196, + Name = "GNU Lesser General Public License v3.0 or later", + SPDX = "LGPL-3.0-or-later", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/LGPL-3.0-or-later.html#licenseText" + }, + new Models.License + { + Id = 197, + Name = "Lesser General Public License For Linguistic Resources", + SPDX = "LGPLLR", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/LGPLLR.html#licenseText" + }, + new Models.License + { + Id = 198, + Name = "libpng License", + SPDX = "Libpng", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Libpng.html#licenseText" + }, + new Models.License + { + Id = 199, + Name = "PNG Reference Library version 2", + SPDX = "libpng-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/libpng-2.0.html#licenseText" + }, + new Models.License + { + Id = 200, + Name = "libtiff License", + SPDX = "libtiff", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/libtiff.html#licenseText" + }, + new Models.License + { + Id = 201, + Name = "Licence Libre du Québec – Permissive version 1.1", + SPDX = "LiLiQ-P-1.1", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/LiLiQ-P-1.1.html#licenseText" + }, + new Models.License + { + Id = 202, + Name = "Licence Libre du Québec – Réciprocité version 1.1", + SPDX = "LiLiQ-R-1.1", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/LiLiQ-R-1.1.html#licenseText" + }, + new Models.License + { + Id = 203, + Name = "Licence Libre du Québec – Réciprocité forte version 1.1", + SPDX = "LiLiQ-Rplus-1.1", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/LiLiQ-Rplus-1.1.html#licenseText" + }, + new Models.License + { + Id = 204, + Name = "Linux Kernel Variant of OpenIB.org license", + SPDX = "Linux-OpenIB", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Linux-OpenIB.html#licenseText" + }, + new Models.License + { + Id = 205, + Name = "Lucent Public License Version 1.0", + SPDX = "LPL-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/LPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 206, + Name = "Lucent Public License v1.02", + SPDX = "LPL-1.02", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/LPL-1.02.html#licenseText" + }, + new Models.License + { + Id = 207, + Name = "LaTeX Project Public License v1.0", + SPDX = "LPPL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/LPPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 208, + Name = "LaTeX Project Public License v1.1", + SPDX = "LPPL-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/LPPL-1.1.html#licenseText" + }, + new Models.License + { + Id = 209, + Name = "LaTeX Project Public License v1.2", + SPDX = "LPPL-1.2", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/LPPL-1.2.html#licenseText" + }, + new Models.License + { + Id = 210, + Name = "LaTeX Project Public License v1.3a", + SPDX = "LPPL-1.3a", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/LPPL-1.3a.html#licenseText" + }, + new Models.License + { + Id = 211, + Name = "LaTeX Project Public License v1.3c", + SPDX = "LPPL-1.3c", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/LPPL-1.3c.html#licenseText" + }, + new Models.License + { + Id = 212, + Name = "MakeIndex License", + SPDX = "MakeIndex", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/MakeIndex.html#licenseText" + }, + new Models.License + { + Id = 213, + Name = "MirOS License", + SPDX = "MirOS", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/MirOS.html#licenseText" + }, + new Models.License + { + Id = 214, + Name = "MIT License", + SPDX = "MIT", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/MIT.html#licenseText" + }, + new Models.License + { + Id = 215, + Name = "MIT No Attribution", + SPDX = "MIT-0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/MIT-0.html#licenseText" + }, + new Models.License + { + Id = 216, + Name = "Enlightenment License (e16)", + SPDX = "MIT-advertising", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/MIT-advertising.html#licenseText" + }, + new Models.License + { + Id = 217, + Name = "CMU License", + SPDX = "MIT-CMU", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/MIT-CMU.html#licenseText" + }, + new Models.License + { + Id = 218, + Name = "enna License", + SPDX = "MIT-enna", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/MIT-enna.html#licenseText" + }, + new Models.License + { + Id = 219, + Name = "feh License", + SPDX = "MIT-feh", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/MIT-feh.html#licenseText" + }, + new Models.License + { + Id = 220, + Name = "MIT +no-false-attribs license", + SPDX = "MITNFA", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/MITNFA.html#licenseText" + }, + new Models.License + { + Id = 221, + Name = "Motosoto License", + SPDX = "Motosoto", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Motosoto.html#licenseText" + }, + new Models.License + { + Id = 222, + Name = "mpich2 License", + SPDX = "mpich2", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/mpich2.html#licenseText" + }, + new Models.License + { + Id = 223, + Name = "Mozilla Public License 1.0", + SPDX = "MPL-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/MPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 224, + Name = "Mozilla Public License 1.1", + SPDX = "MPL-1.1", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/MPL-1.1.html#licenseText" + }, + new Models.License + { + Id = 225, + Name = "Mozilla Public License 2.0", + SPDX = "MPL-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/MPL-2.0.html#licenseText" + }, + new Models.License + { + Id = 226, + Name = "Mozilla Public License 2.0 (no copyleft exception)", + SPDX = "MPL-2.0-no-copyleft-exception", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/MPL-2.0-no-copyleft-exception.html#licenseText" + }, + new Models.License + { + Id = 227, + Name = "Microsoft Public License", + SPDX = "MS-PL", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/MS-PL.html#licenseText" + }, + new Models.License + { + Id = 228, + Name = "Microsoft Reciprocal License", + SPDX = "MS-RL", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/MS-RL.html#licenseText" + }, + new Models.License + { + Id = 229, + Name = "Matrix Template Library License", + SPDX = "MTLL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/MTLL.html#licenseText" + }, + new Models.License + { + Id = 230, + Name = "Multics License", + SPDX = "Multics", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Multics.html#licenseText" + }, + new Models.License + { + Id = 231, + Name = "Mup License", + SPDX = "Mup", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Mup.html#licenseText" + }, + new Models.License + { + Id = 232, + Name = "NASA Open Source Agreement 1.3", + SPDX = "NASA-1.3", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/NASA-1.3.html#licenseText" + }, + new Models.License + { + Id = 233, + Name = "Naumen Public License", + SPDX = "Naumen", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Naumen.html#licenseText" + }, + new Models.License + { + Id = 234, + Name = "Net Boolean Public License v1", + SPDX = "NBPL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/NBPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 235, + Name = "University of Illinois/NCSA Open Source License", + SPDX = "NCSA", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/NCSA.html#licenseText" + }, + new Models.License + { + Id = 236, + Name = "Net-SNMP License", + SPDX = "Net-SNMP", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Net-SNMP.html#licenseText" + }, + new Models.License + { + Id = 237, + Name = "NetCDF license", + SPDX = "NetCDF", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/NetCDF.html#licenseText" + }, + new Models.License + { + Id = 238, + Name = "Newsletr License", + SPDX = "Newsletr", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Newsletr.html#licenseText" + }, + new Models.License + { + Id = 239, + Name = "Nethack General Public License", + SPDX = "NGPL", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/NGPL.html#licenseText" + }, + new Models.License + { + Id = 240, + Name = "Norwegian Licence for Open Government Data", + SPDX = "NLOD-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/NLOD-1.0.html#licenseText" + }, + new Models.License + { + Id = 241, + Name = "No Limit Public License", + SPDX = "NLPL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/NLPL.html#licenseText" + }, + new Models.License + { + Id = 242, + Name = "Nokia Open Source License", + SPDX = "Nokia", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/Nokia.html#licenseText" + }, + new Models.License + { + Id = 243, + Name = "Netizen Open Source License", + SPDX = "NOSL", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/NOSL.html#licenseText" + }, + new Models.License + { + Id = 244, + Name = "Noweb License", + SPDX = "Noweb", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Noweb.html#licenseText" + }, + new Models.License + { + Id = 245, + Name = "Netscape Public License v1.0", + SPDX = "NPL-1.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/NPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 246, + Name = "Netscape Public License v1.1", + SPDX = "NPL-1.1", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/NPL-1.1.html#licenseText" + }, + new Models.License + { + Id = 247, + Name = "Non-Profit Open Software License 3.0", + SPDX = "NPOSL-3.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/NPOSL-3.0.html#licenseText" + }, + new Models.License + { + Id = 248, + Name = "NRL License", + SPDX = "NRL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/NRL.html#licenseText" + }, + new Models.License + { + Id = 249, + Name = "NTP License", + SPDX = "NTP", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/NTP.html#licenseText" + }, + new Models.License + { + Id = 250, + Name = "Open CASCADE Technology Public License", + SPDX = "OCCT-PL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OCCT-PL.html#licenseText" + }, + new Models.License + { + Id = 251, + Name = "OCLC Research Public License 2.0", + SPDX = "OCLC-2.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/OCLC-2.0.html#licenseText" + }, + new Models.License + { + Id = 252, + Name = "ODC Open Database License v1.0", + SPDX = "ODbL-1.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/ODbL-1.0.html#licenseText" + }, + new Models.License + { + Id = 253, + Name = "Open Data Commons Attribution License v1.0", + SPDX = "ODC-By-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/ODC-By-1.0.html#licenseText" + }, + new Models.License + { + Id = 254, + Name = "SIL Open Font License 1.0", + SPDX = "OFL-1.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/OFL-1.0.html#licenseText" + }, + new Models.License + { + Id = 255, + Name = "SIL Open Font License 1.1", + SPDX = "OFL-1.1", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/OFL-1.1.html#licenseText" + }, + new Models.License + { + Id = 256, + Name = "Open Government Licence v1.0", + SPDX = "OGL-UK-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OGL-UK-1.0.html#licenseText" + }, + new Models.License + { + Id = 257, + Name = "Open Government Licence v2.0", + SPDX = "OGL-UK-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OGL-UK-2.0.html#licenseText" + }, + new Models.License + { + Id = 258, + Name = "Open Government Licence v3.0", + SPDX = "OGL-UK-3.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OGL-UK-3.0.html#licenseText" + }, + new Models.License + { + Id = 259, + Name = "Open Group Test Suite License", + SPDX = "OGTSL", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/OGTSL.html#licenseText" + }, + new Models.License + { + Id = 260, + Name = "Open LDAP Public License v1.1", + SPDX = "OLDAP-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-1.1.html#licenseText" + }, + new Models.License + { + Id = 261, + Name = "Open LDAP Public License v1.2", + SPDX = "OLDAP-1.2", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-1.2.html#licenseText" + }, + new Models.License + { + Id = 262, + Name = "Open LDAP Public License v1.3", + SPDX = "OLDAP-1.3", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-1.3.html#licenseText" + }, + new Models.License + { + Id = 263, + Name = "Open LDAP Public License v1.4", + SPDX = "OLDAP-1.4", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-1.4.html#licenseText" + }, + new Models.License + { + Id = 264, + Name = "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)", + SPDX = "OLDAP-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.0.html#licenseText" + }, + new Models.License + { + Id = 265, + Name = "Open LDAP Public License v2.0.1", + SPDX = "OLDAP-2.0.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.0.1.html#licenseText" + }, + new Models.License + { + Id = 266, + Name = "Open LDAP Public License v2.1", + SPDX = "OLDAP-2.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.1.html#licenseText" + }, + new Models.License + { + Id = 267, + Name = "Open LDAP Public License v2.2", + SPDX = "OLDAP-2.2", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.2.html#licenseText" + }, + new Models.License + { + Id = 268, + Name = "Open LDAP Public License v2.2.1", + SPDX = "OLDAP-2.2.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.2.1.html#licenseText" + }, + new Models.License + { + Id = 269, + Name = "Open LDAP Public License 2.2.2", + SPDX = "OLDAP-2.2.2", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.2.2.html#licenseText" + }, + new Models.License + { + Id = 270, + Name = "Open LDAP Public License v2.3", + SPDX = "OLDAP-2.3", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.3.html#licenseText" + }, + new Models.License + { + Id = 271, + Name = "Open LDAP Public License v2.4", + SPDX = "OLDAP-2.4", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.4.html#licenseText" + }, + new Models.License + { + Id = 272, + Name = "Open LDAP Public License v2.5", + SPDX = "OLDAP-2.5", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.5.html#licenseText" + }, + new Models.License + { + Id = 273, + Name = "Open LDAP Public License v2.6", + SPDX = "OLDAP-2.6", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.6.html#licenseText" + }, + new Models.License + { + Id = 274, + Name = "Open LDAP Public License v2.7", + SPDX = "OLDAP-2.7", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.7.html#licenseText" + }, + new Models.License + { + Id = 275, + Name = "Open LDAP Public License v2.8", + SPDX = "OLDAP-2.8", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OLDAP-2.8.html#licenseText" + }, + new Models.License + { + Id = 276, + Name = "Open Market License", + SPDX = "OML", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OML.html#licenseText" + }, + new Models.License + { + Id = 277, + Name = "OpenSSL License", + SPDX = "OpenSSL", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/OpenSSL.html#licenseText" + }, + new Models.License + { + Id = 278, + Name = "Open Public License v1.0", + SPDX = "OPL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 279, + Name = "OSET Public License version 2.1", + SPDX = "OSET-PL-2.1", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/OSET-PL-2.1.html#licenseText" + }, + new Models.License + { + Id = 280, + Name = "Open Software License 1.0", + SPDX = "OSL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/OSL-1.0.html#licenseText" + }, + new Models.License + { + Id = 281, + Name = "Open Software License 1.1", + SPDX = "OSL-1.1", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/OSL-1.1.html#licenseText" + }, + new Models.License + { + Id = 282, + Name = "Open Software License 2.0", + SPDX = "OSL-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/OSL-2.0.html#licenseText" + }, + new Models.License + { + Id = 283, + Name = "Open Software License 2.1", + SPDX = "OSL-2.1", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/OSL-2.1.html#licenseText" + }, + new Models.License + { + Id = 284, + Name = "Open Software License 3.0", + SPDX = "OSL-3.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/OSL-3.0.html#licenseText" + }, + new Models.License + { + Id = 285, + Name = "ODC Public Domain Dedication & License 1.0", + SPDX = "PDDL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/PDDL-1.0.html#licenseText" + }, + new Models.License + { + Id = 286, + Name = "PHP License v3.0", + SPDX = "PHP-3.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/PHP-3.0.html#licenseText" + }, + new Models.License + { + Id = 287, + Name = "PHP License v3.01", + SPDX = "PHP-3.01", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/PHP-3.01.html#licenseText" + }, + new Models.License + { + Id = 288, + Name = "Plexus Classworlds License", + SPDX = "Plexus", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Plexus.html#licenseText" + }, + new Models.License + { + Id = 289, + Name = "PostgreSQL License", + SPDX = "PostgreSQL", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/PostgreSQL.html#licenseText" + }, + new Models.License + { + Id = 290, + Name = "psfrag License", + SPDX = "psfrag", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/psfrag.html#licenseText" + }, + new Models.License + { + Id = 291, + Name = "psutils License", + SPDX = "psutils", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/psutils.html#licenseText" + }, + new Models.License + { + Id = 292, + Name = "Python License 2.0", + SPDX = "Python-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/Python-2.0.html#licenseText" + }, + new Models.License + { + Id = 293, + Name = "Qhull License", + SPDX = "Qhull", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Qhull.html#licenseText" + }, + new Models.License + { + Id = 294, + Name = "Q Public License 1.0", + SPDX = "QPL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/QPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 295, + Name = "Rdisc License", + SPDX = "Rdisc", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Rdisc.html#licenseText" + }, + new Models.License + { + Id = 296, + Name = "Red Hat eCos Public License v1.1", + SPDX = "RHeCos-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/RHeCos-1.1.html#licenseText" + }, + new Models.License + { + Id = 297, + Name = "Reciprocal Public License 1.1", + SPDX = "RPL-1.1", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/RPL-1.1.html#licenseText" + }, + new Models.License + { + Id = 298, + Name = "Reciprocal Public License 1.5", + SPDX = "RPL-1.5", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/RPL-1.5.html#licenseText" + }, + new Models.License + { + Id = 299, + Name = "RealNetworks Public Source License v1.0", + SPDX = "RPSL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/RPSL-1.0.html#licenseText" + }, + new Models.License + { + Id = 300, + Name = "RSA Message-Digest License", + SPDX = "RSA-MD", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/RSA-MD.html#licenseText" + }, + new Models.License + { + Id = 301, + Name = "Ricoh Source Code Public License", + SPDX = "RSCPL", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/RSCPL.html#licenseText" + }, + new Models.License + { + Id = 302, + Name = "Ruby License", + SPDX = "Ruby", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/Ruby.html#licenseText" + }, + new Models.License + { + Id = 303, + Name = "Sax Public Domain Notice", + SPDX = "SAX-PD", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SAX-PD.html#licenseText" + }, + new Models.License + { + Id = 304, + Name = "Saxpath License", + SPDX = "Saxpath", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Saxpath.html#licenseText" + }, + new Models.License + { + Id = 305, + Name = "SCEA Shared Source License", + SPDX = "SCEA", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SCEA.html#licenseText" + }, + new Models.License + { + Id = 306, + Name = "Sendmail License", + SPDX = "Sendmail", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Sendmail.html#licenseText" + }, + new Models.License + { + Id = 307, + Name = "Sendmail License 8.23", + SPDX = "Sendmail-8.23", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Sendmail-8.23.html#licenseText" + }, + new Models.License + { + Id = 308, + Name = "SGI Free Software License B v1.0", + SPDX = "SGI-B-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SGI-B-1.0.html#licenseText" + }, + new Models.License + { + Id = 309, + Name = "SGI Free Software License B v1.1", + SPDX = "SGI-B-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SGI-B-1.1.html#licenseText" + }, + new Models.License + { + Id = 310, + Name = "SGI Free Software License B v2.0", + SPDX = "SGI-B-2.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/SGI-B-2.0.html#licenseText" + }, + new Models.License + { + Id = 311, + Name = "Simple Public License 2.0", + SPDX = "SimPL-2.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/SimPL-2.0.html#licenseText" + }, + new Models.License + { + Id = 312, + Name = "Sun Industry Standards Source License v1.1", + SPDX = "SISSL", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/SISSL.html#licenseText" + }, + new Models.License + { + Id = 313, + Name = "Sun Industry Standards Source License v1.2", + SPDX = "SISSL-1.2", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SISSL-1.2.html#licenseText" + }, + new Models.License + { + Id = 314, + Name = "Sleepycat License", + SPDX = "Sleepycat", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/Sleepycat.html#licenseText" + }, + new Models.License + { + Id = 315, + Name = "Standard ML of New Jersey License", + SPDX = "SMLNJ", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/SMLNJ.html#licenseText" + }, + new Models.License + { + Id = 316, + Name = "Secure Messaging Protocol Public License", + SPDX = "SMPPL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SMPPL.html#licenseText" + }, + new Models.License + { + Id = 317, + Name = "SNIA Public License 1.1", + SPDX = "SNIA", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SNIA.html#licenseText" + }, + new Models.License + { + Id = 318, + Name = "Spencer License 86", + SPDX = "Spencer-86", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Spencer-86.html#licenseText" + }, + new Models.License + { + Id = 319, + Name = "Spencer License 94", + SPDX = "Spencer-94", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Spencer-94.html#licenseText" + }, + new Models.License + { + Id = 320, + Name = "Spencer License 99", + SPDX = "Spencer-99", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Spencer-99.html#licenseText" + }, + new Models.License + { + Id = 321, + Name = "Sun Public License v1.0", + SPDX = "SPL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/SPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 322, + Name = "SugarCRM Public License v1.1.3", + SPDX = "SugarCRM-1.1.3", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SugarCRM-1.1.3.html#licenseText" + }, + new Models.License + { + Id = 323, + Name = "Scheme Widget Library (SWL) Software License Agreement", + SPDX = "SWL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SWL.html#licenseText" + }, + new Models.License + { + Id = 324, + Name = "TAPR Open Hardware License v1.0", + SPDX = "TAPR-OHL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/TAPR-OHL-1.0.html#licenseText" + }, + new Models.License + { + Id = 325, + Name = "TCL/TK License", + SPDX = "TCL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/TCL.html#licenseText" + }, + new Models.License + { + Id = 326, + Name = "TCP Wrappers License", + SPDX = "TCP-wrappers", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/TCP-wrappers.html#licenseText" + }, + new Models.License + { + Id = 327, + Name = "TMate Open Source License", + SPDX = "TMate", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/TMate.html#licenseText" + }, + new Models.License + { + Id = 328, + Name = "TORQUE v2.5+ Software License v1.1", + SPDX = "TORQUE-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/TORQUE-1.1.html#licenseText" + }, + new Models.License + { + Id = 329, + Name = "Trusster Open Source License", + SPDX = "TOSL", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/TOSL.html#licenseText" + }, + new Models.License + { + Id = 330, + Name = "Technische Universitaet Berlin License 1.0", + SPDX = "TU-Berlin-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/TU-Berlin-1.0.html#licenseText" + }, + new Models.License + { + Id = 331, + Name = "Technische Universitaet Berlin License 2.0", + SPDX = "TU-Berlin-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/TU-Berlin-2.0.html#licenseText" + }, + new Models.License + { + Id = 332, + Name = "Unicode License Agreement - Data Files and Software (2015)", + SPDX = "Unicode-DFS-2015", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Unicode-DFS-2015.html#licenseText" + }, + new Models.License + { + Id = 333, + Name = "Unicode License Agreement - Data Files and Software (2016)", + SPDX = "Unicode-DFS-2016", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Unicode-DFS-2016.html#licenseText" + }, + new Models.License + { + Id = 334, + Name = "Unicode Terms of Use", + SPDX = "Unicode-TOU", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Unicode-TOU.html#licenseText" + }, + new Models.License + { + Id = 335, + Name = "The Unlicense", + SPDX = "Unlicense", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/Unlicense.html#licenseText" + }, + new Models.License + { + Id = 336, + Name = "Universal Permissive License v1.0", + SPDX = "UPL-1.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/UPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 337, + Name = "Vim License", + SPDX = "Vim", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/Vim.html#licenseText" + }, + new Models.License + { + Id = 338, + Name = "VOSTROM Public License for Open Source", + SPDX = "VOSTROM", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/VOSTROM.html#licenseText" + }, + new Models.License + { + Id = 339, + Name = "Vovida Software License v1.0", + SPDX = "VSL-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/VSL-1.0.html#licenseText" + }, + new Models.License + { + Id = 340, + Name = "W3C Software Notice and License (2002-12-31)", + SPDX = "W3C", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/W3C.html#licenseText" + }, + new Models.License + { + Id = 341, + Name = "W3C Software Notice and License (1998-07-20)", + SPDX = "W3C-19980720", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/W3C-19980720.html#licenseText" + }, + new Models.License + { + Id = 342, + Name = "W3C Software Notice and Document License (2015-05-13)", + SPDX = "W3C-20150513", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/W3C-20150513.html#licenseText" + }, + new Models.License + { + Id = 343, + Name = "Sybase Open Watcom Public License 1.0", + SPDX = "Watcom-1.0", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Watcom-1.0.html#licenseText" + }, + new Models.License + { + Id = 344, + Name = "Wsuipa License", + SPDX = "Wsuipa", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Wsuipa.html#licenseText" + }, + new Models.License + { + Id = 345, + Name = "Do What The F*ck You Want To Public License", + SPDX = "WTFPL", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/WTFPL.html#licenseText" + }, + new Models.License + { + Id = 346, + Name = "X11 License", + SPDX = "X11", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/X11.html#licenseText" + }, + new Models.License + { + Id = 347, + Name = "Xerox License", + SPDX = "Xerox", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Xerox.html#licenseText" + }, + new Models.License + { + Id = 348, + Name = "XFree86 License 1.1", + SPDX = "XFree86-1.1", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/XFree86-1.1.html#licenseText" + }, + new Models.License + { + Id = 349, + Name = "xinetd License", + SPDX = "xinetd", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/xinetd.html#licenseText" + }, + new Models.License + { + Id = 350, + Name = "X.Net License", + SPDX = "Xnet", + FsfApproved = false, + OsiApproved = true, + Link = "https://spdx.org/licenses/Xnet.html#licenseText" + }, + new Models.License + { + Id = 351, + Name = "XPP License", + SPDX = "xpp", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/xpp.html#licenseText" + }, + new Models.License + { + Id = 352, + Name = "XSkat License", + SPDX = "XSkat", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/XSkat.html#licenseText" + }, + new Models.License + { + Id = 353, + Name = "Yahoo! Public License v1.0", + SPDX = "YPL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/YPL-1.0.html#licenseText" + }, + new Models.License + { + Id = 354, + Name = "Yahoo! Public License v1.1", + SPDX = "YPL-1.1", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/YPL-1.1.html#licenseText" + }, + new Models.License + { + Id = 355, + Name = "Zed License", + SPDX = "Zed", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Zed.html#licenseText" + }, + new Models.License + { + Id = 356, + Name = "Zend License v2.0", + SPDX = "Zend-2.0", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/Zend-2.0.html#licenseText" + }, + new Models.License + { + Id = 357, + Name = "Zimbra Public License v1.3", + SPDX = "Zimbra-1.3", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/Zimbra-1.3.html#licenseText" + }, + new Models.License + { + Id = 358, + Name = "Zimbra Public License v1.4", + SPDX = "Zimbra-1.4", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Zimbra-1.4.html#licenseText" + }, + new Models.License + { + Id = 359, + Name = "zlib License", + SPDX = "Zlib", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/Zlib.html#licenseText" + }, + new Models.License + { + Id = 360, + Name = "zlib/libpng License with Acknowledgement", + SPDX = "zlib-acknowledgement", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/zlib-acknowledgement.html#licenseText" + }, + new Models.License + { + Id = 361, + Name = "Zope Public License 1.1", + SPDX = "ZPL-1.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/ZPL-1.1.html#licenseText" + }, + new Models.License + { + Id = 362, + Name = "Zope Public License 2.0", + SPDX = "ZPL-2.0", + FsfApproved = true, + OsiApproved = true, + Link = "https://spdx.org/licenses/ZPL-2.0.html#licenseText" + }, + new Models.License + { + Id = 363, + Name = "Zope Public License 2.1", + SPDX = "ZPL-2.1", + FsfApproved = true, + OsiApproved = false, + Link = "https://spdx.org/licenses/ZPL-2.1.html#licenseText" + }, + new Models.License + { + Id = 364, + Name = "Public domain", + SPDX = null, + FsfApproved = true, + OsiApproved = false, + Link = null + }, + new Models.License + { + Id = 365, + Name = "Cryptographic Autonomy License 1.0", + SPDX = "CAL-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CAL-1.0.html" + }, + new Models.License + { + Id = 366, + Name = "Cryptographic Autonomy License 1.0 (Combined Work Exception)", + SPDX = "CAL-1.0-Combined-Work-Exception", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CAL-1.0-Combined-Work-Exception.html" + }, + new Models.License + { + Id = 367, + Name = "CERN Open Hardware Licence Version 2 - Permissive", + SPDX = "CERN-OHL-P-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CERN-OHL-P-2.0.html" + }, + new Models.License + { + Id = 368, + Name = "CERN Open Hardware Licence Version 2 - Strongly Reciprocal", + SPDX = "CERN-OHL-S-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CERN-OHL-S-2.0.html" + }, + new Models.License + { + Id = 369, + Name = "CERN Open Hardware Licence Version 2 - Weakly Reciprocal", + SPDX = "CERN-OHL-W-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/CERN-OHL-W-2.0.html" + }, + new Models.License + { + Id = 370, + Name = "Hippocratic License 2.1", + SPDX = "Hippocratic-2.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Hippocratic-2.1.html" + }, + new Models.License + { + Id = 371, + Name = "LGPL-3.0 Linking Exception", + SPDX = "LGPL-3.0-linking-exception", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/LGPL-3.0-linking-exception.html" + }, + new Models.License + { + Id = 372, + Name = "Mulan Permissive Software License, Version 2", + SPDX = "MulanPSL-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/MulanPSL-2.0.html" + }, + new Models.License + { + Id = 373, + Name = "Non-Commercial Government Licence", + SPDX = "NCGL-UK-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/NCGL-UK-2.0.html" + }, + new Models.License + { + Id = 374, + Name = "Open Use of Data Agreement v1.0", + SPDX = "O-UDA-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/O-UDA-1.0.html" + }, + new Models.License + { + Id = 375, + Name = "OGC Software License, Version 1.0", + SPDX = "OGC-1.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/OGC-1.0.html" + }, + new Models.License + { + Id = 376, + Name = "The Parity Public License 7.0.0", + SPDX = "Parity-7.0.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/Parity-7.0.0.html" + }, + new Models.License + { + Id = 377, + Name = "PolyForm Noncommercial License 1.0.0", + SPDX = "PolyForm-Noncommercial-1.0.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/PolyForm-Noncommercial-1.0.0.html" + }, + new Models.License + { + Id = 378, + Name = "PolyForm Small Business License 1.0.0", + SPDX = "PolyForm-Small-Business-1.0.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/PolyForm-Small-Business-1.0.0.html" + }, + new Models.License + { + Id = 379, + Name = "Solderpad Hardware License v2.0", + SPDX = "SHL-2.0", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SHL-2.0.html" + }, + new Models.License + { + Id = 380, + Name = "Solderpad Hardware License v2.1", + SPDX = "SHL-2.1", + FsfApproved = false, + OsiApproved = false, + Link = "https://spdx.org/licenses/SHL-2.1.html" + } + }) { - List existingLicenses = context.Licenses.ToList(); - List newLicenses = new(); - int updatedLicencesCount = 0; + Models.License existingLicense = existingLicenses.FirstOrDefault(r => r.Id == license.Id); - foreach(Models.License license in new[] + if(existingLicense is null) + newLicenses.Add(license); + else { - new Models.License + var changed = false; + + if(license.Name != existingLicense.Name) { - Id = 1, - Name = "Fair use", - FsfApproved = false, - OsiApproved = false - }, - new Models.License - { - Id = 2, - Name = "Advertisement use", - FsfApproved = false, - OsiApproved = false - }, - new Models.License - { - Id = 3, - Name = "All rights reserved", - FsfApproved = false, - OsiApproved = false - }, - new Models.License - { - Id = 4, - Name = "BSD Zero Clause License", - SPDX = "0BSD", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/0BSD.html#licenseText" - }, - new Models.License - { - Id = 5, - Name = "Attribution Assurance License", - SPDX = "AAL", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/AAL.html#licenseText" - }, - new Models.License - { - Id = 6, - Name = "Abstyles License", - SPDX = "Abstyles", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Abstyles.html#licenseText" - }, - new Models.License - { - Id = 7, - Name = "Adobe Systems Incorporated Source Code License Agreement", - SPDX = "Adobe-2006", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Adobe-2006.html#licenseText" - }, - new Models.License - { - Id = 8, - Name = "Adobe Glyph List License", - SPDX = "Adobe-Glyph", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Adobe-Glyph.html#licenseText" - }, - new Models.License - { - Id = 9, - Name = "Amazon Digital Services License", - SPDX = "ADSL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/ADSL.html#licenseText" - }, - new Models.License - { - Id = 10, - Name = "Academic Free License v1.1", - SPDX = "AFL-1.1", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/AFL-1.1.html#licenseText" - }, - new Models.License - { - Id = 11, - Name = "Academic Free License v1.2", - SPDX = "AFL-1.2", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/AFL-1.2.html#licenseText" - }, - new Models.License - { - Id = 12, - Name = "Academic Free License v2.0", - SPDX = "AFL-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/AFL-2.0.html#licenseText" - }, - new Models.License - { - Id = 13, - Name = "Academic Free License v2.1", - SPDX = "AFL-2.1", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/AFL-2.1.html#licenseText" - }, - new Models.License - { - Id = 14, - Name = "Academic Free License v3.0", - SPDX = "AFL-3.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/AFL-3.0.html#licenseText" - }, - new Models.License - { - Id = 15, - Name = "Afmparse License", - SPDX = "Afmparse", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Afmparse.html#licenseText" - }, - new Models.License - { - Id = 16, - Name = "Affero General Public License v1.0 only", - SPDX = "AGPL-1.0-only", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/AGPL-1.0-only.html#licenseText" - }, - new Models.License - { - Id = 17, - Name = "Affero General Public License v1.0 or later", - SPDX = "AGPL-1.0-or-later", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/AGPL-1.0-or-later.html#licenseText" - }, - new Models.License - { - Id = 18, - Name = "GNU Affero General Public License v3.0 only", - SPDX = "AGPL-3.0-only", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/AGPL-3.0-only.html#licenseText" - }, - new Models.License - { - Id = 19, - Name = "GNU Affero General Public License v3.0 or later", - SPDX = "AGPL-3.0-or-later", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/AGPL-3.0-or-later.html#licenseText" - }, - new Models.License - { - Id = 20, - Name = "Aladdin Free Public License", - SPDX = "Aladdin", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Aladdin.html#licenseText" - }, - new Models.License - { - Id = 21, - Name = "AMD's plpa_map.c License", - SPDX = "AMDPLPA", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/AMDPLPA.html#licenseText" - }, - new Models.License - { - Id = 22, - Name = "Apple MIT License", - SPDX = "AML", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/AML.html#licenseText" - }, - new Models.License - { - Id = 23, - Name = "Academy of Motion Picture Arts and Sciences BSD", - SPDX = "AMPAS", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/AMPAS.html#licenseText" - }, - new Models.License - { - Id = 24, - Name = "ANTLR Software Rights Notice", - SPDX = "ANTLR-PD", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/ANTLR-PD.html#licenseText" - }, - new Models.License - { - Id = 25, - Name = "Apache License 1.0", - SPDX = "Apache-1.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/Apache-1.0.html#licenseText" - }, - new Models.License - { - Id = 26, - Name = "Apache License 1.1", - SPDX = "Apache-1.1", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/Apache-1.1.html#licenseText" - }, - new Models.License - { - Id = 27, - Name = "Apache License 2.0", - SPDX = "Apache-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/Apache-2.0.html#licenseText" - }, - new Models.License - { - Id = 28, - Name = "Adobe Postscript AFM License", - SPDX = "APAFML", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/APAFML.html#licenseText" - }, - new Models.License - { - Id = 29, - Name = "Adaptive Public License 1.0", - SPDX = "APL-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/APL-1.0.html#licenseText" - }, - new Models.License - { - Id = 30, - Name = "Apple Public Source License 1.0", - SPDX = "APSL-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/APSL-1.0.html#licenseText" - }, - new Models.License - { - Id = 31, - Name = "Apple Public Source License 1.1", - SPDX = "APSL-1.1", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/APSL-1.1.html#licenseText" - }, - new Models.License - { - Id = 32, - Name = "Apple Public Source License 1.2", - SPDX = "APSL-1.2", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/APSL-1.2.html#licenseText" - }, - new Models.License - { - Id = 33, - Name = "Apple Public Source License 2.0", - SPDX = "APSL-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/APSL-2.0.html#licenseText" - }, - new Models.License - { - Id = 34, - Name = "Artistic License 1.0", - SPDX = "Artistic-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Artistic-1.0.html#licenseText" - }, - new Models.License - { - Id = 35, - Name = "Artistic License 1.0 w/clause 8", - SPDX = "Artistic-1.0-cl8", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Artistic-1.0-cl8.html#licenseText" - }, - new Models.License - { - Id = 36, - Name = "Artistic License 1.0 (Perl)", - SPDX = "Artistic-1.0-Perl", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Artistic-1.0-Perl.html#licenseText" - }, - new Models.License - { - Id = 37, - Name = "Artistic License 2.0", - SPDX = "Artistic-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/Artistic-2.0.html#licenseText" - }, - new Models.License - { - Id = 38, - Name = "Bahyph License", - SPDX = "Bahyph", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Bahyph.html#licenseText" - }, - new Models.License - { - Id = 39, - Name = "Barr License", - SPDX = "Barr", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Barr.html#licenseText" - }, - new Models.License - { - Id = 40, - Name = "Beerware License", - SPDX = "Beerware", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Beerware.html#licenseText" - }, - new Models.License - { - Id = 41, - Name = "BitTorrent Open Source License v1.0", - SPDX = "BitTorrent-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BitTorrent-1.0.html#licenseText" - }, - new Models.License - { - Id = 42, - Name = "BitTorrent Open Source License v1.1", - SPDX = "BitTorrent-1.1", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/BitTorrent-1.1.html#licenseText" - }, - new Models.License - { - Id = 43, - Name = "Borceux license", - SPDX = "Borceux", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Borceux.html#licenseText" - }, - new Models.License - { - Id = 44, - Name = "BSD 1-Clause License", - SPDX = "BSD-1-Clause", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-1-Clause.html#licenseText" - }, - new Models.License - { - Id = 45, - Name = "BSD 2-Clause \"Simplified\" License", - SPDX = "BSD-2-Clause", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/BSD-2-Clause.html#licenseText" - }, - new Models.License - { - Id = 46, - Name = "BSD 2-Clause FreeBSD License", - SPDX = "BSD-2-Clause-FreeBSD", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-2-Clause-FreeBSD.html#licenseText" - }, - new Models.License - { - Id = 47, - Name = "BSD 2-Clause NetBSD License", - SPDX = "BSD-2-Clause-NetBSD", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-2-Clause-NetBSD.html#licenseText" - }, - new Models.License - { - Id = 48, - Name = "BSD-2-Clause Plus Patent License", - SPDX = "BSD-2-Clause-Patent", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/BSD-2-Clause-Patent.html#licenseText" - }, - new Models.License - { - Id = 49, - Name = "BSD 3-Clause \"New\" or \"Revised\" License", - SPDX = "BSD-3-Clause", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/BSD-3-Clause.html#licenseText" - }, - new Models.License - { - Id = 50, - Name = "BSD with attribution", - SPDX = "BSD-3-Clause-Attribution", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-3-Clause-Attribution.html#licenseText" - }, - new Models.License - { - Id = 51, - Name = "BSD 3-Clause Clear License", - SPDX = "BSD-3-Clause-Clear", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-3-Clause-Clear.html#licenseText" - }, - new Models.License - { - Id = 52, - Name = "Lawrence Berkeley National Labs BSD variant license", - SPDX = "BSD-3-Clause-LBNL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-3-Clause-LBNL.html#licenseText" - }, - new Models.License - { - Id = 53, - Name = "BSD 3-Clause No Nuclear License", - SPDX = "BSD-3-Clause-No-Nuclear-License", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-3-Clause-No-Nuclear-License.html#licenseText" - }, - new Models.License - { - Id = 54, - Name = "BSD 3-Clause No Nuclear License 2014", - SPDX = "BSD-3-Clause-No-Nuclear-License-2014", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-3-Clause-No-Nuclear-License-2014.html#licenseText" - }, - new Models.License - { - Id = 55, - Name = "BSD 3-Clause No Nuclear Warranty", - SPDX = "BSD-3-Clause-No-Nuclear-Warranty", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-3-Clause-No-Nuclear-Warranty.html#licenseText" - }, - new Models.License - { - Id = 56, - Name = "BSD 4-Clause \"Original\" or \"Old\" License", - SPDX = "BSD-4-Clause", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-4-Clause.html#licenseText" - }, - new Models.License - { - Id = 57, - Name = "BSD-4-Clause (University of California-Specific)", - SPDX = "BSD-4-Clause-UC", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-4-Clause-UC.html#licenseText" - }, - new Models.License - { - Id = 58, - Name = "BSD Protection License", - SPDX = "BSD-Protection", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-Protection.html#licenseText" - }, - new Models.License - { - Id = 59, - Name = "BSD Source Code Attribution", - SPDX = "BSD-Source-Code", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/BSD-Source-Code.html#licenseText" - }, - new Models.License - { - Id = 60, - Name = "Boost Software License 1.0", - SPDX = "BSL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/BSL-1.0.html#licenseText" - }, - new Models.License - { - Id = 61, - Name = "bzip2 and libbzip2 License v1.0.5", - SPDX = "bzip2-1.0.5", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/bzip2-1.0.5.html#licenseText" - }, - new Models.License - { - Id = 62, - Name = "bzip2 and libbzip2 License v1.0.6", - SPDX = "bzip2-1.0.6", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/bzip2-1.0.6.html#licenseText" - }, - new Models.License - { - Id = 63, - Name = "Caldera License", - SPDX = "Caldera", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Caldera.html#licenseText" - }, - new Models.License - { - Id = 64, - Name = "Computer Associates Trusted Open Source License 1.1", - SPDX = "CATOSL-1.1", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/CATOSL-1.1.html#licenseText" - }, - new Models.License - { - Id = 65, - Name = "Creative Commons Attribution 1.0 Generic", - SPDX = "CC-BY-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-1.0.html#licenseText" - }, - new Models.License - { - Id = 66, - Name = "Creative Commons Attribution 2.0 Generic", - SPDX = "CC-BY-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-2.0.html#licenseText" - }, - new Models.License - { - Id = 67, - Name = "Creative Commons Attribution 2.5 Generic", - SPDX = "CC-BY-2.5", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-2.5.html#licenseText" - }, - new Models.License - { - Id = 68, - Name = "Creative Commons Attribution 3.0 Unported", - SPDX = "CC-BY-3.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-3.0.html#licenseText" - }, - new Models.License - { - Id = 69, - Name = "Creative Commons Attribution 4.0 International", - SPDX = "CC-BY-4.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-4.0.html#licenseText" - }, - new Models.License - { - Id = 70, - Name = "Creative Commons Attribution Non Commercial 1.0 Generic", - SPDX = "CC-BY-NC-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-1.0.html#licenseText" - }, - new Models.License - { - Id = 71, - Name = "Creative Commons Attribution Non Commercial 2.0 Generic", - SPDX = "CC-BY-NC-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-2.0.html#licenseText" - }, - new Models.License - { - Id = 72, - Name = "Creative Commons Attribution Non Commercial 2.5 Generic", - SPDX = "CC-BY-NC-2.5", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-2.5.html#licenseText" - }, - new Models.License - { - Id = 73, - Name = "Creative Commons Attribution Non Commercial 3.0 Unported", - SPDX = "CC-BY-NC-3.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-3.0.html#licenseText" - }, - new Models.License - { - Id = 74, - Name = "Creative Commons Attribution Non Commercial 4.0 International", - SPDX = "CC-BY-NC-4.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-4.0.html#licenseText" - }, - new Models.License - { - Id = 75, - Name = "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic", - SPDX = "CC-BY-NC-ND-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-ND-1.0.html#licenseText" - }, - new Models.License - { - Id = 76, - Name = "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic", - SPDX = "CC-BY-NC-ND-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-ND-2.0.html#licenseText" - }, - new Models.License - { - Id = 77, - Name = "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic", - SPDX = "CC-BY-NC-ND-2.5", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-ND-2.5.html#licenseText" - }, - new Models.License - { - Id = 78, - Name = "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported", - SPDX = "CC-BY-NC-ND-3.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-ND-3.0.html#licenseText" - }, - new Models.License - { - Id = 79, - Name = "Creative Commons Attribution Non Commercial No Derivatives 4.0 International", - SPDX = "CC-BY-NC-ND-4.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-ND-4.0.html#licenseText" - }, - new Models.License - { - Id = 80, - Name = "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic", - SPDX = "CC-BY-NC-SA-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-SA-1.0.html#licenseText" - }, - new Models.License - { - Id = 81, - Name = "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic", - SPDX = "CC-BY-NC-SA-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-SA-2.0.html#licenseText" - }, - new Models.License - { - Id = 82, - Name = "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic", - SPDX = "CC-BY-NC-SA-2.5", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-SA-2.5.html#licenseText" - }, - new Models.License - { - Id = 83, - Name = "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported", - SPDX = "CC-BY-NC-SA-3.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-SA-3.0.html#licenseText" - }, - new Models.License - { - Id = 84, - Name = "Creative Commons Attribution Non Commercial Share Alike 4.0 International", - SPDX = "CC-BY-NC-SA-4.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-NC-SA-4.0.html#licenseText" - }, - new Models.License - { - Id = 85, - Name = "Creative Commons Attribution No Derivatives 1.0 Generic", - SPDX = "CC-BY-ND-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-ND-1.0.html#licenseText" - }, - new Models.License - { - Id = 86, - Name = "Creative Commons Attribution No Derivatives 2.0 Generic", - SPDX = "CC-BY-ND-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-ND-2.0.html#licenseText" - }, - new Models.License - { - Id = 87, - Name = "Creative Commons Attribution No Derivatives 2.5 Generic", - SPDX = "CC-BY-ND-2.5", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-ND-2.5.html#licenseText" - }, - new Models.License - { - Id = 88, - Name = "Creative Commons Attribution No Derivatives 3.0 Unported", - SPDX = "CC-BY-ND-3.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-ND-3.0.html#licenseText" - }, - new Models.License - { - Id = 89, - Name = "Creative Commons Attribution No Derivatives 4.0 International", - SPDX = "CC-BY-ND-4.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-ND-4.0.html#licenseText" - }, - new Models.License - { - Id = 90, - Name = "Creative Commons Attribution Share Alike 1.0 Generic", - SPDX = "CC-BY-SA-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-SA-1.0.html#licenseText" - }, - new Models.License - { - Id = 91, - Name = "Creative Commons Attribution Share Alike 2.0 Generic", - SPDX = "CC-BY-SA-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-SA-2.0.html#licenseText" - }, - new Models.License - { - Id = 92, - Name = "Creative Commons Attribution Share Alike 2.5 Generic", - SPDX = "CC-BY-SA-2.5", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-SA-2.5.html#licenseText" - }, - new Models.License - { - Id = 93, - Name = "Creative Commons Attribution Share Alike 3.0 Unported", - SPDX = "CC-BY-SA-3.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-SA-3.0.html#licenseText" - }, - new Models.License - { - Id = 94, - Name = "Creative Commons Attribution Share Alike 4.0 International", - SPDX = "CC-BY-SA-4.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC-BY-SA-4.0.html#licenseText" - }, - new Models.License - { - Id = 95, - Name = "Creative Commons Zero v1.0 Universal", - SPDX = "CC0-1.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/CC0-1.0.html#licenseText" - }, - new Models.License - { - Id = 96, - Name = "Common Development and Distribution License 1.0", - SPDX = "CDDL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/CDDL-1.0.html#licenseText" - }, - new Models.License - { - Id = 97, - Name = "Common Development and Distribution License 1.1", - SPDX = "CDDL-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CDDL-1.1.html#licenseText" - }, - new Models.License - { - Id = 98, - Name = "Community Data License Agreement Permissive 1.0", - SPDX = "CDLA-Permissive-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CDLA-Permissive-1.0.html#licenseText" - }, - new Models.License - { - Id = 99, - Name = "Community Data License Agreement Sharing 1.0", - SPDX = "CDLA-Sharing-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CDLA-Sharing-1.0.html#licenseText" - }, - new Models.License - { - Id = 100, - Name = "CeCILL Free Software License Agreement v1.0", - SPDX = "CECILL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CECILL-1.0.html#licenseText" - }, - new Models.License - { - Id = 101, - Name = "CeCILL Free Software License Agreement v1.1", - SPDX = "CECILL-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CECILL-1.1.html#licenseText" - }, - new Models.License - { - Id = 102, - Name = "CeCILL Free Software License Agreement v2.0", - SPDX = "CECILL-2.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/CECILL-2.0.html#licenseText" - }, - new Models.License - { - Id = 103, - Name = "CeCILL Free Software License Agreement v2.1", - SPDX = "CECILL-2.1", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/CECILL-2.1.html#licenseText" - }, - new Models.License - { - Id = 104, - Name = "CeCILL-B Free Software License Agreement", - SPDX = "CECILL-B", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/CECILL-B.html#licenseText" - }, - new Models.License - { - Id = 105, - Name = "CeCILL-C Free Software License Agreement", - SPDX = "CECILL-C", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/CECILL-C.html#licenseText" - }, - new Models.License - { - Id = 106, - Name = "CERN Open Hardware License v1.1", - SPDX = "CERN-OHL-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CERN-OHL-1.1.html#licenseText" - }, - new Models.License - { - Id = 107, - Name = "CERN Open Hardware Licence v1.2", - SPDX = "CERN-OHL-1.2", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CERN-OHL-1.2.html#licenseText" - }, - new Models.License - { - Id = 108, - Name = "Clarified Artistic License", - SPDX = "ClArtistic", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/ClArtistic.html#licenseText" - }, - new Models.License - { - Id = 109, - Name = "CNRI Jython License", - SPDX = "CNRI-Jython", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CNRI-Jython.html#licenseText" - }, - new Models.License - { - Id = 110, - Name = "CNRI Python License", - SPDX = "CNRI-Python", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/CNRI-Python.html#licenseText" - }, - new Models.License - { - Id = 111, - Name = "CNRI Python Open Source GPL Compatible License Agreement", - SPDX = "CNRI-Python-GPL-Compatible", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CNRI-Python-GPL-Compatible.html#licenseText" - }, - new Models.License - { - Id = 112, - Name = "Condor Public License v1.1", - SPDX = "Condor-1.1", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/Condor-1.1.html#licenseText" - }, - new Models.License - { - Id = 113, - Name = "copyleft-next 0.3.0", - SPDX = "copyleft-next-0.3.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/copyleft-next-0.3.0.html#licenseText" - }, - new Models.License - { - Id = 114, - Name = "copyleft-next 0.3.1", - SPDX = "copyleft-next-0.3.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/copyleft-next-0.3.1.html#licenseText" - }, - new Models.License - { - Id = 115, - Name = "Common Public Attribution License 1.0", - SPDX = "CPAL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/CPAL-1.0.html#licenseText" - }, - new Models.License - { - Id = 116, - Name = "Common Public License 1.0", - SPDX = "CPL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/CPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 117, - Name = "Code Project Open License 1.02", - SPDX = "CPOL-1.02", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CPOL-1.02.html#licenseText" - }, - new Models.License - { - Id = 118, - Name = "Crossword License", - SPDX = "Crossword", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Crossword.html#licenseText" - }, - new Models.License - { - Id = 119, - Name = "CrystalStacker License", - SPDX = "CrystalStacker", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CrystalStacker.html#licenseText" - }, - new Models.License - { - Id = 120, - Name = "CUA Office Public License v1.0", - SPDX = "CUA-OPL-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/CUA-OPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 121, - Name = "Cube License", - SPDX = "Cube", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Cube.html#licenseText" - }, - new Models.License - { - Id = 122, - Name = "curl License", - SPDX = "curl", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/curl.html#licenseText" - }, - new Models.License - { - Id = 123, - Name = "Deutsche Freie Software Lizenz", - SPDX = "D-FSL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/D-FSL-1.0.html#licenseText" - }, - new Models.License - { - Id = 124, - Name = "diffmark license", - SPDX = "diffmark", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/diffmark.html#licenseText" - }, - new Models.License - { - Id = 125, - Name = "DOC License", - SPDX = "DOC", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/DOC.html#licenseText" - }, - new Models.License - { - Id = 126, - Name = "Dotseqn License", - SPDX = "Dotseqn", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Dotseqn.html#licenseText" - }, - new Models.License - { - Id = 127, - Name = "DSDP License", - SPDX = "DSDP", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/DSDP.html#licenseText" - }, - new Models.License - { - Id = 128, - Name = "dvipdfm License", - SPDX = "dvipdfm", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/dvipdfm.html#licenseText" - }, - new Models.License - { - Id = 129, - Name = "Educational Community License v1.0", - SPDX = "ECL-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/ECL-1.0.html#licenseText" - }, - new Models.License - { - Id = 130, - Name = "Educational Community License v2.0", - SPDX = "ECL-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/ECL-2.0.html#licenseText" - }, - new Models.License - { - Id = 131, - Name = "Eiffel Forum License v1.0", - SPDX = "EFL-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/EFL-1.0.html#licenseText" - }, - new Models.License - { - Id = 132, - Name = "Eiffel Forum License v2.0", - SPDX = "EFL-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/EFL-2.0.html#licenseText" - }, - new Models.License - { - Id = 133, - Name = "eGenix.com Public License 1.1.0", - SPDX = "eGenix", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/eGenix.html#licenseText" - }, - new Models.License - { - Id = 134, - Name = "Entessa Public License v1.0", - SPDX = "Entessa", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Entessa.html#licenseText" - }, - new Models.License - { - Id = 135, - Name = "Eclipse Public License 1.0", - SPDX = "EPL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/EPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 136, - Name = "Eclipse Public License 2.0", - SPDX = "EPL-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/EPL-2.0.html#licenseText" - }, - new Models.License - { - Id = 137, - Name = "Erlang Public License v1.1", - SPDX = "ErlPL-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/ErlPL-1.1.html#licenseText" - }, - new Models.License - { - Id = 138, - Name = "EU DataGrid Software License", - SPDX = "EUDatagrid", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/EUDatagrid.html#licenseText" - }, - new Models.License - { - Id = 139, - Name = "European Union Public License 1.0", - SPDX = "EUPL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/EUPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 140, - Name = "European Union Public License 1.1", - SPDX = "EUPL-1.1", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/EUPL-1.1.html#licenseText" - }, - new Models.License - { - Id = 141, - Name = "European Union Public License 1.2", - SPDX = "EUPL-1.2", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/EUPL-1.2.html#licenseText" - }, - new Models.License - { - Id = 142, - Name = "Eurosym License", - SPDX = "Eurosym", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Eurosym.html#licenseText" - }, - new Models.License - { - Id = 143, - Name = "Fair License", - SPDX = "Fair", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Fair.html#licenseText" - }, - new Models.License - { - Id = 144, - Name = "Frameworx Open License 1.0", - SPDX = "Frameworx-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Frameworx-1.0.html#licenseText" - }, - new Models.License - { - Id = 145, - Name = "FreeImage Public License v1.0", - SPDX = "FreeImage", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/FreeImage.html#licenseText" - }, - new Models.License - { - Id = 146, - Name = "FSF All Permissive License", - SPDX = "FSFAP", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/FSFAP.html#licenseText" - }, - new Models.License - { - Id = 147, - Name = "FSF Unlimited License", - SPDX = "FSFUL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/FSFUL.html#licenseText" - }, - new Models.License - { - Id = 148, - Name = "FSF Unlimited License (with License Retention)", - SPDX = "FSFULLR", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/FSFULLR.html#licenseText" - }, - new Models.License - { - Id = 149, - Name = "Freetype Project License", - SPDX = "FTL", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/FTL.html#licenseText" - }, - new Models.License - { - Id = 150, - Name = "GNU Free Documentation License v1.1 only", - SPDX = "GFDL-1.1-only", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/GFDL-1.1-only.html#licenseText" - }, - new Models.License - { - Id = 151, - Name = "GNU Free Documentation License v1.1 or later", - SPDX = "GFDL-1.1-or-later", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/GFDL-1.1-or-later.html#licenseText" - }, - new Models.License - { - Id = 152, - Name = "GNU Free Documentation License v1.2 only", - SPDX = "GFDL-1.2-only", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/GFDL-1.2-only.html#licenseText" - }, - new Models.License - { - Id = 153, - Name = "GNU Free Documentation License v1.2 or later", - SPDX = "GFDL-1.2-or-later", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/GFDL-1.2-or-later.html#licenseText" - }, - new Models.License - { - Id = 154, - Name = "GNU Free Documentation License v1.3 only", - SPDX = "GFDL-1.3-only", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/GFDL-1.3-only.html#licenseText" - }, - new Models.License - { - Id = 155, - Name = "GNU Free Documentation License v1.3 or later", - SPDX = "GFDL-1.3-or-later", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/GFDL-1.3-or-later.html#licenseText" - }, - new Models.License - { - Id = 156, - Name = "Giftware License", - SPDX = "Giftware", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Giftware.html#licenseText" - }, - new Models.License - { - Id = 157, - Name = "GL2PS License", - SPDX = "GL2PS", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/GL2PS.html#licenseText" - }, - new Models.License - { - Id = 158, - Name = "3dfx Glide License", - SPDX = "Glide", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Glide.html#licenseText" - }, - new Models.License - { - Id = 159, - Name = "Glulxe License", - SPDX = "Glulxe", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Glulxe.html#licenseText" - }, - new Models.License - { - Id = 160, - Name = "gnuplot License", - SPDX = "gnuplot", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/gnuplot.html#licenseText" - }, - new Models.License - { - Id = 161, - Name = "GNU General Public License v1.0 only", - SPDX = "GPL-1.0-only", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/GPL-1.0-only.html#licenseText" - }, - new Models.License - { - Id = 162, - Name = "GNU General Public License v1.0 or later", - SPDX = "GPL-1.0-or-later", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/GPL-1.0-or-later.html#licenseText" - }, - new Models.License - { - Id = 163, - Name = "GNU General Public License v2.0 only", - SPDX = "GPL-2.0-only", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/GPL-2.0-only.html#licenseText" - }, - new Models.License - { - Id = 164, - Name = "GNU General Public License v2.0 or later", - SPDX = "GPL-2.0-or-later", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText" - }, - new Models.License - { - Id = 165, - Name = "GNU General Public License v3.0 only", - SPDX = "GPL-3.0-only", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/GPL-3.0-only.html#licenseText" - }, - new Models.License - { - Id = 166, - Name = "GNU General Public License v3.0 or later", - SPDX = "GPL-3.0-or-later", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/GPL-3.0-or-later.html#licenseText" - }, - new Models.License - { - Id = 167, - Name = "gSOAP Public License v1.3b", - SPDX = "gSOAP-1.3b", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/gSOAP-1.3b.html#licenseText" - }, - new Models.License - { - Id = 168, - Name = "Haskell Language Report License", - SPDX = "HaskellReport", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/HaskellReport.html#licenseText" - }, - new Models.License - { - Id = 169, - Name = "Historical Permission Notice and Disclaimer", - SPDX = "HPND", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/HPND.html#licenseText" - }, - new Models.License - { - Id = 170, - Name = "Historical Permission Notice and Disclaimer - sell variant", - SPDX = "HPND-sell-variant", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/HPND-sell-variant.html#licenseText" - }, - new Models.License - { - Id = 171, - Name = "IBM PowerPC Initialization and Boot Software", - SPDX = "IBM-pibs", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/IBM-pibs.html#licenseText" - }, - new Models.License - { - Id = 172, - Name = "ICU License", - SPDX = "ICU", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/ICU.html#licenseText" - }, - new Models.License - { - Id = 173, - Name = "Independent JPEG Group License", - SPDX = "IJG", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/IJG.html#licenseText" - }, - new Models.License - { - Id = 174, - Name = "ImageMagick License", - SPDX = "ImageMagick", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/ImageMagick.html#licenseText" - }, - new Models.License - { - Id = 175, - Name = "iMatix Standard Function Library Agreement", - SPDX = "iMatix", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/iMatix.html#licenseText" - }, - new Models.License - { - Id = 176, - Name = "Imlib2 License", - SPDX = "Imlib2", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/Imlib2.html#licenseText" - }, - new Models.License - { - Id = 177, - Name = "Info-ZIP License", - SPDX = "Info-ZIP", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Info-ZIP.html#licenseText" - }, - new Models.License - { - Id = 178, - Name = "Intel Open Source License", - SPDX = "Intel", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/Intel.html#licenseText" - }, - new Models.License - { - Id = 179, - Name = "Intel ACPI Software License Agreement", - SPDX = "Intel-ACPI", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Intel-ACPI.html#licenseText" - }, - new Models.License - { - Id = 180, - Name = "Interbase Public License v1.0", - SPDX = "Interbase-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Interbase-1.0.html#licenseText" - }, - new Models.License - { - Id = 181, - Name = "IPA Font License", - SPDX = "IPA", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/IPA.html#licenseText" - }, - new Models.License - { - Id = 182, - Name = "IBM Public License v1.0", - SPDX = "IPL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/IPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 183, - Name = "ISC License", - SPDX = "ISC", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/ISC.html#licenseText" - }, - new Models.License - { - Id = 184, - Name = "JasPer License", - SPDX = "JasPer-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/JasPer-2.0.html#licenseText" - }, - new Models.License - { - Id = 185, - Name = "Japan Network Information Center License", - SPDX = "JPNIC", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/JPNIC.html#licenseText" - }, - new Models.License - { - Id = 186, - Name = "JSON License", - SPDX = "JSON", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/JSON.html#licenseText" - }, - new Models.License - { - Id = 187, - Name = "Licence Art Libre 1.2", - SPDX = "LAL-1.2", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/LAL-1.2.html#licenseText" - }, - new Models.License - { - Id = 188, - Name = "Licence Art Libre 1.3", - SPDX = "LAL-1.3", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/LAL-1.3.html#licenseText" - }, - new Models.License - { - Id = 189, - Name = "Latex2e License", - SPDX = "Latex2e", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Latex2e.html#licenseText" - }, - new Models.License - { - Id = 190, - Name = "Leptonica License", - SPDX = "Leptonica", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Leptonica.html#licenseText" - }, - new Models.License - { - Id = 191, - Name = "GNU Library General Public License v2 only", - SPDX = "LGPL-2.0-only", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/LGPL-2.0-only.html#licenseText" - }, - new Models.License - { - Id = 192, - Name = "GNU Library General Public License v2 or later", - SPDX = "LGPL-2.0-or-later", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/LGPL-2.0-or-later.html#licenseText" - }, - new Models.License - { - Id = 193, - Name = "GNU Lesser General Public License v2.1 only", - SPDX = "LGPL-2.1-only", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/LGPL-2.1-only.html#licenseText" - }, - new Models.License - { - Id = 194, - Name = "GNU Lesser General Public License v2.1 or later", - SPDX = "LGPL-2.1-or-later", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/LGPL-2.1-or-later.html#licenseText" - }, - new Models.License - { - Id = 195, - Name = "GNU Lesser General Public License v3.0 only", - SPDX = "LGPL-3.0-only", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/LGPL-3.0-only.html#licenseText" - }, - new Models.License - { - Id = 196, - Name = "GNU Lesser General Public License v3.0 or later", - SPDX = "LGPL-3.0-or-later", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/LGPL-3.0-or-later.html#licenseText" - }, - new Models.License - { - Id = 197, - Name = "Lesser General Public License For Linguistic Resources", - SPDX = "LGPLLR", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/LGPLLR.html#licenseText" - }, - new Models.License - { - Id = 198, - Name = "libpng License", - SPDX = "Libpng", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Libpng.html#licenseText" - }, - new Models.License - { - Id = 199, - Name = "PNG Reference Library version 2", - SPDX = "libpng-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/libpng-2.0.html#licenseText" - }, - new Models.License - { - Id = 200, - Name = "libtiff License", - SPDX = "libtiff", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/libtiff.html#licenseText" - }, - new Models.License - { - Id = 201, - Name = "Licence Libre du Québec – Permissive version 1.1", - SPDX = "LiLiQ-P-1.1", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/LiLiQ-P-1.1.html#licenseText" - }, - new Models.License - { - Id = 202, - Name = "Licence Libre du Québec – Réciprocité version 1.1", - SPDX = "LiLiQ-R-1.1", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/LiLiQ-R-1.1.html#licenseText" - }, - new Models.License - { - Id = 203, - Name = "Licence Libre du Québec – Réciprocité forte version 1.1", - SPDX = "LiLiQ-Rplus-1.1", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/LiLiQ-Rplus-1.1.html#licenseText" - }, - new Models.License - { - Id = 204, - Name = "Linux Kernel Variant of OpenIB.org license", - SPDX = "Linux-OpenIB", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Linux-OpenIB.html#licenseText" - }, - new Models.License - { - Id = 205, - Name = "Lucent Public License Version 1.0", - SPDX = "LPL-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/LPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 206, - Name = "Lucent Public License v1.02", - SPDX = "LPL-1.02", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/LPL-1.02.html#licenseText" - }, - new Models.License - { - Id = 207, - Name = "LaTeX Project Public License v1.0", - SPDX = "LPPL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/LPPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 208, - Name = "LaTeX Project Public License v1.1", - SPDX = "LPPL-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/LPPL-1.1.html#licenseText" - }, - new Models.License - { - Id = 209, - Name = "LaTeX Project Public License v1.2", - SPDX = "LPPL-1.2", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/LPPL-1.2.html#licenseText" - }, - new Models.License - { - Id = 210, - Name = "LaTeX Project Public License v1.3a", - SPDX = "LPPL-1.3a", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/LPPL-1.3a.html#licenseText" - }, - new Models.License - { - Id = 211, - Name = "LaTeX Project Public License v1.3c", - SPDX = "LPPL-1.3c", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/LPPL-1.3c.html#licenseText" - }, - new Models.License - { - Id = 212, - Name = "MakeIndex License", - SPDX = "MakeIndex", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/MakeIndex.html#licenseText" - }, - new Models.License - { - Id = 213, - Name = "MirOS License", - SPDX = "MirOS", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/MirOS.html#licenseText" - }, - new Models.License - { - Id = 214, - Name = "MIT License", - SPDX = "MIT", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/MIT.html#licenseText" - }, - new Models.License - { - Id = 215, - Name = "MIT No Attribution", - SPDX = "MIT-0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/MIT-0.html#licenseText" - }, - new Models.License - { - Id = 216, - Name = "Enlightenment License (e16)", - SPDX = "MIT-advertising", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/MIT-advertising.html#licenseText" - }, - new Models.License - { - Id = 217, - Name = "CMU License", - SPDX = "MIT-CMU", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/MIT-CMU.html#licenseText" - }, - new Models.License - { - Id = 218, - Name = "enna License", - SPDX = "MIT-enna", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/MIT-enna.html#licenseText" - }, - new Models.License - { - Id = 219, - Name = "feh License", - SPDX = "MIT-feh", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/MIT-feh.html#licenseText" - }, - new Models.License - { - Id = 220, - Name = "MIT +no-false-attribs license", - SPDX = "MITNFA", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/MITNFA.html#licenseText" - }, - new Models.License - { - Id = 221, - Name = "Motosoto License", - SPDX = "Motosoto", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Motosoto.html#licenseText" - }, - new Models.License - { - Id = 222, - Name = "mpich2 License", - SPDX = "mpich2", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/mpich2.html#licenseText" - }, - new Models.License - { - Id = 223, - Name = "Mozilla Public License 1.0", - SPDX = "MPL-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/MPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 224, - Name = "Mozilla Public License 1.1", - SPDX = "MPL-1.1", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/MPL-1.1.html#licenseText" - }, - new Models.License - { - Id = 225, - Name = "Mozilla Public License 2.0", - SPDX = "MPL-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/MPL-2.0.html#licenseText" - }, - new Models.License - { - Id = 226, - Name = "Mozilla Public License 2.0 (no copyleft exception)", - SPDX = "MPL-2.0-no-copyleft-exception", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/MPL-2.0-no-copyleft-exception.html#licenseText" - }, - new Models.License - { - Id = 227, - Name = "Microsoft Public License", - SPDX = "MS-PL", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/MS-PL.html#licenseText" - }, - new Models.License - { - Id = 228, - Name = "Microsoft Reciprocal License", - SPDX = "MS-RL", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/MS-RL.html#licenseText" - }, - new Models.License - { - Id = 229, - Name = "Matrix Template Library License", - SPDX = "MTLL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/MTLL.html#licenseText" - }, - new Models.License - { - Id = 230, - Name = "Multics License", - SPDX = "Multics", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Multics.html#licenseText" - }, - new Models.License - { - Id = 231, - Name = "Mup License", - SPDX = "Mup", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Mup.html#licenseText" - }, - new Models.License - { - Id = 232, - Name = "NASA Open Source Agreement 1.3", - SPDX = "NASA-1.3", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/NASA-1.3.html#licenseText" - }, - new Models.License - { - Id = 233, - Name = "Naumen Public License", - SPDX = "Naumen", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Naumen.html#licenseText" - }, - new Models.License - { - Id = 234, - Name = "Net Boolean Public License v1", - SPDX = "NBPL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/NBPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 235, - Name = "University of Illinois/NCSA Open Source License", - SPDX = "NCSA", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/NCSA.html#licenseText" - }, - new Models.License - { - Id = 236, - Name = "Net-SNMP License", - SPDX = "Net-SNMP", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Net-SNMP.html#licenseText" - }, - new Models.License - { - Id = 237, - Name = "NetCDF license", - SPDX = "NetCDF", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/NetCDF.html#licenseText" - }, - new Models.License - { - Id = 238, - Name = "Newsletr License", - SPDX = "Newsletr", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Newsletr.html#licenseText" - }, - new Models.License - { - Id = 239, - Name = "Nethack General Public License", - SPDX = "NGPL", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/NGPL.html#licenseText" - }, - new Models.License - { - Id = 240, - Name = "Norwegian Licence for Open Government Data", - SPDX = "NLOD-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/NLOD-1.0.html#licenseText" - }, - new Models.License - { - Id = 241, - Name = "No Limit Public License", - SPDX = "NLPL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/NLPL.html#licenseText" - }, - new Models.License - { - Id = 242, - Name = "Nokia Open Source License", - SPDX = "Nokia", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/Nokia.html#licenseText" - }, - new Models.License - { - Id = 243, - Name = "Netizen Open Source License", - SPDX = "NOSL", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/NOSL.html#licenseText" - }, - new Models.License - { - Id = 244, - Name = "Noweb License", - SPDX = "Noweb", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Noweb.html#licenseText" - }, - new Models.License - { - Id = 245, - Name = "Netscape Public License v1.0", - SPDX = "NPL-1.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/NPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 246, - Name = "Netscape Public License v1.1", - SPDX = "NPL-1.1", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/NPL-1.1.html#licenseText" - }, - new Models.License - { - Id = 247, - Name = "Non-Profit Open Software License 3.0", - SPDX = "NPOSL-3.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/NPOSL-3.0.html#licenseText" - }, - new Models.License - { - Id = 248, - Name = "NRL License", - SPDX = "NRL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/NRL.html#licenseText" - }, - new Models.License - { - Id = 249, - Name = "NTP License", - SPDX = "NTP", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/NTP.html#licenseText" - }, - new Models.License - { - Id = 250, - Name = "Open CASCADE Technology Public License", - SPDX = "OCCT-PL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OCCT-PL.html#licenseText" - }, - new Models.License - { - Id = 251, - Name = "OCLC Research Public License 2.0", - SPDX = "OCLC-2.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/OCLC-2.0.html#licenseText" - }, - new Models.License - { - Id = 252, - Name = "ODC Open Database License v1.0", - SPDX = "ODbL-1.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/ODbL-1.0.html#licenseText" - }, - new Models.License - { - Id = 253, - Name = "Open Data Commons Attribution License v1.0", - SPDX = "ODC-By-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/ODC-By-1.0.html#licenseText" - }, - new Models.License - { - Id = 254, - Name = "SIL Open Font License 1.0", - SPDX = "OFL-1.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/OFL-1.0.html#licenseText" - }, - new Models.License - { - Id = 255, - Name = "SIL Open Font License 1.1", - SPDX = "OFL-1.1", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/OFL-1.1.html#licenseText" - }, - new Models.License - { - Id = 256, - Name = "Open Government Licence v1.0", - SPDX = "OGL-UK-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OGL-UK-1.0.html#licenseText" - }, - new Models.License - { - Id = 257, - Name = "Open Government Licence v2.0", - SPDX = "OGL-UK-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OGL-UK-2.0.html#licenseText" - }, - new Models.License - { - Id = 258, - Name = "Open Government Licence v3.0", - SPDX = "OGL-UK-3.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OGL-UK-3.0.html#licenseText" - }, - new Models.License - { - Id = 259, - Name = "Open Group Test Suite License", - SPDX = "OGTSL", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/OGTSL.html#licenseText" - }, - new Models.License - { - Id = 260, - Name = "Open LDAP Public License v1.1", - SPDX = "OLDAP-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-1.1.html#licenseText" - }, - new Models.License - { - Id = 261, - Name = "Open LDAP Public License v1.2", - SPDX = "OLDAP-1.2", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-1.2.html#licenseText" - }, - new Models.License - { - Id = 262, - Name = "Open LDAP Public License v1.3", - SPDX = "OLDAP-1.3", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-1.3.html#licenseText" - }, - new Models.License - { - Id = 263, - Name = "Open LDAP Public License v1.4", - SPDX = "OLDAP-1.4", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-1.4.html#licenseText" - }, - new Models.License - { - Id = 264, - Name = "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)", - SPDX = "OLDAP-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.0.html#licenseText" - }, - new Models.License - { - Id = 265, - Name = "Open LDAP Public License v2.0.1", - SPDX = "OLDAP-2.0.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.0.1.html#licenseText" - }, - new Models.License - { - Id = 266, - Name = "Open LDAP Public License v2.1", - SPDX = "OLDAP-2.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.1.html#licenseText" - }, - new Models.License - { - Id = 267, - Name = "Open LDAP Public License v2.2", - SPDX = "OLDAP-2.2", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.2.html#licenseText" - }, - new Models.License - { - Id = 268, - Name = "Open LDAP Public License v2.2.1", - SPDX = "OLDAP-2.2.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.2.1.html#licenseText" - }, - new Models.License - { - Id = 269, - Name = "Open LDAP Public License 2.2.2", - SPDX = "OLDAP-2.2.2", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.2.2.html#licenseText" - }, - new Models.License - { - Id = 270, - Name = "Open LDAP Public License v2.3", - SPDX = "OLDAP-2.3", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.3.html#licenseText" - }, - new Models.License - { - Id = 271, - Name = "Open LDAP Public License v2.4", - SPDX = "OLDAP-2.4", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.4.html#licenseText" - }, - new Models.License - { - Id = 272, - Name = "Open LDAP Public License v2.5", - SPDX = "OLDAP-2.5", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.5.html#licenseText" - }, - new Models.License - { - Id = 273, - Name = "Open LDAP Public License v2.6", - SPDX = "OLDAP-2.6", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.6.html#licenseText" - }, - new Models.License - { - Id = 274, - Name = "Open LDAP Public License v2.7", - SPDX = "OLDAP-2.7", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.7.html#licenseText" - }, - new Models.License - { - Id = 275, - Name = "Open LDAP Public License v2.8", - SPDX = "OLDAP-2.8", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OLDAP-2.8.html#licenseText" - }, - new Models.License - { - Id = 276, - Name = "Open Market License", - SPDX = "OML", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OML.html#licenseText" - }, - new Models.License - { - Id = 277, - Name = "OpenSSL License", - SPDX = "OpenSSL", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/OpenSSL.html#licenseText" - }, - new Models.License - { - Id = 278, - Name = "Open Public License v1.0", - SPDX = "OPL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 279, - Name = "OSET Public License version 2.1", - SPDX = "OSET-PL-2.1", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/OSET-PL-2.1.html#licenseText" - }, - new Models.License - { - Id = 280, - Name = "Open Software License 1.0", - SPDX = "OSL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/OSL-1.0.html#licenseText" - }, - new Models.License - { - Id = 281, - Name = "Open Software License 1.1", - SPDX = "OSL-1.1", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/OSL-1.1.html#licenseText" - }, - new Models.License - { - Id = 282, - Name = "Open Software License 2.0", - SPDX = "OSL-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/OSL-2.0.html#licenseText" - }, - new Models.License - { - Id = 283, - Name = "Open Software License 2.1", - SPDX = "OSL-2.1", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/OSL-2.1.html#licenseText" - }, - new Models.License - { - Id = 284, - Name = "Open Software License 3.0", - SPDX = "OSL-3.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/OSL-3.0.html#licenseText" - }, - new Models.License - { - Id = 285, - Name = "ODC Public Domain Dedication & License 1.0", - SPDX = "PDDL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/PDDL-1.0.html#licenseText" - }, - new Models.License - { - Id = 286, - Name = "PHP License v3.0", - SPDX = "PHP-3.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/PHP-3.0.html#licenseText" - }, - new Models.License - { - Id = 287, - Name = "PHP License v3.01", - SPDX = "PHP-3.01", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/PHP-3.01.html#licenseText" - }, - new Models.License - { - Id = 288, - Name = "Plexus Classworlds License", - SPDX = "Plexus", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Plexus.html#licenseText" - }, - new Models.License - { - Id = 289, - Name = "PostgreSQL License", - SPDX = "PostgreSQL", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/PostgreSQL.html#licenseText" - }, - new Models.License - { - Id = 290, - Name = "psfrag License", - SPDX = "psfrag", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/psfrag.html#licenseText" - }, - new Models.License - { - Id = 291, - Name = "psutils License", - SPDX = "psutils", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/psutils.html#licenseText" - }, - new Models.License - { - Id = 292, - Name = "Python License 2.0", - SPDX = "Python-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/Python-2.0.html#licenseText" - }, - new Models.License - { - Id = 293, - Name = "Qhull License", - SPDX = "Qhull", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Qhull.html#licenseText" - }, - new Models.License - { - Id = 294, - Name = "Q Public License 1.0", - SPDX = "QPL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/QPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 295, - Name = "Rdisc License", - SPDX = "Rdisc", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Rdisc.html#licenseText" - }, - new Models.License - { - Id = 296, - Name = "Red Hat eCos Public License v1.1", - SPDX = "RHeCos-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/RHeCos-1.1.html#licenseText" - }, - new Models.License - { - Id = 297, - Name = "Reciprocal Public License 1.1", - SPDX = "RPL-1.1", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/RPL-1.1.html#licenseText" - }, - new Models.License - { - Id = 298, - Name = "Reciprocal Public License 1.5", - SPDX = "RPL-1.5", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/RPL-1.5.html#licenseText" - }, - new Models.License - { - Id = 299, - Name = "RealNetworks Public Source License v1.0", - SPDX = "RPSL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/RPSL-1.0.html#licenseText" - }, - new Models.License - { - Id = 300, - Name = "RSA Message-Digest License", - SPDX = "RSA-MD", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/RSA-MD.html#licenseText" - }, - new Models.License - { - Id = 301, - Name = "Ricoh Source Code Public License", - SPDX = "RSCPL", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/RSCPL.html#licenseText" - }, - new Models.License - { - Id = 302, - Name = "Ruby License", - SPDX = "Ruby", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/Ruby.html#licenseText" - }, - new Models.License - { - Id = 303, - Name = "Sax Public Domain Notice", - SPDX = "SAX-PD", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SAX-PD.html#licenseText" - }, - new Models.License - { - Id = 304, - Name = "Saxpath License", - SPDX = "Saxpath", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Saxpath.html#licenseText" - }, - new Models.License - { - Id = 305, - Name = "SCEA Shared Source License", - SPDX = "SCEA", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SCEA.html#licenseText" - }, - new Models.License - { - Id = 306, - Name = "Sendmail License", - SPDX = "Sendmail", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Sendmail.html#licenseText" - }, - new Models.License - { - Id = 307, - Name = "Sendmail License 8.23", - SPDX = "Sendmail-8.23", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Sendmail-8.23.html#licenseText" - }, - new Models.License - { - Id = 308, - Name = "SGI Free Software License B v1.0", - SPDX = "SGI-B-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SGI-B-1.0.html#licenseText" - }, - new Models.License - { - Id = 309, - Name = "SGI Free Software License B v1.1", - SPDX = "SGI-B-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SGI-B-1.1.html#licenseText" - }, - new Models.License - { - Id = 310, - Name = "SGI Free Software License B v2.0", - SPDX = "SGI-B-2.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/SGI-B-2.0.html#licenseText" - }, - new Models.License - { - Id = 311, - Name = "Simple Public License 2.0", - SPDX = "SimPL-2.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/SimPL-2.0.html#licenseText" - }, - new Models.License - { - Id = 312, - Name = "Sun Industry Standards Source License v1.1", - SPDX = "SISSL", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/SISSL.html#licenseText" - }, - new Models.License - { - Id = 313, - Name = "Sun Industry Standards Source License v1.2", - SPDX = "SISSL-1.2", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SISSL-1.2.html#licenseText" - }, - new Models.License - { - Id = 314, - Name = "Sleepycat License", - SPDX = "Sleepycat", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/Sleepycat.html#licenseText" - }, - new Models.License - { - Id = 315, - Name = "Standard ML of New Jersey License", - SPDX = "SMLNJ", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/SMLNJ.html#licenseText" - }, - new Models.License - { - Id = 316, - Name = "Secure Messaging Protocol Public License", - SPDX = "SMPPL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SMPPL.html#licenseText" - }, - new Models.License - { - Id = 317, - Name = "SNIA Public License 1.1", - SPDX = "SNIA", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SNIA.html#licenseText" - }, - new Models.License - { - Id = 318, - Name = "Spencer License 86", - SPDX = "Spencer-86", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Spencer-86.html#licenseText" - }, - new Models.License - { - Id = 319, - Name = "Spencer License 94", - SPDX = "Spencer-94", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Spencer-94.html#licenseText" - }, - new Models.License - { - Id = 320, - Name = "Spencer License 99", - SPDX = "Spencer-99", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Spencer-99.html#licenseText" - }, - new Models.License - { - Id = 321, - Name = "Sun Public License v1.0", - SPDX = "SPL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/SPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 322, - Name = "SugarCRM Public License v1.1.3", - SPDX = "SugarCRM-1.1.3", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SugarCRM-1.1.3.html#licenseText" - }, - new Models.License - { - Id = 323, - Name = "Scheme Widget Library (SWL) Software License Agreement", - SPDX = "SWL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SWL.html#licenseText" - }, - new Models.License - { - Id = 324, - Name = "TAPR Open Hardware License v1.0", - SPDX = "TAPR-OHL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/TAPR-OHL-1.0.html#licenseText" - }, - new Models.License - { - Id = 325, - Name = "TCL/TK License", - SPDX = "TCL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/TCL.html#licenseText" - }, - new Models.License - { - Id = 326, - Name = "TCP Wrappers License", - SPDX = "TCP-wrappers", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/TCP-wrappers.html#licenseText" - }, - new Models.License - { - Id = 327, - Name = "TMate Open Source License", - SPDX = "TMate", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/TMate.html#licenseText" - }, - new Models.License - { - Id = 328, - Name = "TORQUE v2.5+ Software License v1.1", - SPDX = "TORQUE-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/TORQUE-1.1.html#licenseText" - }, - new Models.License - { - Id = 329, - Name = "Trusster Open Source License", - SPDX = "TOSL", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/TOSL.html#licenseText" - }, - new Models.License - { - Id = 330, - Name = "Technische Universitaet Berlin License 1.0", - SPDX = "TU-Berlin-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/TU-Berlin-1.0.html#licenseText" - }, - new Models.License - { - Id = 331, - Name = "Technische Universitaet Berlin License 2.0", - SPDX = "TU-Berlin-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/TU-Berlin-2.0.html#licenseText" - }, - new Models.License - { - Id = 332, - Name = "Unicode License Agreement - Data Files and Software (2015)", - SPDX = "Unicode-DFS-2015", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Unicode-DFS-2015.html#licenseText" - }, - new Models.License - { - Id = 333, - Name = "Unicode License Agreement - Data Files and Software (2016)", - SPDX = "Unicode-DFS-2016", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Unicode-DFS-2016.html#licenseText" - }, - new Models.License - { - Id = 334, - Name = "Unicode Terms of Use", - SPDX = "Unicode-TOU", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Unicode-TOU.html#licenseText" - }, - new Models.License - { - Id = 335, - Name = "The Unlicense", - SPDX = "Unlicense", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/Unlicense.html#licenseText" - }, - new Models.License - { - Id = 336, - Name = "Universal Permissive License v1.0", - SPDX = "UPL-1.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/UPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 337, - Name = "Vim License", - SPDX = "Vim", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/Vim.html#licenseText" - }, - new Models.License - { - Id = 338, - Name = "VOSTROM Public License for Open Source", - SPDX = "VOSTROM", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/VOSTROM.html#licenseText" - }, - new Models.License - { - Id = 339, - Name = "Vovida Software License v1.0", - SPDX = "VSL-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/VSL-1.0.html#licenseText" - }, - new Models.License - { - Id = 340, - Name = "W3C Software Notice and License (2002-12-31)", - SPDX = "W3C", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/W3C.html#licenseText" - }, - new Models.License - { - Id = 341, - Name = "W3C Software Notice and License (1998-07-20)", - SPDX = "W3C-19980720", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/W3C-19980720.html#licenseText" - }, - new Models.License - { - Id = 342, - Name = "W3C Software Notice and Document License (2015-05-13)", - SPDX = "W3C-20150513", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/W3C-20150513.html#licenseText" - }, - new Models.License - { - Id = 343, - Name = "Sybase Open Watcom Public License 1.0", - SPDX = "Watcom-1.0", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Watcom-1.0.html#licenseText" - }, - new Models.License - { - Id = 344, - Name = "Wsuipa License", - SPDX = "Wsuipa", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Wsuipa.html#licenseText" - }, - new Models.License - { - Id = 345, - Name = "Do What The F*ck You Want To Public License", - SPDX = "WTFPL", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/WTFPL.html#licenseText" - }, - new Models.License - { - Id = 346, - Name = "X11 License", - SPDX = "X11", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/X11.html#licenseText" - }, - new Models.License - { - Id = 347, - Name = "Xerox License", - SPDX = "Xerox", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Xerox.html#licenseText" - }, - new Models.License - { - Id = 348, - Name = "XFree86 License 1.1", - SPDX = "XFree86-1.1", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/XFree86-1.1.html#licenseText" - }, - new Models.License - { - Id = 349, - Name = "xinetd License", - SPDX = "xinetd", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/xinetd.html#licenseText" - }, - new Models.License - { - Id = 350, - Name = "X.Net License", - SPDX = "Xnet", - FsfApproved = false, - OsiApproved = true, - Link = "https://spdx.org/licenses/Xnet.html#licenseText" - }, - new Models.License - { - Id = 351, - Name = "XPP License", - SPDX = "xpp", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/xpp.html#licenseText" - }, - new Models.License - { - Id = 352, - Name = "XSkat License", - SPDX = "XSkat", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/XSkat.html#licenseText" - }, - new Models.License - { - Id = 353, - Name = "Yahoo! Public License v1.0", - SPDX = "YPL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/YPL-1.0.html#licenseText" - }, - new Models.License - { - Id = 354, - Name = "Yahoo! Public License v1.1", - SPDX = "YPL-1.1", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/YPL-1.1.html#licenseText" - }, - new Models.License - { - Id = 355, - Name = "Zed License", - SPDX = "Zed", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Zed.html#licenseText" - }, - new Models.License - { - Id = 356, - Name = "Zend License v2.0", - SPDX = "Zend-2.0", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/Zend-2.0.html#licenseText" - }, - new Models.License - { - Id = 357, - Name = "Zimbra Public License v1.3", - SPDX = "Zimbra-1.3", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/Zimbra-1.3.html#licenseText" - }, - new Models.License - { - Id = 358, - Name = "Zimbra Public License v1.4", - SPDX = "Zimbra-1.4", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Zimbra-1.4.html#licenseText" - }, - new Models.License - { - Id = 359, - Name = "zlib License", - SPDX = "Zlib", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/Zlib.html#licenseText" - }, - new Models.License - { - Id = 360, - Name = "zlib/libpng License with Acknowledgement", - SPDX = "zlib-acknowledgement", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/zlib-acknowledgement.html#licenseText" - }, - new Models.License - { - Id = 361, - Name = "Zope Public License 1.1", - SPDX = "ZPL-1.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/ZPL-1.1.html#licenseText" - }, - new Models.License - { - Id = 362, - Name = "Zope Public License 2.0", - SPDX = "ZPL-2.0", - FsfApproved = true, - OsiApproved = true, - Link = "https://spdx.org/licenses/ZPL-2.0.html#licenseText" - }, - new Models.License - { - Id = 363, - Name = "Zope Public License 2.1", - SPDX = "ZPL-2.1", - FsfApproved = true, - OsiApproved = false, - Link = "https://spdx.org/licenses/ZPL-2.1.html#licenseText" - }, - new Models.License - { - Id = 364, - Name = "Public domain", - SPDX = null, - FsfApproved = true, - OsiApproved = false, - Link = null - }, - new Models.License - { - Id = 365, - Name = "Cryptographic Autonomy License 1.0", - SPDX = "CAL-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CAL-1.0.html" - }, - new Models.License - { - Id = 366, - Name = "Cryptographic Autonomy License 1.0 (Combined Work Exception)", - SPDX = "CAL-1.0-Combined-Work-Exception", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CAL-1.0-Combined-Work-Exception.html" - }, - new Models.License - { - Id = 367, - Name = "CERN Open Hardware Licence Version 2 - Permissive", - SPDX = "CERN-OHL-P-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CERN-OHL-P-2.0.html" - }, - new Models.License - { - Id = 368, - Name = "CERN Open Hardware Licence Version 2 - Strongly Reciprocal", - SPDX = "CERN-OHL-S-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CERN-OHL-S-2.0.html" - }, - new Models.License - { - Id = 369, - Name = "CERN Open Hardware Licence Version 2 - Weakly Reciprocal", - SPDX = "CERN-OHL-W-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/CERN-OHL-W-2.0.html" - }, - new Models.License - { - Id = 370, - Name = "Hippocratic License 2.1", - SPDX = "Hippocratic-2.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Hippocratic-2.1.html" - }, - new Models.License - { - Id = 371, - Name = "LGPL-3.0 Linking Exception", - SPDX = "LGPL-3.0-linking-exception", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/LGPL-3.0-linking-exception.html" - }, - new Models.License - { - Id = 372, - Name = "Mulan Permissive Software License, Version 2", - SPDX = "MulanPSL-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/MulanPSL-2.0.html" - }, - new Models.License - { - Id = 373, - Name = "Non-Commercial Government Licence", - SPDX = "NCGL-UK-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/NCGL-UK-2.0.html" - }, - new Models.License - { - Id = 374, - Name = "Open Use of Data Agreement v1.0", - SPDX = "O-UDA-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/O-UDA-1.0.html" - }, - new Models.License - { - Id = 375, - Name = "OGC Software License, Version 1.0", - SPDX = "OGC-1.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/OGC-1.0.html" - }, - new Models.License - { - Id = 376, - Name = "The Parity Public License 7.0.0", - SPDX = "Parity-7.0.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/Parity-7.0.0.html" - }, - new Models.License - { - Id = 377, - Name = "PolyForm Noncommercial License 1.0.0", - SPDX = "PolyForm-Noncommercial-1.0.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/PolyForm-Noncommercial-1.0.0.html" - }, - new Models.License - { - Id = 378, - Name = "PolyForm Small Business License 1.0.0", - SPDX = "PolyForm-Small-Business-1.0.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/PolyForm-Small-Business-1.0.0.html" - }, - new Models.License - { - Id = 379, - Name = "Solderpad Hardware License v2.0", - SPDX = "SHL-2.0", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SHL-2.0.html" - }, - new Models.License - { - Id = 380, - Name = "Solderpad Hardware License v2.1", - SPDX = "SHL-2.1", - FsfApproved = false, - OsiApproved = false, - Link = "https://spdx.org/licenses/SHL-2.1.html" + existingLicense.Name = license.Name; + changed = true; } - }) - { - Models.License existingLicense = existingLicenses.FirstOrDefault(r => r.Id == license.Id); - if(existingLicense is null) - newLicenses.Add(license); - else + if(license.SPDX != existingLicense.SPDX) { - bool changed = false; - - if(license.Name != existingLicense.Name) - { - existingLicense.Name = license.Name; - changed = true; - } - - if(license.SPDX != existingLicense.SPDX) - { - existingLicense.SPDX = license.SPDX; - changed = true; - } - - if(license.FsfApproved != existingLicense.FsfApproved) - { - existingLicense.FsfApproved = license.FsfApproved; - changed = true; - } - - if(license.OsiApproved != existingLicense.OsiApproved) - { - existingLicense.OsiApproved = license.OsiApproved; - changed = true; - } - - if(license.Link != existingLicense.Link) - { - existingLicense.Link = license.Link; - changed = true; - } - - if(changed) - updatedLicencesCount++; + existingLicense.SPDX = license.SPDX; + changed = true; } + + if(license.FsfApproved != existingLicense.FsfApproved) + { + existingLicense.FsfApproved = license.FsfApproved; + changed = true; + } + + if(license.OsiApproved != existingLicense.OsiApproved) + { + existingLicense.OsiApproved = license.OsiApproved; + changed = true; + } + + if(license.Link != existingLicense.Link) + { + existingLicense.Link = license.Link; + changed = true; + } + + if(changed) updatedLicencesCount++; } - - context.Licenses.AddRange(newLicenses); - - Console.WriteLine("{0} licenses will be added.", newLicenses.Count); - Console.WriteLine("{0} licenses will be updated.", updatedLicencesCount); } + + context.Licenses.AddRange(newLicenses); + + Console.WriteLine("{0} licenses will be added.", newLicenses.Count); + Console.WriteLine("{0} licenses will be updated.", updatedLicencesCount); } } \ No newline at end of file diff --git a/Marechai.Database/Seeders/Roles.cs b/Marechai.Database/Seeders/Roles.cs index 472d0417..b83f3479 100644 --- a/Marechai.Database/Seeders/Roles.cs +++ b/Marechai.Database/Seeders/Roles.cs @@ -29,43 +29,44 @@ using Marechai.Database.Models; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Configuration; -namespace Marechai.Database.Seeders +namespace Marechai.Database.Seeders; + +public static class Roles { - public static class Roles + public static void Seed(RoleManager roleManager, IConfiguration configuration) { - public static void Seed(RoleManager roleManager, IConfiguration configuration) + var roles = configuration.GetSection("MarechaiRoles") + .GetChildren() + .Select(x => new + { + Name = x.GetValue("Name"), + Description = x.GetValue("Description") + }) + .ToList(); + + if(roles.Count == 0) return; + + foreach(var role in roles) { - var roles = configuration.GetSection("MarechaiRoles").GetChildren().Select(x => new + ApplicationRole existingRole = roleManager.FindByNameAsync(role.Name).Result; + + if(existingRole != null) { - Name = x.GetValue("Name"), - Description = x.GetValue("Description") - }).ToList(); - - if(roles.Count == 0) - return; - - foreach(var role in roles) - { - ApplicationRole existingRole = roleManager.FindByNameAsync(role.Name).Result; - - if(existingRole != null) + if(existingRole.Description != role.Description) { - if(existingRole.Description != role.Description) - { - Console.WriteLine("Updating description for role {0}", role.Name); - existingRole.Description = role.Description; - } - - continue; + Console.WriteLine("Updating description for role {0}", role.Name); + existingRole.Description = role.Description; } - var newRole = new ApplicationRole(role.Name, role.Description); - - IdentityResult result = roleManager.CreateAsync(newRole).Result; - - Console.WriteLine(result.Succeeded ? "New role {0} added successfully" : "Failed to add new role {0}", - role.Name); + continue; } + + var newRole = new ApplicationRole(role.Name, role.Description); + + IdentityResult result = roleManager.CreateAsync(newRole).Result; + + Console.WriteLine(result.Succeeded ? "New role {0} added successfully" : "Failed to add new role {0}", + role.Name); } } } \ No newline at end of file diff --git a/Marechai.Database/Seeders/Users.cs b/Marechai.Database/Seeders/Users.cs index 6519c388..ea4baea8 100644 --- a/Marechai.Database/Seeders/Users.cs +++ b/Marechai.Database/Seeders/Users.cs @@ -28,71 +28,67 @@ using System.Collections.Generic; using Marechai.Database.Models; using Microsoft.AspNetCore.Identity; -namespace Marechai.Database.Seeders +namespace Marechai.Database.Seeders; + +public static class Users { - public static class Users + public static void Seed(UserManager userManager, RoleManager roleManager) { - public static void Seed(UserManager userManager, RoleManager roleManager) + ApplicationRole uberAdminRole = roleManager.FindByNameAsync("UberAdmin").Result; + + if(uberAdminRole is null) { - ApplicationRole uberAdminRole = roleManager.FindByNameAsync("UberAdmin").Result; + Console.WriteLine("Cannot find UberAdmin role, is database properly seeded?"); - if(uberAdminRole is null) - { - Console.WriteLine("Cannot find UberAdmin role, is database properly seeded?"); - - return; - } - - IList uberAdmins = userManager.GetUsersInRoleAsync("UberAdmin").Result; - - if(uberAdmins.Count > 1) - { - Console.WriteLine("Too many uberadmins, only one can exist"); - - foreach(ApplicationUser user in uberAdmins) - { - Console.WriteLine("Removing uberadmin permissions from user {0}", user.UserName); - - userManager.RemoveFromRoleAsync(user, "UberAdmin"); - } - } - - if(uberAdmins.Count == 1) - return; - - ApplicationUser uberAdmin = userManager.FindByEmailAsync("claunia@claunia.com").Result ?? - userManager.FindByNameAsync("claunia").Result; - - if(uberAdmin is null) - { - uberAdmin = new ApplicationUser - { - UserName = "claunia", - Email = "claunia@claunia.com", - EmailConfirmed = true - }; - - byte[] newPass = new byte[8]; - new Random().NextBytes(newPass); - string newPassString = Convert.ToBase64String(newPass); - - IdentityResult result = userManager.CreateAsync(uberAdmin, newPassString).Result; - - if(result.Succeeded) - { - userManager.AddToRoleAsync(uberAdmin, "UberAdmin").Wait(); - Console.WriteLine("Created new claunia uberadmin with password {0}.", newPassString); - } - else - { - Console.WriteLine("Could not create new uberadmin."); - } - - return; - } - - Console.WriteLine("Giving uberadmin permissions to user claunia"); - userManager.AddToRoleAsync(uberAdmin, "UberAdmin").Wait(); + return; } + + IList uberAdmins = userManager.GetUsersInRoleAsync("UberAdmin").Result; + + if(uberAdmins.Count > 1) + { + Console.WriteLine("Too many uberadmins, only one can exist"); + + foreach(ApplicationUser user in uberAdmins) + { + Console.WriteLine("Removing uberadmin permissions from user {0}", user.UserName); + + userManager.RemoveFromRoleAsync(user, "UberAdmin"); + } + } + + if(uberAdmins.Count == 1) return; + + ApplicationUser uberAdmin = userManager.FindByEmailAsync("claunia@claunia.com").Result ?? + userManager.FindByNameAsync("claunia").Result; + + if(uberAdmin is null) + { + uberAdmin = new ApplicationUser + { + UserName = "claunia", + Email = "claunia@claunia.com", + EmailConfirmed = true + }; + + var newPass = new byte[8]; + new Random().NextBytes(newPass); + string newPassString = Convert.ToBase64String(newPass); + + IdentityResult result = userManager.CreateAsync(uberAdmin, newPassString).Result; + + if(result.Succeeded) + { + userManager.AddToRoleAsync(uberAdmin, "UberAdmin").Wait(); + Console.WriteLine("Created new claunia uberadmin with password {0}.", newPassString); + } + else + Console.WriteLine("Could not create new uberadmin."); + + return; + } + + Console.WriteLine("Giving uberadmin permissions to user claunia"); + userManager.AddToRoleAsync(uberAdmin, "UberAdmin").Wait(); } } \ No newline at end of file diff --git a/Marechai/App.razor b/Marechai/App.razor index 523e9268..c765980d 100644 --- a/Marechai/App.razor +++ b/Marechai/App.razor @@ -27,7 +27,7 @@ - + diff --git a/Marechai/Areas/Identity/IdentityHostingStartup.cs b/Marechai/Areas/Identity/IdentityHostingStartup.cs index 2f6b57ee..b1802cb5 100644 --- a/Marechai/Areas/Identity/IdentityHostingStartup.cs +++ b/Marechai/Areas/Identity/IdentityHostingStartup.cs @@ -3,10 +3,9 @@ using Microsoft.AspNetCore.Hosting; [assembly: HostingStartup(typeof(IdentityHostingStartup))] -namespace Marechai.Areas.Identity +namespace Marechai.Areas.Identity; + +public class IdentityHostingStartup : IHostingStartup { - public class IdentityHostingStartup : IHostingStartup - { - public void Configure(IWebHostBuilder builder) => builder.ConfigureServices((context, services) => {}); - } + public void Configure(IWebHostBuilder builder) => builder.ConfigureServices((context, services) => {}); } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs index f4b13636..9f43e17a 100644 --- a/Marechai/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs @@ -1,9 +1,8 @@ using Microsoft.AspNetCore.Mvc.RazorPages; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +public class AccessDeniedModel : PageModel { - public class AccessDeniedModel : PageModel - { - public void OnGet() {} - } + public void OnGet() {} } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs index 61f938bf..f6efb4e6 100644 --- a/Marechai/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs @@ -7,38 +7,26 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class ConfirmEmailModel(UserManager userManager) : PageModel { - [AllowAnonymous] - public class ConfirmEmailModel : PageModel + [TempData] + public string StatusMessage { get; set; } + + public async Task OnGetAsync(string userId, string code) { - readonly UserManager _userManager; + if(userId == null || code == null) return RedirectToPage("/Index"); - public ConfirmEmailModel(UserManager userManager) => _userManager = userManager; + ApplicationUser user = await userManager.FindByIdAsync(userId); - [TempData] - public string StatusMessage { get; set; } + if(user == null) return NotFound($"Unable to load user with ID '{userId}'."); - public async Task OnGetAsync(string userId, string code) - { - if(userId == null || - code == null) - { - return RedirectToPage("/Index"); - } + code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); + IdentityResult result = await userManager.ConfirmEmailAsync(user, code); + StatusMessage = result.Succeeded ? "Thank you for confirming your email." : "Error confirming your email."; - ApplicationUser user = await _userManager.FindByIdAsync(userId); - - if(user == null) - { - return NotFound($"Unable to load user with ID '{userId}'."); - } - - code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); - IdentityResult result = await _userManager.ConfirmEmailAsync(user, code); - StatusMessage = result.Succeeded ? "Thank you for confirming your email." : "Error confirming your email."; - - return Page(); - } + return Page(); } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml b/Marechai/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml index 186c61a8..e7c49633 100644 --- a/Marechai/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml @@ -4,4 +4,4 @@ ViewData["Title"] = "Confirm email change"; }

@ViewData["Title"]

- \ No newline at end of file + \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs index b5e77e53..7705b75d 100644 --- a/Marechai/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs @@ -7,65 +7,47 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class ConfirmEmailChangeModel + (UserManager userManager, SignInManager signInManager) : PageModel { - [AllowAnonymous] - public class ConfirmEmailChangeModel : PageModel + [TempData] + public string StatusMessage { get; set; } + + public async Task OnGetAsync(string userId, string email, string code) { - readonly SignInManager _signInManager; - readonly UserManager _userManager; + if(userId == null || email == null || code == null) return RedirectToPage("/Index"); - public ConfirmEmailChangeModel(UserManager userManager, - SignInManager signInManager) + ApplicationUser user = await userManager.FindByIdAsync(userId); + + if(user == null) return NotFound($"Unable to load user with ID '{userId}'."); + + code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); + IdentityResult result = await userManager.ChangeEmailAsync(user, email, code); + + if(!result.Succeeded) { - _userManager = userManager; - _signInManager = signInManager; - } - - [TempData] - public string StatusMessage { get; set; } - - public async Task OnGetAsync(string userId, string email, string code) - { - if(userId == null || - email == null || - code == null) - { - return RedirectToPage("/Index"); - } - - ApplicationUser user = await _userManager.FindByIdAsync(userId); - - if(user == null) - { - return NotFound($"Unable to load user with ID '{userId}'."); - } - - code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); - IdentityResult result = await _userManager.ChangeEmailAsync(user, email, code); - - if(!result.Succeeded) - { - StatusMessage = "Error changing email."; - - return Page(); - } - - // In our UI email and user name are one and the same, so when we update the email - // we need to update the user name. - IdentityResult setUserNameResult = await _userManager.SetUserNameAsync(user, email); - - if(!setUserNameResult.Succeeded) - { - StatusMessage = "Error changing user name."; - - return Page(); - } - - await _signInManager.RefreshSignInAsync(user); - StatusMessage = "Thank you for confirming your email change."; + StatusMessage = "Error changing email."; return Page(); } + + // In our UI email and user name are one and the same, so when we update the email + // we need to update the user name. + IdentityResult setUserNameResult = await userManager.SetUserNameAsync(user, email); + + if(!setUserNameResult.Succeeded) + { + StatusMessage = "Error changing user name."; + + return Page(); + } + + await signInManager.RefreshSignInAsync(user); + StatusMessage = "Thank you for confirming your email change."; + + return Page(); } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/ExternalLogin.cshtml b/Marechai/Areas/Identity/Pages/Account/ExternalLogin.cshtml index 31ec095b..7b1887d6 100644 --- a/Marechai/Areas/Identity/Pages/Account/ExternalLogin.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/ExternalLogin.cshtml @@ -5,7 +5,7 @@ }

@ViewData["Title"]

Associate your @Model.ProviderDisplayName account.

-
+

You've successfully authenticated with @Model.ProviderDisplayName. @@ -18,7 +18,7 @@

- +
@@ -27,5 +27,5 @@ @section Scripts { - + } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs index f899b211..6e8d268a 100644 --- a/Marechai/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs @@ -14,190 +14,186 @@ using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using SignInResult = Microsoft.AspNetCore.Identity.SignInResult; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class ExternalLoginModel +( + SignInManager signInManager, + UserManager userManager, + ILogger logger, + IEmailSender emailSender +) : PageModel { - [AllowAnonymous] - public class ExternalLoginModel : PageModel + [BindProperty] + public InputModel Input { get; set; } + + public string ProviderDisplayName { get; set; } + + public string ReturnUrl { get; set; } + + [TempData] + public string ErrorMessage { get; set; } + + public IActionResult OnGetAsync() => RedirectToPage("./Login"); + + public IActionResult OnPost(string provider, string returnUrl = null) { - readonly IEmailSender _emailSender; - readonly ILogger _logger; - readonly SignInManager _signInManager; - readonly UserManager _userManager; + // Request a redirect to the external login provider. + string redirectUrl = Url.Page("./ExternalLogin", + "Callback", + new + { + returnUrl + }); - public ExternalLoginModel(SignInManager signInManager, - UserManager userManager, ILogger logger, - IEmailSender emailSender) + AuthenticationProperties properties = + signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl); + + return new ChallengeResult(provider, properties); + } + + public async Task OnGetCallbackAsync(string returnUrl = null, string remoteError = null) + { + returnUrl = returnUrl ?? Url.Content("~/"); + + if(remoteError != null) { - _signInManager = signInManager; - _userManager = userManager; - _logger = logger; - _emailSender = emailSender; + ErrorMessage = $"Error from external provider: {remoteError}"; + + return RedirectToPage("./Login", + new + { + ReturnUrl = returnUrl + }); } - [BindProperty] - public InputModel Input { get; set; } + ExternalLoginInfo info = await signInManager.GetExternalLoginInfoAsync(); - public string ProviderDisplayName { get; set; } - - public string ReturnUrl { get; set; } - - [TempData] - public string ErrorMessage { get; set; } - - public IActionResult OnGetAsync() => RedirectToPage("./Login"); - - public IActionResult OnPost(string provider, string returnUrl = null) + if(info == null) { - // Request a redirect to the external login provider. - string redirectUrl = Url.Page("./ExternalLogin", "Callback", new - { - returnUrl - }); + ErrorMessage = "Error loading external login information."; - AuthenticationProperties properties = - _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl); - - return new ChallengeResult(provider, properties); + return RedirectToPage("./Login", + new + { + ReturnUrl = returnUrl + }); } - public async Task OnGetCallbackAsync(string returnUrl = null, string remoteError = null) + // Sign in the user with this external login provider if the user already has a login. + SignInResult result = + await signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, false, true); + + if(result.Succeeded) { - returnUrl = returnUrl ?? Url.Content("~/"); + logger.LogInformation("{Name} logged in with {LoginProvider} provider.", + info.Principal.Identity.Name, + info.LoginProvider); - if(remoteError != null) + return LocalRedirect(returnUrl); + } + + if(result.IsLockedOut) return RedirectToPage("./Lockout"); + + // If the user does not have an account, then ask the user to create an account. + ReturnUrl = returnUrl; + ProviderDisplayName = info.ProviderDisplayName; + + if(info.Principal.HasClaim(c => c.Type == ClaimTypes.Email)) + { + Input = new InputModel { - ErrorMessage = $"Error from external provider: {remoteError}"; + Email = info.Principal.FindFirstValue(ClaimTypes.Email) + }; + } - return RedirectToPage("./Login", new - { - ReturnUrl = returnUrl - }); - } + return Page(); + } - ExternalLoginInfo info = await _signInManager.GetExternalLoginInfoAsync(); + public async Task OnPostConfirmationAsync(string returnUrl = null) + { + returnUrl = returnUrl ?? Url.Content("~/"); - if(info == null) + // Get the information about the user from the external login provider + ExternalLoginInfo info = await signInManager.GetExternalLoginInfoAsync(); + + if(info == null) + { + ErrorMessage = "Error loading external login information during confirmation."; + + return RedirectToPage("./Login", + new + { + ReturnUrl = returnUrl + }); + } + + if(ModelState.IsValid) + { + var user = new ApplicationUser { - ErrorMessage = "Error loading external login information."; + UserName = Input.Email, + Email = Input.Email + }; - return RedirectToPage("./Login", new - { - ReturnUrl = returnUrl - }); - } - - // Sign in the user with this external login provider if the user already has a login. - SignInResult result = - await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, false, true); + IdentityResult result = await userManager.CreateAsync(user); if(result.Succeeded) { - _logger.LogInformation("{Name} logged in with {LoginProvider} provider.", info.Principal.Identity.Name, - info.LoginProvider); - - return LocalRedirect(returnUrl); - } - - if(result.IsLockedOut) - { - return RedirectToPage("./Lockout"); - } - - // If the user does not have an account, then ask the user to create an account. - ReturnUrl = returnUrl; - ProviderDisplayName = info.ProviderDisplayName; - - if(info.Principal.HasClaim(c => c.Type == ClaimTypes.Email)) - { - Input = new InputModel - { - Email = info.Principal.FindFirstValue(ClaimTypes.Email) - }; - } - - return Page(); - } - - public async Task OnPostConfirmationAsync(string returnUrl = null) - { - returnUrl = returnUrl ?? Url.Content("~/"); - - // Get the information about the user from the external login provider - ExternalLoginInfo info = await _signInManager.GetExternalLoginInfoAsync(); - - if(info == null) - { - ErrorMessage = "Error loading external login information during confirmation."; - - return RedirectToPage("./Login", new - { - ReturnUrl = returnUrl - }); - } - - if(ModelState.IsValid) - { - var user = new ApplicationUser - { - UserName = Input.Email, - Email = Input.Email - }; - - IdentityResult result = await _userManager.CreateAsync(user); + result = await userManager.AddLoginAsync(user, info); if(result.Succeeded) { - result = await _userManager.AddLoginAsync(user, info); + logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); - if(result.Succeeded) + string userId = await userManager.GetUserIdAsync(user); + string code = await userManager.GenerateEmailConfirmationTokenAsync(user); + code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); + + string callbackUrl = Url.Page("/Account/ConfirmEmail", + null, + new + { + area = "Identity", + userId, + code + }, + Request.Scheme); + + await emailSender.SendEmailAsync(Input.Email, + "Confirm your email", + $"Please confirm your account by clicking here."); + + // If account confirmation is required, we need to show the link if we don't have a real email sender + if(userManager.Options.SignIn.RequireConfirmedAccount) { - _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); - - string userId = await _userManager.GetUserIdAsync(user); - string code = await _userManager.GenerateEmailConfirmationTokenAsync(user); - code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); - - string callbackUrl = Url.Page("/Account/ConfirmEmail", null, new - { - area = "Identity", - userId, - code - }, Request.Scheme); - - await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", - $"Please confirm your account by clicking here."); - - // If account confirmation is required, we need to show the link if we don't have a real email sender - if(_userManager.Options.SignIn.RequireConfirmedAccount) - { - return RedirectToPage("./RegisterConfirmation", new - { - Input.Email - }); - } - - await _signInManager.SignInAsync(user, false, info.LoginProvider); - - return LocalRedirect(returnUrl); + return RedirectToPage("./RegisterConfirmation", + new + { + Input.Email + }); } - } - foreach(IdentityError error in result.Errors) - { - ModelState.AddModelError(string.Empty, error.Description); + await signInManager.SignInAsync(user, false, info.LoginProvider); + + return LocalRedirect(returnUrl); } } - ProviderDisplayName = info.ProviderDisplayName; - ReturnUrl = returnUrl; - - return Page(); + foreach(IdentityError error in result.Errors) ModelState.AddModelError(string.Empty, error.Description); } - public class InputModel - { - [Required, EmailAddress] - public string Email { get; set; } - } + ProviderDisplayName = info.ProviderDisplayName; + ReturnUrl = returnUrl; + + return Page(); + } + + public class InputModel + { + [Required] + [EmailAddress] + public string Email { get; set; } } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/ForgotPassword.cshtml b/Marechai/Areas/Identity/Pages/Account/ForgotPassword.cshtml index ca9490be..07b8e4cb 100644 --- a/Marechai/Areas/Identity/Pages/Account/ForgotPassword.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/ForgotPassword.cshtml @@ -5,14 +5,14 @@ }

@ViewData["Title"]

Enter your email.

-
+
- +
@@ -21,5 +21,5 @@
@section Scripts { - + } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs index af605b57..9de79587 100644 --- a/Marechai/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs @@ -10,60 +10,54 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class ForgotPasswordModel(UserManager userManager, IEmailSender emailSender) : PageModel { - [AllowAnonymous] - public class ForgotPasswordModel : PageModel + [BindProperty] + public InputModel Input { get; set; } + + public async Task OnPostAsync() { - readonly IEmailSender _emailSender; - readonly UserManager _userManager; - - public ForgotPasswordModel(UserManager userManager, IEmailSender emailSender) + if(ModelState.IsValid) { - _userManager = userManager; - _emailSender = emailSender; - } + ApplicationUser user = await userManager.FindByEmailAsync(Input.Email); - [BindProperty] - public InputModel Input { get; set; } - - public async Task OnPostAsync() - { - if(ModelState.IsValid) + if(user == null || !await userManager.IsEmailConfirmedAsync(user)) { - ApplicationUser user = await _userManager.FindByEmailAsync(Input.Email); - - if(user == null || - !await _userManager.IsEmailConfirmedAsync(user)) - { - // Don't reveal that the user does not exist or is not confirmed - return RedirectToPage("./ForgotPasswordConfirmation"); - } - - // For more information on how to enable account confirmation and password reset please - // visit https://go.microsoft.com/fwlink/?LinkID=532713 - string code = await _userManager.GeneratePasswordResetTokenAsync(user); - code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); - - string callbackUrl = Url.Page("/Account/ResetPassword", null, new - { - area = "Identity", - code - }, Request.Scheme); - - await _emailSender.SendEmailAsync(Input.Email, "Reset Password", - $"Please reset your password by clicking here."); - + // Don't reveal that the user does not exist or is not confirmed return RedirectToPage("./ForgotPasswordConfirmation"); } - return Page(); + // For more information on how to enable account confirmation and password reset please + // visit https://go.microsoft.com/fwlink/?LinkID=532713 + string code = await userManager.GeneratePasswordResetTokenAsync(user); + code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); + + string callbackUrl = Url.Page("/Account/ResetPassword", + null, + new + { + area = "Identity", + code + }, + Request.Scheme); + + await emailSender.SendEmailAsync(Input.Email, + "Reset Password", + $"Please reset your password by clicking here."); + + return RedirectToPage("./ForgotPasswordConfirmation"); } - public class InputModel - { - [Required, EmailAddress] - public string Email { get; set; } - } + return Page(); + } + + public class InputModel + { + [Required] + [EmailAddress] + public string Email { get; set; } } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs index 59d780dd..22052a4a 100644 --- a/Marechai/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs @@ -1,11 +1,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class ForgotPasswordConfirmation : PageModel { - [AllowAnonymous] - public class ForgotPasswordConfirmation : PageModel - { - public void OnGet() {} - } + public void OnGet() {} } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Lockout.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/Lockout.cshtml.cs index e6dc2718..8ba868a7 100644 --- a/Marechai/Areas/Identity/Pages/Account/Lockout.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/Lockout.cshtml.cs @@ -1,11 +1,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class LockoutModel : PageModel { - [AllowAnonymous] - public class LockoutModel : PageModel - { - public void OnGet() {} - } + public void OnGet() {} } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Login.cshtml b/Marechai/Areas/Identity/Pages/Account/Login.cshtml index 5ad17629..8c06ba14 100644 --- a/Marechai/Areas/Identity/Pages/Account/Login.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/Login.cshtml @@ -1,4 +1,5 @@ @page +@using Microsoft.AspNetCore.Authentication @model LoginModel @{ @@ -10,22 +11,22 @@

Use a local account to log in.

-
+
- +
- +
@@ -50,7 +51,7 @@

Use another service to log in.

-
+
@{ if((Model.ExternalLogins?.Count ?? 0) == 0) { @@ -58,28 +59,32 @@

There are no external authentication services configured. See this article - for details on setting up this ASP.NET application to support logging in via external services. + for details on setting up this ASP.NET application to support logging in via external + services.

} else { - +

- @foreach(var provider in Model.ExternalLogins) + @foreach(AuthenticationScheme provider in Model.ExternalLogins) { - + }

-} + } }
@section Scripts { - + } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Login.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/Login.cshtml.cs index 2bfac00e..e6ed4353 100644 --- a/Marechai/Areas/Identity/Pages/Account/Login.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/Login.cshtml.cs @@ -11,103 +11,93 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; using SignInResult = Microsoft.AspNetCore.Identity.SignInResult; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class LoginModel + (SignInManager signInManager, ILogger logger, UserManager userManager) + : PageModel { - [AllowAnonymous] - public class LoginModel : PageModel + readonly UserManager _userManager = userManager; + + [BindProperty] + public InputModel Input { get; set; } + + public IList ExternalLogins { get; set; } + + public string ReturnUrl { get; set; } + + [TempData] + public string ErrorMessage { get; set; } + + public async Task OnGetAsync(string returnUrl = null) { - readonly ILogger _logger; - readonly SignInManager _signInManager; - readonly UserManager _userManager; + if(!string.IsNullOrEmpty(ErrorMessage)) ModelState.AddModelError(string.Empty, ErrorMessage); - public LoginModel(SignInManager signInManager, ILogger logger, - UserManager userManager) + returnUrl = returnUrl ?? Url.Content("~/"); + + // Clear the existing external cookie to ensure a clean login process + await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); + + ExternalLogins = (await signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); + + ReturnUrl = returnUrl; + } + + public async Task OnPostAsync(string returnUrl = null) + { + returnUrl = returnUrl ?? Url.Content("~/"); + + if(ModelState.IsValid) { - _userManager = userManager; - _signInManager = signInManager; - _logger = logger; - } + // This doesn't count login failures towards account lockout + // To enable password failures to trigger account lockout, set lockoutOnFailure: true + SignInResult result = + await signInManager.PasswordSignInAsync(Input.Username, Input.Password, Input.RememberMe, false); - [BindProperty] - public InputModel Input { get; set; } - - public IList ExternalLogins { get; set; } - - public string ReturnUrl { get; set; } - - [TempData] - public string ErrorMessage { get; set; } - - public async Task OnGetAsync(string returnUrl = null) - { - if(!string.IsNullOrEmpty(ErrorMessage)) + if(result.Succeeded) { - ModelState.AddModelError(string.Empty, ErrorMessage); + logger.LogInformation("User logged in."); + + return LocalRedirect(returnUrl); } - returnUrl = returnUrl ?? Url.Content("~/"); - - // Clear the existing external cookie to ensure a clean login process - await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); - - ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); - - ReturnUrl = returnUrl; - } - - public async Task OnPostAsync(string returnUrl = null) - { - returnUrl = returnUrl ?? Url.Content("~/"); - - if(ModelState.IsValid) + if(result.RequiresTwoFactor) { - // This doesn't count login failures towards account lockout - // To enable password failures to trigger account lockout, set lockoutOnFailure: true - SignInResult result = - await _signInManager.PasswordSignInAsync(Input.Username, Input.Password, Input.RememberMe, false); - - if(result.Succeeded) - { - _logger.LogInformation("User logged in."); - - return LocalRedirect(returnUrl); - } - - if(result.RequiresTwoFactor) - { - return RedirectToPage("./LoginWith2fa", new - { - ReturnUrl = returnUrl, - Input.RememberMe - }); - } - - if(result.IsLockedOut) - { - _logger.LogWarning("User account locked out."); - - return RedirectToPage("./Lockout"); - } - - ModelState.AddModelError(string.Empty, "Invalid login attempt."); - - return Page(); + return RedirectToPage("./LoginWith2fa", + new + { + ReturnUrl = returnUrl, + Input.RememberMe + }); } - // If we got this far, something failed, redisplay form + if(result.IsLockedOut) + { + logger.LogWarning("User account locked out."); + + return RedirectToPage("./Lockout"); + } + + ModelState.AddModelError(string.Empty, "Invalid login attempt."); + return Page(); } - public class InputModel - { - [Required] - public string Username { get; set; } + // If we got this far, something failed, redisplay form + return Page(); + } - [Required, DataType(DataType.Password)] - public string Password { get; set; } + public class InputModel + { + [Required] + public string Username { get; set; } - [Display(Name = "Remember me?")] - public bool RememberMe { get; set; } - } + [Required] + [DataType(DataType.Password)] + public string Password { get; set; } + + [Display(Name = "Remember me?")] + public bool RememberMe { get; set; } } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/LoginWith2fa.cshtml b/Marechai/Areas/Identity/Pages/Account/LoginWith2fa.cshtml index b2acddca..d5f28934 100644 --- a/Marechai/Areas/Identity/Pages/Account/LoginWith2fa.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/LoginWith2fa.cshtml @@ -4,22 +4,22 @@ ViewData["Title"] = "Two-factor authentication"; }

@ViewData["Title"]

-
+

Your login is protected with an authenticator app. Enter your authenticator code below.

- +
- +
@@ -32,9 +32,10 @@

Don't have access to your authenticator device? You can - log in with a recovery code. + log in with a + recovery code.

@section Scripts { - + } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs index 5756d6bd..1b4487fa 100644 --- a/Marechai/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs @@ -9,94 +9,80 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; using SignInResult = Microsoft.AspNetCore.Identity.SignInResult; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class LoginWith2faModel(SignInManager signInManager, ILogger logger) + : PageModel { - [AllowAnonymous] - public class LoginWith2faModel : PageModel + [BindProperty] + public InputModel Input { get; set; } + + public bool RememberMe { get; set; } + + public string ReturnUrl { get; set; } + + public async Task OnGetAsync(bool rememberMe, string returnUrl = null) { - readonly ILogger _logger; - readonly SignInManager _signInManager; + // Ensure the user has gone through the username & password screen first + ApplicationUser user = await signInManager.GetTwoFactorAuthenticationUserAsync(); - public LoginWith2faModel(SignInManager signInManager, ILogger logger) + if(user == null) throw new InvalidOperationException("Unable to load two-factor authentication user."); + + ReturnUrl = returnUrl; + RememberMe = rememberMe; + + return Page(); + } + + public async Task OnPostAsync(bool rememberMe, string returnUrl = null) + { + if(!ModelState.IsValid) return Page(); + + returnUrl = returnUrl ?? Url.Content("~/"); + + ApplicationUser user = await signInManager.GetTwoFactorAuthenticationUserAsync(); + + if(user == null) throw new InvalidOperationException("Unable to load two-factor authentication user."); + + string authenticatorCode = Input.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty); + + SignInResult result = + await signInManager.TwoFactorAuthenticatorSignInAsync(authenticatorCode, + rememberMe, + Input.RememberMachine); + + if(result.Succeeded) { - _signInManager = signInManager; - _logger = logger; + logger.LogInformation("User with ID '{UserId}' logged in with 2fa.", user.Id); + + return LocalRedirect(returnUrl); } - [BindProperty] - public InputModel Input { get; set; } - - public bool RememberMe { get; set; } - - public string ReturnUrl { get; set; } - - public async Task OnGetAsync(bool rememberMe, string returnUrl = null) + if(result.IsLockedOut) { - // Ensure the user has gone through the username & password screen first - ApplicationUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); + logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id); - if(user == null) - { - throw new InvalidOperationException("Unable to load two-factor authentication user."); - } - - ReturnUrl = returnUrl; - RememberMe = rememberMe; - - return Page(); + return RedirectToPage("./Lockout"); } - public async Task OnPostAsync(bool rememberMe, string returnUrl = null) - { - if(!ModelState.IsValid) - { - return Page(); - } + logger.LogWarning("Invalid authenticator code entered for user with ID '{UserId}'.", user.Id); + ModelState.AddModelError(string.Empty, "Invalid authenticator code."); - returnUrl = returnUrl ?? Url.Content("~/"); + return Page(); + } - ApplicationUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); + public class InputModel + { + [Required] + [StringLength(7, + ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", + MinimumLength = 6)] + [DataType(DataType.Text)] + [Display(Name = "Authenticator code")] + public string TwoFactorCode { get; set; } - if(user == null) - { - throw new InvalidOperationException("Unable to load two-factor authentication user."); - } - - string authenticatorCode = Input.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty); - - SignInResult result = - await _signInManager.TwoFactorAuthenticatorSignInAsync(authenticatorCode, rememberMe, - Input.RememberMachine); - - if(result.Succeeded) - { - _logger.LogInformation("User with ID '{UserId}' logged in with 2fa.", user.Id); - - return LocalRedirect(returnUrl); - } - - if(result.IsLockedOut) - { - _logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id); - - return RedirectToPage("./Lockout"); - } - - _logger.LogWarning("Invalid authenticator code entered for user with ID '{UserId}'.", user.Id); - ModelState.AddModelError(string.Empty, "Invalid authenticator code."); - - return Page(); - } - - public class InputModel - { - [Required, - StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", - MinimumLength = 6), DataType(DataType.Text), Display(Name = "Authenticator code")] - public string TwoFactorCode { get; set; } - - [Display(Name = "Remember this machine")] - public bool RememberMachine { get; set; } - } + [Display(Name = "Remember this machine")] + public bool RememberMachine { get; set; } } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml b/Marechai/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml index b6090f05..5867bdf5 100644 --- a/Marechai/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml @@ -1,10 +1,10 @@ @page @model LoginWithRecoveryCodeModel @{ - ViewData["Title"] = "Recovery code verification"; +ViewData["Title"] = "Recovery code verification"; }

@ViewData["Title"]

-
+

You have requested to log in with a recovery code. This login will not be remembered until you provide an authenticator app code at log in or disable 2FA and log in again. @@ -15,7 +15,7 @@

- +
@@ -24,5 +24,5 @@
@section Scripts { - + } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs index b3b9f41e..8800407d 100644 --- a/Marechai/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs @@ -9,83 +9,67 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; using SignInResult = Microsoft.AspNetCore.Identity.SignInResult; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class LoginWithRecoveryCodeModel + (SignInManager signInManager, ILogger logger) : PageModel { - [AllowAnonymous] - public class LoginWithRecoveryCodeModel : PageModel + [BindProperty] + public InputModel Input { get; set; } + + public string ReturnUrl { get; set; } + + public async Task OnGetAsync(string returnUrl = null) { - readonly ILogger _logger; - readonly SignInManager _signInManager; + // Ensure the user has gone through the username & password screen first + ApplicationUser user = await signInManager.GetTwoFactorAuthenticationUserAsync(); - public LoginWithRecoveryCodeModel(SignInManager signInManager, - ILogger logger) + if(user == null) throw new InvalidOperationException("Unable to load two-factor authentication user."); + + ReturnUrl = returnUrl; + + return Page(); + } + + public async Task OnPostAsync(string returnUrl = null) + { + if(!ModelState.IsValid) return Page(); + + ApplicationUser user = await signInManager.GetTwoFactorAuthenticationUserAsync(); + + if(user == null) throw new InvalidOperationException("Unable to load two-factor authentication user."); + + string recoveryCode = Input.RecoveryCode.Replace(" ", string.Empty); + + SignInResult result = await signInManager.TwoFactorRecoveryCodeSignInAsync(recoveryCode); + + if(result.Succeeded) { - _signInManager = signInManager; - _logger = logger; + logger.LogInformation("User with ID '{UserId}' logged in with a recovery code.", user.Id); + + return LocalRedirect(returnUrl ?? Url.Content("~/")); } + if(result.IsLockedOut) + { + logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id); + + return RedirectToPage("./Lockout"); + } + + logger.LogWarning("Invalid recovery code entered for user with ID '{UserId}' ", user.Id); + ModelState.AddModelError(string.Empty, "Invalid recovery code entered."); + + return Page(); + } + + public class InputModel + { [BindProperty] - public InputModel Input { get; set; } - - public string ReturnUrl { get; set; } - - public async Task OnGetAsync(string returnUrl = null) - { - // Ensure the user has gone through the username & password screen first - ApplicationUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - - if(user == null) - { - throw new InvalidOperationException("Unable to load two-factor authentication user."); - } - - ReturnUrl = returnUrl; - - return Page(); - } - - public async Task OnPostAsync(string returnUrl = null) - { - if(!ModelState.IsValid) - { - return Page(); - } - - ApplicationUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - - if(user == null) - { - throw new InvalidOperationException("Unable to load two-factor authentication user."); - } - - string recoveryCode = Input.RecoveryCode.Replace(" ", string.Empty); - - SignInResult result = await _signInManager.TwoFactorRecoveryCodeSignInAsync(recoveryCode); - - if(result.Succeeded) - { - _logger.LogInformation("User with ID '{UserId}' logged in with a recovery code.", user.Id); - - return LocalRedirect(returnUrl ?? Url.Content("~/")); - } - - if(result.IsLockedOut) - { - _logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id); - - return RedirectToPage("./Lockout"); - } - - _logger.LogWarning("Invalid recovery code entered for user with ID '{UserId}' ", user.Id); - ModelState.AddModelError(string.Empty, "Invalid recovery code entered."); - - return Page(); - } - - public class InputModel - { - [BindProperty, Required, DataType(DataType.Text), Display(Name = "Recovery Code")] - public string RecoveryCode { get; set; } - } + [Required] + [DataType(DataType.Text)] + [Display(Name = "Recovery Code")] + public string RecoveryCode { get; set; } } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Logout.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/Logout.cshtml.cs index 0896d6ea..cfa3b74e 100644 --- a/Marechai/Areas/Identity/Pages/Account/Logout.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/Logout.cshtml.cs @@ -6,33 +6,20 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -namespace Marechai.Areas.Identity.Pages.Account +namespace Marechai.Areas.Identity.Pages.Account; + +[AllowAnonymous] +public class LogoutModel(SignInManager signInManager, ILogger logger) : PageModel { - [AllowAnonymous] - public class LogoutModel : PageModel + public void OnGet() {} + + public async Task OnPost(string returnUrl = null) { - readonly ILogger _logger; - readonly SignInManager _signInManager; + await signInManager.SignOutAsync(); + logger.LogInformation("User logged out."); - public LogoutModel(SignInManager signInManager, ILogger logger) - { - _signInManager = signInManager; - _logger = logger; - } + if(returnUrl != null) return LocalRedirect(returnUrl); - public void OnGet() {} - - public async Task OnPost(string returnUrl = null) - { - await _signInManager.SignOutAsync(); - _logger.LogInformation("User logged out."); - - if(returnUrl != null) - { - return LocalRedirect(returnUrl); - } - - return RedirectToPage(); - } + return RedirectToPage(); } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml b/Marechai/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml index c799b83b..427c3697 100644 --- a/Marechai/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml @@ -1,28 +1,28 @@ @page @model ChangePasswordModel @{ - ViewData["Title"] = "Change password"; + ViewData["Title"] = "Change password"; ViewData["ActivePage"] = ManageNavPages.ChangePassword; }

@ViewData["Title"]

- +
- +
- +
- +
@@ -31,5 +31,5 @@
@section Scripts { - + } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs index 681dd9e0..bee5bbba 100644 --- a/Marechai/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs @@ -6,94 +6,78 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -namespace Marechai.Areas.Identity.Pages.Account.Manage +namespace Marechai.Areas.Identity.Pages.Account.Manage; + +public class ChangePasswordModel +( + UserManager userManager, + SignInManager signInManager, + ILogger logger +) : PageModel { - public class ChangePasswordModel : PageModel + [BindProperty] + public InputModel Input { get; set; } + + [TempData] + public string StatusMessage { get; set; } + + public async Task OnGetAsync() { - readonly ILogger _logger; - readonly SignInManager _signInManager; - readonly UserManager _userManager; + ApplicationUser user = await userManager.GetUserAsync(User); - public ChangePasswordModel(UserManager userManager, - SignInManager signInManager, ILogger logger) + if(user == null) return NotFound($"Unable to load user with ID '{userManager.GetUserId(User)}'."); + + bool hasPassword = await userManager.HasPasswordAsync(user); + + if(!hasPassword) return RedirectToPage("./SetPassword"); + + return Page(); + } + + public async Task OnPostAsync() + { + if(!ModelState.IsValid) return Page(); + + ApplicationUser user = await userManager.GetUserAsync(User); + + if(user == null) return NotFound($"Unable to load user with ID '{userManager.GetUserId(User)}'."); + + IdentityResult changePasswordResult = + await userManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword); + + if(!changePasswordResult.Succeeded) { - _userManager = userManager; - _signInManager = signInManager; - _logger = logger; - } - - [BindProperty] - public InputModel Input { get; set; } - - [TempData] - public string StatusMessage { get; set; } - - public async Task OnGetAsync() - { - ApplicationUser user = await _userManager.GetUserAsync(User); - - if(user == null) - { - return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - bool hasPassword = await _userManager.HasPasswordAsync(user); - - if(!hasPassword) - { - return RedirectToPage("./SetPassword"); - } + foreach(IdentityError error in changePasswordResult.Errors) + ModelState.AddModelError(string.Empty, error.Description); return Page(); } - public async Task OnPostAsync() - { - if(!ModelState.IsValid) - { - return Page(); - } + await signInManager.RefreshSignInAsync(user); + logger.LogInformation("User changed their password successfully."); + StatusMessage = "Your password has been changed."; - ApplicationUser user = await _userManager.GetUserAsync(User); + return RedirectToPage(); + } - if(user == null) - { - return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } + public class InputModel + { + [Required] + [DataType(DataType.Password)] + [Display(Name = "Current password")] + public string OldPassword { get; set; } - IdentityResult changePasswordResult = - await _userManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword); + [Required] + [StringLength(100, + ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", + MinimumLength = 6)] + [DataType(DataType.Password)] + [Display(Name = "New password")] + public string NewPassword { get; set; } - if(!changePasswordResult.Succeeded) - { - foreach(IdentityError error in changePasswordResult.Errors) - { - ModelState.AddModelError(string.Empty, error.Description); - } - - return Page(); - } - - await _signInManager.RefreshSignInAsync(user); - _logger.LogInformation("User changed their password successfully."); - StatusMessage = "Your password has been changed."; - - return RedirectToPage(); - } - - public class InputModel - { - [Required, DataType(DataType.Password), Display(Name = "Current password")] - public string OldPassword { get; set; } - - [Required, - StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", - MinimumLength = 6), DataType(DataType.Password), Display(Name = "New password")] - public string NewPassword { get; set; } - - [DataType(DataType.Password), Display(Name = "Confirm new password"), - Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } + [DataType(DataType.Password)] + [Display(Name = "Confirm new password")] + [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] + public string ConfirmPassword { get; set; } } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml b/Marechai/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml index 88473bf5..a1d6c6f0 100644 --- a/Marechai/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml @@ -1,7 +1,7 @@ @page @model DeletePersonalDataModel @{ - ViewData["Title"] = "Delete Personal Data"; + ViewData["Title"] = "Delete Personal Data"; ViewData["ActivePage"] = ManageNavPages.PersonalData; }

@ViewData["Title"]

@@ -17,7 +17,7 @@ {
- +
} @@ -26,5 +26,5 @@
@section Scripts { - + } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs b/Marechai/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs index fa00dcc6..ec1d22fb 100644 --- a/Marechai/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs +++ b/Marechai/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs @@ -7,82 +7,66 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -namespace Marechai.Areas.Identity.Pages.Account.Manage +namespace Marechai.Areas.Identity.Pages.Account.Manage; + +public class DeletePersonalDataModel +( + UserManager userManager, + SignInManager signInManager, + ILogger logger +) : PageModel { - public class DeletePersonalDataModel : PageModel + [BindProperty] + public InputModel Input { get; set; } + + public bool RequirePassword { get; set; } + + public async Task OnGet() { - readonly ILogger _logger; - readonly SignInManager _signInManager; - readonly UserManager _userManager; + ApplicationUser user = await userManager.GetUserAsync(User); - public DeletePersonalDataModel(UserManager userManager, - SignInManager signInManager, - ILogger logger) + if(user == null) return NotFound($"Unable to load user with ID '{userManager.GetUserId(User)}'."); + + RequirePassword = await userManager.HasPasswordAsync(user); + + return Page(); + } + + public async Task OnPostAsync() + { + ApplicationUser user = await userManager.GetUserAsync(User); + + if(user == null) return NotFound($"Unable to load user with ID '{userManager.GetUserId(User)}'."); + + RequirePassword = await userManager.HasPasswordAsync(user); + + if(RequirePassword) { - _userManager = userManager; - _signInManager = signInManager; - _logger = logger; + if(!await userManager.CheckPasswordAsync(user, Input.Password)) + { + ModelState.AddModelError(string.Empty, "Incorrect password."); + + return Page(); + } } - [BindProperty] - public InputModel Input { get; set; } + IdentityResult result = await userManager.DeleteAsync(user); + string userId = await userManager.GetUserIdAsync(user); - public bool RequirePassword { get; set; } + if(!result.Succeeded) + throw new InvalidOperationException($"Unexpected error occurred deleting user with ID '{userId}'."); - public async Task OnGet() - { - ApplicationUser user = await _userManager.GetUserAsync(User); + await signInManager.SignOutAsync(); - if(user == null) - { - return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } + logger.LogInformation("User with ID '{UserId}' deleted themselves.", userId); - RequirePassword = await _userManager.HasPasswordAsync(user); + return Redirect("~/"); + } - return Page(); - } - - public async Task OnPostAsync() - { - ApplicationUser user = await _userManager.GetUserAsync(User); - - if(user == null) - { - return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - RequirePassword = await _userManager.HasPasswordAsync(user); - - if(RequirePassword) - { - if(!await _userManager.CheckPasswordAsync(user, Input.Password)) - { - ModelState.AddModelError(string.Empty, "Incorrect password."); - - return Page(); - } - } - - IdentityResult result = await _userManager.DeleteAsync(user); - string userId = await _userManager.GetUserIdAsync(user); - - if(!result.Succeeded) - { - throw new InvalidOperationException($"Unexpected error occurred deleting user with ID '{userId}'."); - } - - await _signInManager.SignOutAsync(); - - _logger.LogInformation("User with ID '{UserId}' deleted themselves.", userId); - - return Redirect("~/"); - } - - public class InputModel - { - [Required, DataType(DataType.Password)] - public string Password { get; set; } - } + public class InputModel + { + [Required] + [DataType(DataType.Password)] + public string Password { get; set; } } } \ No newline at end of file diff --git a/Marechai/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml b/Marechai/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml index c41bd904..3247ee49 100644 --- a/Marechai/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml +++ b/Marechai/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml @@ -1,10 +1,10 @@ @page @model Disable2faModel @{ - ViewData["Title"] = "Disable two-factor authentication (2FA)"; + ViewData["Title"] = "Disable two-factor authentication (2FA)"; ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication; } - +

@ViewData["Title"]

@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
@if(!_editing) { -
+

@L["Resolutions supported by this graphical processing unit"]

- + + + @if(_addingResolution) {
@L["Resolutions"] - - + +
} + @if(_gpuResolutions?.Count > 0) {
@@ -290,7 +291,7 @@ - @foreach(var item in _gpuResolutions) + @foreach(ResolutionByGpuViewModel item in _gpuResolutions) { @@ -312,7 +313,8 @@ @item.Resolution.Grayscale - + } @@ -322,18 +324,20 @@ } - + @_deleteTitle - + @_deleteText - + - } \ No newline at end of file + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Gpu.razor.cs b/Marechai/Pages/Admin/Details/Gpu.razor.cs index 18e674ff..c2d80b04 100644 --- a/Marechai/Pages/Admin/Details/Gpu.razor.cs +++ b/Marechai/Pages/Admin/Details/Gpu.razor.cs @@ -33,265 +33,254 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class Gpu { - public partial class Gpu + bool _addingResolution; + int? _addingResolutionId; + AuthenticationState _authState; + List _companies; + bool _creating; + ResolutionByGpuViewModel _currentResolution; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _editing; + Modal _frmDelete; + List _gpuResolutions; + bool _loaded; + GpuViewModel _model; + bool _prototype; + List _resolutions; + bool _savingResolution; + bool _unknownCompany; + bool _unknownDieSize; + bool _unknownIntroduced; + bool _unknownModelCode; + bool _unknownPackage; + bool _unknownProcess; + bool _unknownProcessNm; + bool _unknownTransistors; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - bool _addingResolution; - int? _addingResolutionId; - AuthenticationState _authState; - List _companies; - bool _creating; - ResolutionByGpuViewModel _currentResolution; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _editing; - Modal _frmDelete; - List _gpuResolutions; - bool _loaded; - GpuViewModel _model; - bool _prototype; - List _resolutions; - bool _savingResolution; - bool _unknownCompany; - bool _unknownDieSize; - bool _unknownIntroduced; - bool _unknownModelCode; - bool _unknownPackage; - bool _unknownProcess; - bool _unknownProcessNm; - bool _unknownTransistors; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/gpus/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _companies = await CompaniesService.GetAsync(); + _model = _creating ? new GpuViewModel() : await Service.GetAsync(Id); + _resolutions = await ResolutionsService.GetAsync(); + _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/gpus/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownCompany = !_model.CompanyId.HasValue; + _unknownDieSize = !_model.DieSize.HasValue; + _unknownIntroduced = !_model.Introduced.HasValue; + _unknownModelCode = string.IsNullOrWhiteSpace(_model.ModelCode); + _unknownPackage = string.IsNullOrWhiteSpace(_model.Package); + _unknownProcess = string.IsNullOrWhiteSpace(_model.Process); + _unknownProcessNm = !_model.ProcessNm.HasValue; + _unknownTransistors = !_model.Transistors.HasValue; + _prototype = _model.Introduced?.Year == 1000; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - if(_loaded) - return; + NavigationManager.ToBaseRelativePath("admin/document_people"); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/gpus/create", StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _companies = await CompaniesService.GetAsync(); - _model = _creating ? new GpuViewModel() : await Service.GetAsync(Id); - _resolutions = await ResolutionsService.GetAsync(); - _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/gpus/edit/", StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownCompany) + _model.CompanyId = null; + else if(_model.CompanyId < 0) return; + + if(_unknownModelCode) + _model.ModelCode = null; + else if(string.IsNullOrWhiteSpace(_model.ModelCode)) return; + + if(_unknownIntroduced) + _model.Introduced = null; + else if(_prototype) + _model.Introduced = new DateTime(1000, 1, 1); + else if(_model.Introduced >= DateTime.UtcNow.Date) return; + + if(_unknownPackage) + _model.Package = null; + else if(string.IsNullOrWhiteSpace(_model.Package)) return; + + if(_unknownProcess) + _model.Process = null; + else if(string.IsNullOrWhiteSpace(_model.Process)) return; + + if(_unknownProcessNm) + _model.ProcessNm = null; + else if(_model.ProcessNm < 1) return; + + if(_unknownDieSize) + _model.DieSize = null; + else if(_model.DieSize < 1) return; + + if(_unknownTransistors) + _model.Transistors = null; + else if(_model.Transistors < 0) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Name must be 50 characters or less."], 50); + + void ValidateModelCode(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Model code must be 45 characters or less."], 45); + + void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); + + void ValidatePackage(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Package must be 45 characters or less."], 45); + + void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e); + + void ValidateFloatBiggerThanOne(ValidatorEventArgs e) => Validators.ValidateFloat(e, 1); + + void ValidateProcess(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Process must be 45 characters or less."], 45); + + void ShowResolutionDeleteModal(long itemId) + { + _currentResolution = _gpuResolutions.FirstOrDefault(n => n.Id == itemId); + _deleteTitle = L["Delete resolution from this graphical processing unit"]; + + _deleteText = + string.Format(L["Are you sure you want to delete the resolution {0} from this graphical processing unit?"], + _currentResolution); + + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentResolution is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ResolutionsByGpuService.DeleteAsync(_currentResolution.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _currentResolution = null; + } + + void OnAddResolutionClick() + { + _addingResolution = true; + _savingResolution = false; + _addingResolutionId = _resolutions.First().Id; + } + + void CancelAddResolution() + { + _addingResolution = false; + _savingResolution = false; + _addingResolutionId = null; + } + + async Task ConfirmAddResolution() + { + if(_addingResolutionId is null || _addingResolutionId <= 0) { - _unknownCompany = !_model.CompanyId.HasValue; - _unknownDieSize = !_model.DieSize.HasValue; - _unknownIntroduced = !_model.Introduced.HasValue; - _unknownModelCode = string.IsNullOrWhiteSpace(_model.ModelCode); - _unknownPackage = string.IsNullOrWhiteSpace(_model.Package); - _unknownProcess = string.IsNullOrWhiteSpace(_model.Process); - _unknownProcessNm = !_model.ProcessNm.HasValue; - _unknownTransistors = !_model.Transistors.HasValue; - _prototype = _model.Introduced?.Year == 1000; + CancelAddResolution(); + + return; } - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } + _savingResolution = true; - async void OnCancelClicked() - { - _editing = false; + // Yield thread to let UI to update + await Task.Yield(); - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/document_people"); + await ResolutionsByGpuService.CreateAsync(_addingResolutionId.Value, + Id, + (await UserManager.GetUserAsync(_authState.User)).Id); - return; - } + _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + _addingResolution = false; + _savingResolution = false; + _addingResolutionId = null; - async void OnSaveClicked() - { - if(_unknownCompany) - _model.CompanyId = null; - else if(_model.CompanyId < 0) - return; + // Yield thread to let UI to update + await Task.Yield(); - if(_unknownModelCode) - _model.ModelCode = null; - else if(string.IsNullOrWhiteSpace(_model.ModelCode)) - return; - - if(_unknownIntroduced) - _model.Introduced = null; - else if(_prototype) - _model.Introduced = new DateTime(1000, 1, 1); - else if(_model.Introduced >= DateTime.UtcNow.Date) - return; - - if(_unknownPackage) - _model.Package = null; - else if(string.IsNullOrWhiteSpace(_model.Package)) - return; - - if(_unknownProcess) - _model.Process = null; - else if(string.IsNullOrWhiteSpace(_model.Process)) - return; - - if(_unknownProcessNm) - _model.ProcessNm = null; - else if(_model.ProcessNm < 1) - return; - - if(_unknownDieSize) - _model.DieSize = null; - else if(_model.DieSize < 1) - return; - - if(_unknownTransistors) - _model.Transistors = null; - else if(_model.Transistors < 0) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Name must be 50 characters or less."], 50); - - void ValidateModelCode(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Model code must be 45 characters or less."], 45); - - void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); - - void ValidatePackage(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Package must be 45 characters or less."], 45); - - void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e); - - void ValidateFloatBiggerThanOne(ValidatorEventArgs e) => Validators.ValidateFloat(e, 1); - - void ValidateProcess(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Process must be 45 characters or less."], 45); - - void ShowResolutionDeleteModal(long itemId) - { - _currentResolution = _gpuResolutions.FirstOrDefault(n => n.Id == itemId); - _deleteTitle = L["Delete resolution from this graphical processing unit"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the resolution {0} from this graphical processing unit?"], - _currentResolution); - - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentResolution is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await ResolutionsByGpuService.DeleteAsync(_currentResolution.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _currentResolution = null; - } - - void OnAddResolutionClick() - { - _addingResolution = true; - _savingResolution = false; - _addingResolutionId = _resolutions.First().Id; - } - - void CancelAddResolution() - { - _addingResolution = false; - _savingResolution = false; - _addingResolutionId = null; - } - - async Task ConfirmAddResolution() - { - if(_addingResolutionId is null || - _addingResolutionId <= 0) - { - CancelAddResolution(); - - return; - } - - _savingResolution = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await ResolutionsByGpuService.CreateAsync(_addingResolutionId.Value, Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _gpuResolutions = await ResolutionsByGpuService.GetByGpu(Id); - - _addingResolution = false; - _savingResolution = false; - _addingResolutionId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/InstructionSet.razor b/Marechai/Pages/Admin/Details/InstructionSet.razor index 069983f7..4cfb9bcf 100644 --- a/Marechai/Pages/Admin/Details/InstructionSet.razor +++ b/Marechai/Pages/Admin/Details/InstructionSet.razor @@ -32,11 +32,11 @@ @inherits OwningComponentBase @inject IStringLocalizer L @attribute [Authorize(Roles = "UberAdmin, Admin")] -@inject NavigationManager NavigationManager -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject NavigationManager NavigationManager +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider

@L["Instruction set details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -59,11 +59,12 @@ @if(!_editing) { -} + } else { + -} + } @L["Back to list"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/InstructionSet.razor.cs b/Marechai/Pages/Admin/Details/InstructionSet.razor.cs index d99ab893..20bdccc6 100644 --- a/Marechai/Pages/Admin/Details/InstructionSet.razor.cs +++ b/Marechai/Pages/Admin/Details/InstructionSet.razor.cs @@ -30,94 +30,87 @@ using Marechai.Shared; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class InstructionSet { - public partial class InstructionSet + AuthenticationState _authState; + bool _creating; + bool _editing; + bool _loaded; + Database.Models.InstructionSet _model; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - AuthenticationState _authState; - bool _creating; - bool _editing; - bool _loaded; - Database.Models.InstructionSet _model; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/instruction_sets/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _model = _creating ? new Database.Models.InstructionSet() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/instruction_sets/edit/", StringComparison.InvariantCulture); + + StateHasChanged(); + } + + void OnEditClicked() + { + _editing = true; + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - if(_loaded) - return; + NavigationManager.ToBaseRelativePath("admin/instruction_sets"); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/instruction_sets/create", - StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _model = _creating ? new Database.Models.InstructionSet() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/instruction_sets/edit/", - StringComparison.InvariantCulture); - - StateHasChanged(); + return; } - void OnEditClicked() - { - _editing = true; - StateHasChanged(); - } + _model = await Service.GetAsync(Id); + StateHasChanged(); + } - async void OnCancelClicked() - { - _editing = false; + async void OnSaveClicked() + { + if(string.IsNullOrWhiteSpace(_model.Name) || _model.Name.Length > 45 || !Service.VerifyUnique(_model.Name)) + return; - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/instruction_sets"); + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - return; - } + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + StateHasChanged(); + } - _model = await Service.GetAsync(Id); - StateHasChanged(); - } + void ValidateName(ValidatorEventArgs e) + { + Validators.ValidateString(e, L["Instruction set name cannot contain more than 45 characters."], 45); - async void OnSaveClicked() - { - if(string.IsNullOrWhiteSpace(_model.Name) || - _model.Name.Length > 45 || - !Service.VerifyUnique(_model.Name)) - return; + if(e.Status != ValidationStatus.Success) return; - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + if(Service.VerifyUnique(_model.Name)) return; - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - StateHasChanged(); - } - - void ValidateName(ValidatorEventArgs e) - { - Validators.ValidateString(e, L["Instruction set name cannot contain more than 45 characters."], 45); - - if(e.Status != ValidationStatus.Success) - return; - - if(Service.VerifyUnique(_model.Name)) - return; - - e.Status = ValidationStatus.Error; - e.ErrorText = L["Instruction set name must be unique."]; - } + e.Status = ValidationStatus.Error; + e.ErrorText = L["Instruction set name must be unique."]; } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/InstructionSetExtension.razor b/Marechai/Pages/Admin/Details/InstructionSetExtension.razor index c09c6c16..dee14f0b 100644 --- a/Marechai/Pages/Admin/Details/InstructionSetExtension.razor +++ b/Marechai/Pages/Admin/Details/InstructionSetExtension.razor @@ -32,11 +32,11 @@ @inherits OwningComponentBase @inject IStringLocalizer L @attribute [Authorize(Roles = "UberAdmin, Admin")] -@inject NavigationManager NavigationManager -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject NavigationManager NavigationManager +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider

@L["Instruction set extension details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -59,11 +59,12 @@ @if(!_editing) { -} + } else { + -} + } @L["Back to list"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/InstructionSetExtension.razor.cs b/Marechai/Pages/Admin/Details/InstructionSetExtension.razor.cs index 0f5a829a..53cc4292 100644 --- a/Marechai/Pages/Admin/Details/InstructionSetExtension.razor.cs +++ b/Marechai/Pages/Admin/Details/InstructionSetExtension.razor.cs @@ -30,94 +30,91 @@ using Marechai.Shared; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class InstructionSetExtension { - public partial class InstructionSetExtension + AuthenticationState _authState; + bool _creating; + bool _editing; + bool _loaded; + Database.Models.InstructionSetExtension _model; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - AuthenticationState _authState; - bool _creating; - bool _editing; - bool _loaded; - Database.Models.InstructionSetExtension _model; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/instruction_set_extensions/create", + StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _model = _creating ? new Database.Models.InstructionSetExtension() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/instruction_set_extensions/edit/", + StringComparison.InvariantCulture); + + StateHasChanged(); + } + + void OnEditClicked() + { + _editing = true; + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - if(_loaded) - return; + NavigationManager.ToBaseRelativePath("admin/instruction_set_extensions"); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/instruction_set_extensions/create", - StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _model = _creating ? new Database.Models.InstructionSetExtension() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/instruction_set_extensions/edit/", - StringComparison.InvariantCulture); - - StateHasChanged(); + return; } - void OnEditClicked() - { - _editing = true; - StateHasChanged(); - } + _model = await Service.GetAsync(Id); + StateHasChanged(); + } - async void OnCancelClicked() - { - _editing = false; + async void OnSaveClicked() + { + if(string.IsNullOrWhiteSpace(_model.Extension) || + _model.Extension.Length > 45 || + !Service.VerifyUnique(_model.Extension)) + return; - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/instruction_set_extensions"); + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - return; - } + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + StateHasChanged(); + } - _model = await Service.GetAsync(Id); - StateHasChanged(); - } + void ValidateName(ValidatorEventArgs e) + { + Validators.ValidateString(e, L["Extension name cannot contain more than 45 characters."], 45); - async void OnSaveClicked() - { - if(string.IsNullOrWhiteSpace(_model.Extension) || - _model.Extension.Length > 45 || - !Service.VerifyUnique(_model.Extension)) - return; + if(e.Status != ValidationStatus.Success) return; - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + if(Service.VerifyUnique(_model.Extension)) return; - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - StateHasChanged(); - } - - void ValidateName(ValidatorEventArgs e) - { - Validators.ValidateString(e, L["Extension name cannot contain more than 45 characters."], 45); - - if(e.Status != ValidationStatus.Success) - return; - - if(Service.VerifyUnique(_model.Extension)) - return; - - e.Status = ValidationStatus.Error; - e.ErrorText = L["Extension name must be unique."]; - } + e.Status = ValidationStatus.Error; + e.ErrorText = L["Extension name must be unique."]; } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/License.razor b/Marechai/Pages/Admin/Details/License.razor index fe6bee5c..a1112e91 100644 --- a/Marechai/Pages/Admin/Details/License.razor +++ b/Marechai/Pages/Admin/Details/License.razor @@ -31,12 +31,12 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject NavigationManager NavigationManager -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject NavigationManager NavigationManager +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["License details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -66,11 +66,11 @@ @L["FSF approved"] - + @L["OSI approved"] - + @if(_editing || _model.Link != null) { @@ -79,9 +79,8 @@ @if(_editing) { @L["Unknown or none (text link)"] -} - @if(!_editing || - !_unknownLink) + } + @if(!_editing || !_unknownLink) { @@ -90,9 +89,9 @@ -} + } -} + } @if(_editing || _model.Text != null) { @@ -100,9 +99,8 @@ @if(_editing) { @L["Unknown (license text)"] -} - @if(!_editing || - !_unknownText) + } + @if(!_editing || !_unknownText) { @@ -111,19 +109,20 @@ -} + } -} + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/License.razor.cs b/Marechai/Pages/Admin/Details/License.razor.cs index 46efebd6..0ea597a6 100644 --- a/Marechai/Pages/Admin/Details/License.razor.cs +++ b/Marechai/Pages/Admin/Details/License.razor.cs @@ -30,119 +30,109 @@ using Marechai.Shared; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class License { - public partial class License + AuthenticationState _authState; + bool _creating; + bool _editing; + bool _loaded; + Database.Models.License _model; + bool _unknownLink; + bool _unknownText; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - AuthenticationState _authState; - bool _creating; - bool _editing; - bool _loaded; - Database.Models.License _model; - bool _unknownLink; - bool _unknownText; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; + _loaded = true; - _loaded = true; + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/licenses/create", StringComparison.InvariantCulture); - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/licenses/create", StringComparison.InvariantCulture); + if(Id <= 0 && !_creating) return; - if(Id <= 0 && - !_creating) - return; + _model = _creating ? new Database.Models.License() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _model = _creating ? new Database.Models.License() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/licenses/edit/", StringComparison.InvariantCulture); - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/licenses/edit/", - StringComparison.InvariantCulture); + if(_editing) SetCheckboxes(); - if(_editing) - SetCheckboxes(); - - StateHasChanged(); - } - - void SetCheckboxes() - { - _unknownText = string.IsNullOrWhiteSpace(_model.Text); - _unknownLink = string.IsNullOrWhiteSpace(_model.Link); - } - - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } - - async void OnCancelClicked() - { - _editing = false; - - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/licenses"); - - return; - } - - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - async void OnSaveClicked() - { - if(_unknownText) - _model.Text = null; - else if(string.IsNullOrWhiteSpace(_model.Text)) - return; - - if(string.IsNullOrWhiteSpace(_model.Text) || - _model.Name?.Length > 255) - return; - - if(string.IsNullOrWhiteSpace(_model.SPDX) || - _model.SPDX?.Length > 255) - return; - - if(_unknownLink) - _model.Link = null; - else if(string.IsNullOrWhiteSpace(_model.Link) || - _model.Link?.Length > 512) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["License name cannot contain more than 255 characters."], 255); - - void ValidateSpdx(ValidatorEventArgs e) => - Validators.ValidateString(e, L["SPDX identifier cannot contain more than 255 characters."], 255); - - void ValidateLink(ValidatorEventArgs e) => - Validators.ValidateUrl(e, L["License text link must be smaller than 512 characters."], 512); - - void ValidateText(ValidatorEventArgs e) => - Validators.ValidateString(e, L["License text cannot contain more than 131072 characters."], 131072); + StateHasChanged(); } + + void SetCheckboxes() + { + _unknownText = string.IsNullOrWhiteSpace(_model.Text); + _unknownLink = string.IsNullOrWhiteSpace(_model.Link); + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) + { + NavigationManager.ToBaseRelativePath("admin/licenses"); + + return; + } + + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownText) + _model.Text = null; + else if(string.IsNullOrWhiteSpace(_model.Text)) return; + + if(string.IsNullOrWhiteSpace(_model.Text) || _model.Name?.Length > 255) return; + + if(string.IsNullOrWhiteSpace(_model.SPDX) || _model.SPDX?.Length > 255) return; + + if(_unknownLink) + _model.Link = null; + else if(string.IsNullOrWhiteSpace(_model.Link) || _model.Link?.Length > 512) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["License name cannot contain more than 255 characters."], 255); + + void ValidateSpdx(ValidatorEventArgs e) => + Validators.ValidateString(e, L["SPDX identifier cannot contain more than 255 characters."], 255); + + void ValidateLink(ValidatorEventArgs e) => + Validators.ValidateUrl(e, L["License text link must be smaller than 512 characters."], 512); + + void ValidateText(ValidatorEventArgs e) => + Validators.ValidateString(e, L["License text cannot contain more than 131072 characters."], 131072); } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Machine.razor b/Marechai/Pages/Admin/Details/Machine.razor index 1bfd9735..a701f5dd 100644 --- a/Marechai/Pages/Admin/Details/Machine.razor +++ b/Marechai/Pages/Admin/Details/Machine.razor @@ -28,29 +28,29 @@ @page "/admin/machines/details/{Id:int}" @page "/admin/machines/edit/{Id:int}" @page "/admin/machines/create" -@using Marechai.Database.Models @using Marechai.Database +@using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject CompaniesService CompaniesService -@inject MachineFamiliesService MachineFamiliesService -@inject NavigationManager NavigationManager -@inject GpusByMachineService GpusByMachineService -@inject GpusService GpusService -@inject SoundSynthsByMachineService SoundSynthsByMachineService -@inject SoundSynthsService SoundSynthsService -@inject ProcessorsByMachineService ProcessorsByMachineService -@inject ProcessorsService ProcessorsService -@inject MemoriesByMachineService MemoriesByMachineService -@inject StorageByMachineService StorageByMachineService -@inject ScreensByMachineService ScreensByMachineService -@inject ScreensService ScreensService -@inject MachinePhotosService MachinePhotosService -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject CompaniesService CompaniesService +@inject MachineFamiliesService MachineFamiliesService +@inject NavigationManager NavigationManager +@inject GpusByMachineService GpusByMachineService +@inject GpusService GpusService +@inject SoundSynthsByMachineService SoundSynthsByMachineService +@inject SoundSynthsService SoundSynthsService +@inject ProcessorsByMachineService ProcessorsByMachineService +@inject ProcessorsService ProcessorsService +@inject MemoriesByMachineService MemoriesByMachineService +@inject StorageByMachineService StorageByMachineService +@inject ScreensByMachineService ScreensByMachineService +@inject ScreensService ScreensService +@inject MachinePhotosService MachinePhotosService +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Machine details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -61,10 +61,10 @@ @L["Company"] @@ -83,7 +83,7 @@ @foreach(int type in Enum.GetValues(typeof(MachineType))) { @(((MachineType)type).ToString()) -} + } @if(_editing || _model.Model != null) @@ -93,9 +93,8 @@ @if(_editing) { @L["Unknown (model)"] -} - @if(!_editing || - !_unknownModel) + } + @if(!_editing || !_unknownModel) { @@ -104,20 +103,21 @@ -} + } -} + } @if(_editing || _model.Introduced.HasValue) { @L["Introduced (public release)"] @if(_editing) { - @L["Unknown (introduction date)"] + @L["Unknown (introduction date)"] + @L["Prototype"] -} - @if(!_editing || - !_prototype && !_unknownIntroduced) + } + @if(!_editing || !_prototype && !_unknownIntroduced) { @@ -126,9 +126,9 @@ -} + } -} + } @if(_editing || _model.FamilyId != null) { @@ -136,53 +136,56 @@ @if(_editing) { @L["No family"] -} - @if(!_editing || - !_noFamily) + } + @if(!_editing || !_noFamily) { -} + } -} + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
@if(!_editing) { -
+

@L["Graphical processing units belonging to this machine"]

+ + @if(_addingGpu) {
@L["Graphical processing units"]
} + @if(_machineGpus?.Count > 0) {
@@ -199,7 +202,7 @@ - @foreach(var item in _machineGpus) + @foreach(GpuByMachineViewModel item in _machineGpus) { @@ -209,7 +212,8 @@ @item.Name - + } @@ -218,25 +222,30 @@
} -
+

@L["Sound synthesizers belonging to this machine"]

- + + + @if(_addingSound) {
@L["Sound synthesizers"]
} + @if(_machineSound?.Count > 0) {
@@ -253,7 +262,7 @@ - @foreach(var item in _machineSound) + @foreach(SoundSynthByMachineViewModel item in _machineSound) { @@ -263,7 +272,8 @@ @item.Name - + } @@ -272,24 +282,28 @@
} -
+

@L["Processors belonging to this machine"]

- + + + @if(_addingCpu) {
@L["Processors"] @L["Nominal speed (MHz)"] - @L["Unknown (processor by machine speed)"] + @L["Unknown (processor by machine speed)"] @if(!_unknownProcessorSpeed) { @@ -299,12 +313,13 @@ -} + }
} + @if(_machineCpus?.Count > 0) {
@@ -324,7 +339,7 @@ - @foreach(var item in _machineCpus) + @foreach(ProcessorByMachineViewModel item in _machineCpus) { @@ -337,7 +352,8 @@ @string.Format(L["{0:F3} MHz"], item.Speed) - + } @@ -346,9 +362,12 @@
} -
+

@L["Memory belonging to this machine"]

- + + + @if(_addingMemory) {
@@ -358,7 +377,7 @@ @foreach(int type in Enum.GetValues(typeof(MemoryType))) { @(((MemoryType)type).ToString()) -} + } @@ -367,12 +386,13 @@ @foreach(int usage in Enum.GetValues(typeof(MemoryUsage))) { @(((MemoryUsage)usage).ToString()) -} + } @L["Nominal speed (Hz)"] - @L["Unknown (memory by machine speed)"] + @L["Unknown (memory by machine speed)"] @if(!_unknownMemorySpeed) { @@ -382,7 +402,7 @@ -} + } @L["Memory size (bytes)"] @@ -396,12 +416,13 @@ -} + }
} + @if(_machineMemories?.Count > 0) {
@@ -424,7 +445,7 @@ - @foreach(var item in _machineMemories) + @foreach(MemoryByMachineViewModel item in _machineMemories) { @@ -454,7 +475,8 @@ } - + } @@ -463,9 +485,12 @@
} -
+

@L["Storage belonging to this machine"]

- + + + @if(_addingStorage) {
@@ -475,7 +500,7 @@ @foreach(int type in Enum.GetValues(typeof(StorageType))) { @(((StorageType)type).ToString()) -} + } @@ -484,12 +509,13 @@ @foreach(int usage in Enum.GetValues(typeof(StorageInterface))) { @(((StorageInterface)usage).ToString()) -} + } @L["Nominal capacity (bytes)"] - @L["Unknown or empty (storage by machine nominal capacity)"] + @L["Unknown or empty (storage by machine nominal capacity)"] @if(!_unknownStorageSize) { @@ -499,12 +525,13 @@ -} + }
} + @if(_machineStorage?.Count > 0) {
@@ -524,7 +551,7 @@ - @foreach(var item in _machineStorage) + @foreach(StorageByMachineViewModel item in _machineStorage) { @@ -544,7 +571,8 @@ } - + } @@ -553,21 +581,25 @@
} -
+

@L["Screens attached to this machine"]

- + + + @if(_addingScreen) {
@L["Screens"] @@ -575,6 +607,7 @@
} + @if(_machineScreens?.Count > 0) {
@@ -603,7 +636,7 @@ - @foreach(var item in _machineScreens) + @foreach(ScreenByMachineViewModel item in _machineScreens) { @@ -625,7 +658,8 @@ @item.Screen.NativeResolution - + } @@ -635,34 +669,46 @@ } - + @_deleteTitle - + @_deleteText - + @if(_photos.Count > 0) { - foreach(var photo in _photos) + foreach(Guid photo in _photos) {
- - - - - + + + + +
@L["Details"] diff --git a/Marechai/Pages/Admin/Details/Machine.razor.cs b/Marechai/Pages/Admin/Details/Machine.razor.cs index d122205e..0ecb0da3 100644 --- a/Marechai/Pages/Admin/Details/Machine.razor.cs +++ b/Marechai/Pages/Admin/Details/Machine.razor.cs @@ -34,768 +34,764 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class Machine { - public partial class Machine + bool _addingCpu; + int? _addingCpuId; + bool _addingGpu; + int? _addingGpuId; + bool _addingMemory; + long? _addingMemorySize; + double? _addingMemorySpeed; + int _addingMemoryType; + int _addingMemoryUsage; + float? _addingProcessorSpeed; + bool _addingScreen; + int? _addingScreenId; + bool _addingSound; + int? _addingSoundId; + bool _addingStorage; + int _addingStorageInterface; + long? _addingStorageSize; + int _addingStorageType; + AuthenticationState _authState; + List _companies; + List _cpus; + bool _creating; + ProcessorByMachineViewModel _currentCpuByMachine; + GpuByMachineViewModel _currentGpuByMachine; + MemoryByMachineViewModel _currentMemoryByMachine; + ScreenByMachineViewModel _currentScreenByMachine; + SoundSynthByMachineViewModel _currentSoundByMachine; + StorageByMachineViewModel _currentStorageByMachine; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _deletingCpuByMachine; + bool _deletingGpuByMachine; + bool _deletingMemoryByMachine; + bool _deletingScreenByMachine; + bool _deletingSoundByMachine; + bool _deletingStorageByMachine; + bool _editing; + List _families; + Modal _frmDelete; + List _gpus; + bool _loaded; + List _machineCpus; + List _machineGpus; + List _machineMemories; + List _machineScreens; + List _machineSound; + List _machineStorage; + MachineViewModel _model; + bool _noFamily; + List _photos; + bool _prototype; + bool _savingCpu; + bool _savingGpu; + bool _savingMemory; + bool _savingScreen; + bool _savingSound; + bool _savingStorage; + List _screens; + List _soundSynths; + bool _unknownIntroduced; + bool _unknownMemorySize; + bool _unknownMemorySpeed; + bool _unknownModel; + bool _unknownProcessorSpeed; + bool _unknownStorageSize; + [Parameter] + public int Id { get; set; } + + int Type { - bool _addingCpu; - int? _addingCpuId; - bool _addingGpu; - int? _addingGpuId; - bool _addingMemory; - long? _addingMemorySize; - double? _addingMemorySpeed; - int _addingMemoryType; - int _addingMemoryUsage; - float? _addingProcessorSpeed; - bool _addingScreen; - int? _addingScreenId; - bool _addingSound; - int? _addingSoundId; - bool _addingStorage; - int _addingStorageInterface; - long? _addingStorageSize; - int _addingStorageType; - AuthenticationState _authState; - List _companies; - List _cpus; - bool _creating; - ProcessorByMachineViewModel _currentCpuByMachine; - GpuByMachineViewModel _currentGpuByMachine; - MemoryByMachineViewModel _currentMemoryByMachine; - ScreenByMachineViewModel _currentScreenByMachine; - SoundSynthByMachineViewModel _currentSoundByMachine; - StorageByMachineViewModel _currentStorageByMachine; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _deletingCpuByMachine; - bool _deletingGpuByMachine; - bool _deletingMemoryByMachine; - bool _deletingScreenByMachine; - bool _deletingSoundByMachine; - bool _deletingStorageByMachine; - bool _editing; - List _families; - Modal _frmDelete; - List _gpus; - bool _loaded; - List _machineCpus; - List _machineGpus; - List _machineMemories; - List _machineScreens; - List _machineSound; - List _machineStorage; - MachineViewModel _model; - bool _noFamily; - List _photos; - bool _prototype; - bool _savingCpu; - bool _savingGpu; - bool _savingMemory; - bool _savingScreen; - bool _savingSound; - bool _savingStorage; - List _screens; - List _soundSynths; - bool _unknownIntroduced; - bool _unknownMemorySize; - bool _unknownMemorySpeed; - bool _unknownModel; - bool _unknownProcessorSpeed; - bool _unknownStorageSize; - [Parameter] - public int Id { get; set; } + get => (int)_model.Type; + set => _model.Type = (MachineType)value; + } - int Type + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; + + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/machines/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _companies = await CompaniesService.GetAsync(); + _families = await MachineFamiliesService.GetAsync(); + _model = _creating ? new MachineViewModel() : await Service.GetAsync(Id); + _machineGpus = await GpusByMachineService.GetByMachine(Id); + _machineCpus = await ProcessorsByMachineService.GetByMachine(Id); + _gpus = await GpusService.GetAsync(); + _screens = await ScreensService.GetAsync(); + _cpus = await ProcessorsService.GetAsync(); + _soundSynths = await SoundSynthsService.GetAsync(); + _machineMemories = await MemoriesByMachineService.GetByMachine(Id); + _machineStorage = await StorageByMachineService.GetByMachine(Id); + _machineScreens = await ScreensByMachineService.GetByMachine(Id); + _photos = await MachinePhotosService.GetGuidsByMachineAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _machineSound = await SoundSynthsByMachineService.GetByMachine(Id); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/machines/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _noFamily = !_model.FamilyId.HasValue; + _prototype = _model.Introduced?.Year == 1000; + _unknownIntroduced = !_model.Introduced.HasValue; + _unknownModel = string.IsNullOrWhiteSpace(_model.Model); + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - get => (int)_model.Type; - set => _model.Type = (MachineType)value; + NavigationManager.ToBaseRelativePath("admin/machines"); + + return; } - protected override async Task OnAfterRenderAsync(bool firstRender) + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_noFamily) + _model.FamilyId = null; + else if(_model.FamilyId < 0) return; + + if(_unknownIntroduced) + _model.Introduced = null; + else if(_prototype) + _model.Introduced = new DateTime(1000, 1, 1); + else if(_model.Introduced?.Date >= DateTime.UtcNow.Date) return; + + if(_unknownModel) + _model.Model = null; + else if(string.IsNullOrWhiteSpace(_model.Model)) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Name must contain less than 255 characters."], 255); + + void ValidateModel(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Model must contain less than 50 characters."], 50); + + void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); + + void ShowGpuDeleteModal(long itemId) + { + _currentGpuByMachine = _machineGpus.FirstOrDefault(n => n.Id == itemId); + _deletingGpuByMachine = true; + _deleteTitle = L["Delete graphical processing unit from this machine"]; + + _deleteText = + string.Format(L["Are you sure you want to delete the graphical processing unit {0} manufactured by {1} from this machine?"], + _currentGpuByMachine?.Name, + _currentGpuByMachine?.CompanyName); + + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_deletingGpuByMachine) + await ConfirmDeleteGpuByMachine(); + else if(_deletingSoundByMachine) + await ConfirmDeleteSoundByMachine(); + else if(_deletingCpuByMachine) + await ConfirmDeleteCpuByMachine(); + else if(_deletingMemoryByMachine) + await ConfirmDeleteMemoryByMachine(); + else if(_deletingStorageByMachine) + await ConfirmDeleteStorageByMachine(); + else if(_deletingScreenByMachine) await ConfirmDeleteScreenByMachine(); + } + + async Task ConfirmDeleteGpuByMachine() + { + if(_currentGpuByMachine is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await GpusByMachineService.DeleteAsync(_currentGpuByMachine.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineGpus = await GpusByMachineService.GetByMachine(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _deletingGpuByMachine = false; + _currentGpuByMachine = null; + _deletingSoundByMachine = false; + _currentSoundByMachine = null; + _deletingCpuByMachine = false; + _currentCpuByMachine = null; + _deletingScreenByMachine = false; + _currentScreenByMachine = null; + _deletingMemoryByMachine = false; + _deletingStorageByMachine = false; + } + + void OnAddGpuClick() + { + _addingGpu = true; + _savingGpu = false; + _addingGpuId = _gpus.First().Id; + } + + void CancelAddGpu() + { + _addingGpu = false; + _savingGpu = false; + _addingGpuId = null; + } + + async Task ConfirmAddGpu() + { + if(_addingGpuId is null || _addingGpuId <= 0) { - if(_loaded) - return; + CancelAddGpu(); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/machines/create", StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _companies = await CompaniesService.GetAsync(); - _families = await MachineFamiliesService.GetAsync(); - _model = _creating ? new MachineViewModel() : await Service.GetAsync(Id); - _machineGpus = await GpusByMachineService.GetByMachine(Id); - _machineCpus = await ProcessorsByMachineService.GetByMachine(Id); - _gpus = await GpusService.GetAsync(); - _screens = await ScreensService.GetAsync(); - _cpus = await ProcessorsService.GetAsync(); - _soundSynths = await SoundSynthsService.GetAsync(); - _machineMemories = await MemoriesByMachineService.GetByMachine(Id); - _machineStorage = await StorageByMachineService.GetByMachine(Id); - _machineScreens = await ScreensByMachineService.GetByMachine(Id); - _photos = await MachinePhotosService.GetGuidsByMachineAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _machineSound = await SoundSynthsByMachineService.GetByMachine(Id); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/machines/edit/", - StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() + _savingGpu = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await GpusByMachineService.CreateAsync(_addingGpuId.Value, + Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineGpus = await GpusByMachineService.GetByMachine(Id); + + _addingGpu = false; + _savingGpu = false; + _addingGpuId = null; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ShowSoundDeleteModal(long itemId) + { + _currentSoundByMachine = _machineSound.FirstOrDefault(n => n.Id == itemId); + _deletingSoundByMachine = true; + _deleteTitle = L["Delete sound synthesizer from this machine"]; + + _deleteText = + string.Format(L["Are you sure you want to delete the sound synthesizer {0} manufactured by {1} from this machine?"], + _currentSoundByMachine?.Name, + _currentSoundByMachine?.CompanyName); + + _frmDelete.Show(); + } + + async Task ConfirmDeleteSoundByMachine() + { + if(_currentSoundByMachine is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await SoundSynthsByMachineService.DeleteAsync(_currentSoundByMachine.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineSound = await SoundSynthsByMachineService.GetByMachine(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void OnAddSoundClick() + { + _addingSound = true; + _savingSound = false; + _addingSoundId = _soundSynths.First().Id; + } + + void CancelAddSound() + { + _addingSound = false; + _savingSound = false; + _addingSoundId = null; + } + + async Task ConfirmAddSound() + { + if(_addingSoundId is null || _addingSoundId <= 0) { - _noFamily = !_model.FamilyId.HasValue; - _prototype = _model.Introduced?.Year == 1000; - _unknownIntroduced = !_model.Introduced.HasValue; - _unknownModel = string.IsNullOrWhiteSpace(_model.Model); + CancelAddSound(); + + return; } - void OnEditClicked() + _savingSound = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await SoundSynthsByMachineService.CreateAsync(_addingSoundId.Value, + Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineSound = await SoundSynthsByMachineService.GetByMachine(Id); + + _addingSound = false; + _savingSound = false; + _addingSoundId = null; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ShowCpuDeleteModal(long itemId) + { + _currentCpuByMachine = _machineCpus.FirstOrDefault(n => n.Id == itemId); + _deletingCpuByMachine = true; + _deleteTitle = L["Delete processor from this machine"]; + + string speed = _currentCpuByMachine?.Speed == null + ? L["Unknown (processor by machine speed)"] + : string.Format(L["{0:F3} MHz"], _currentCpuByMachine?.Speed); + + _deleteText = + string.Format(L["Are you sure you want to delete the processor {0} with speed {2} manufactured by {1} from this machine?"], + _currentCpuByMachine?.Name, + _currentCpuByMachine?.CompanyName, + speed); + + _frmDelete.Show(); + } + + async Task ConfirmDeleteCpuByMachine() + { + if(_currentCpuByMachine is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ProcessorsByMachineService.DeleteAsync(_currentCpuByMachine.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineCpus = await ProcessorsByMachineService.GetByMachine(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void OnAddCpuClick() + { + _addingCpu = true; + _savingCpu = false; + _addingCpuId = _cpus.First().Id; + _addingProcessorSpeed = 0; + _unknownProcessorSpeed = true; + } + + void CancelAddCpu() + { + _addingCpu = false; + _savingCpu = false; + _addingCpuId = null; + } + + async Task ConfirmAddCpu() + { + if(_addingCpuId is null || _addingCpuId <= 0) { - _editing = true; - SetCheckboxes(); - StateHasChanged(); + CancelAddCpu(); + + return; } - async void OnCancelClicked() + _savingCpu = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ProcessorsByMachineService.CreateAsync(_addingCpuId.Value, + Id, + _unknownProcessorSpeed ? null : _addingProcessorSpeed, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineCpus = await ProcessorsByMachineService.GetByMachine(Id); + + _addingCpu = false; + _savingCpu = false; + _addingCpuId = null; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ValidateProcessorSpeed(ValidatorEventArgs e) + { + if(!(e.Value is float item)) { - _editing = false; + e.Status = ValidationStatus.Error; - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/machines"); - - return; - } - - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); + return; } - async void OnSaveClicked() - { - if(_noFamily) - _model.FamilyId = null; - else if(_model.FamilyId < 0) - return; + e.Status = item > 0 ? ValidationStatus.Success : ValidationStatus.Error; + } - if(_unknownIntroduced) - _model.Introduced = null; - else if(_prototype) - _model.Introduced = new DateTime(1000, 1, 1); - else if(_model.Introduced?.Date >= DateTime.UtcNow.Date) - return; + void ShowMemoryDeleteModal(long itemId) + { + _currentMemoryByMachine = _machineMemories.FirstOrDefault(n => n.Id == itemId); + _deletingMemoryByMachine = true; + _deleteTitle = L["Delete memory from this machine"]; - if(_unknownModel) - _model.Model = null; - else if(string.IsNullOrWhiteSpace(_model.Model)) - return; + _deleteText = + string.Format(L["Are you sure you want to delete the memory type {0} with usage {1} from this machine?"], + _currentMemoryByMachine?.Type, + _currentMemoryByMachine?.Usage); - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + _frmDelete.Show(); + } - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + async Task ConfirmDeleteMemoryByMachine() + { + if(_currentMemoryByMachine is null) return; - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Name must contain less than 255 characters."], 255); + _deleteInProgress = true; - void ValidateModel(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Model must contain less than 50 characters."], 50); + // Yield thread to let UI to update + await Task.Yield(); - void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); - - void ShowGpuDeleteModal(long itemId) - { - _currentGpuByMachine = _machineGpus.FirstOrDefault(n => n.Id == itemId); - _deletingGpuByMachine = true; - _deleteTitle = L["Delete graphical processing unit from this machine"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the graphical processing unit {0} manufactured by {1} from this machine?"], - _currentGpuByMachine?.Name, _currentGpuByMachine?.CompanyName); - - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_deletingGpuByMachine) - await ConfirmDeleteGpuByMachine(); - else if(_deletingSoundByMachine) - await ConfirmDeleteSoundByMachine(); - else if(_deletingCpuByMachine) - await ConfirmDeleteCpuByMachine(); - else if(_deletingMemoryByMachine) - await ConfirmDeleteMemoryByMachine(); - else if(_deletingStorageByMachine) - await ConfirmDeleteStorageByMachine(); - else if(_deletingScreenByMachine) - await ConfirmDeleteScreenByMachine(); - } - - async Task ConfirmDeleteGpuByMachine() - { - if(_currentGpuByMachine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await GpusByMachineService.DeleteAsync(_currentGpuByMachine.Id, + await MemoriesByMachineService.DeleteAsync(_currentMemoryByMachine.Id, (await UserManager.GetUserAsync(_authState.User)).Id); - _machineGpus = await GpusByMachineService.GetByMachine(Id); + _machineMemories = await MemoriesByMachineService.GetByMachine(Id); - _deleteInProgress = false; - _frmDelete.Hide(); + _deleteInProgress = false; + _frmDelete.Hide(); - // Yield thread to let UI to update - await Task.Yield(); + // Yield thread to let UI to update + await Task.Yield(); - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); + } - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _deletingGpuByMachine = false; - _currentGpuByMachine = null; - _deletingSoundByMachine = false; - _currentSoundByMachine = null; - _deletingCpuByMachine = false; - _currentCpuByMachine = null; - _deletingScreenByMachine = false; - _currentScreenByMachine = null; - _deletingMemoryByMachine = false; - _deletingStorageByMachine = false; - } + void OnAddMemoryClick() + { + _addingMemory = true; + _savingMemory = false; + _addingMemorySpeed = 0; + _unknownMemorySpeed = true; + _addingMemorySize = 0; + _unknownMemorySize = true; + } - void OnAddGpuClick() - { - _addingGpu = true; - _savingGpu = false; - _addingGpuId = _gpus.First().Id; - } + void CancelAddMemory() + { + _addingMemory = false; + _savingMemory = false; + } - void CancelAddGpu() - { - _addingGpu = false; - _savingGpu = false; - _addingGpuId = null; - } + async Task ConfirmAddMemory() + { + // TODO: Validation - async Task ConfirmAddGpu() - { - if(_addingGpuId is null || - _addingGpuId <= 0) - { - CancelAddGpu(); + _savingMemory = true; - return; - } + // Yield thread to let UI to update + await Task.Yield(); - _savingGpu = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await GpusByMachineService.CreateAsync(_addingGpuId.Value, Id, + await MemoriesByMachineService.CreateAsync(Id, + (MemoryType)_addingMemoryType, + (MemoryUsage)_addingMemoryUsage, + _unknownMemorySize ? null : _addingMemorySize, + _unknownMemorySpeed ? null : _addingMemorySpeed, (await UserManager.GetUserAsync(_authState.User)).Id); - _machineGpus = await GpusByMachineService.GetByMachine(Id); + _machineMemories = await MemoriesByMachineService.GetByMachine(Id); - _addingGpu = false; - _savingGpu = false; - _addingGpuId = null; + _addingMemory = false; + _savingMemory = false; - // Yield thread to let UI to update - await Task.Yield(); + // Yield thread to let UI to update + await Task.Yield(); - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); + } - void ShowSoundDeleteModal(long itemId) + void ValidateMemorySpeed(ValidatorEventArgs e) + { + if(!(e.Value is double item)) { - _currentSoundByMachine = _machineSound.FirstOrDefault(n => n.Id == itemId); - _deletingSoundByMachine = true; - _deleteTitle = L["Delete sound synthesizer from this machine"]; + e.Status = ValidationStatus.Error; - _deleteText = - string.Format(L["Are you sure you want to delete the sound synthesizer {0} manufactured by {1} from this machine?"], - _currentSoundByMachine?.Name, _currentSoundByMachine?.CompanyName); - - _frmDelete.Show(); + return; } - async Task ConfirmDeleteSoundByMachine() + e.Status = item > 0 ? ValidationStatus.Success : ValidationStatus.Error; + } + + void ValidateMemorySize(ValidatorEventArgs e) + { + if(!(e.Value is long item)) { - if(_currentSoundByMachine is null) - return; + e.Status = ValidationStatus.Error; - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await SoundSynthsByMachineService.DeleteAsync(_currentSoundByMachine.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineSound = await SoundSynthsByMachineService.GetByMachine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); + return; } - void OnAddSoundClick() + e.Status = item > 0 ? ValidationStatus.Success : ValidationStatus.Error; + } + + void ShowStorageDeleteModal(long itemId) + { + _currentStorageByMachine = _machineStorage.FirstOrDefault(n => n.Id == itemId); + _deletingStorageByMachine = true; + _deleteTitle = L["Delete storage from this machine"]; + + _deleteText = + string.Format(L["Are you sure you want to delete the storage type {0} with interface {1} from this machine?"], + _currentStorageByMachine?.Type, + _currentStorageByMachine?.Interface); + + _frmDelete.Show(); + } + + async Task ConfirmDeleteStorageByMachine() + { + if(_currentStorageByMachine is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await StorageByMachineService.DeleteAsync(_currentStorageByMachine.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineStorage = await StorageByMachineService.GetByMachine(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void OnAddStorageClick() + { + _addingStorage = true; + _savingStorage = false; + _addingStorageSize = 0; + _unknownStorageSize = true; + } + + void CancelAddStorage() + { + _addingStorage = false; + _savingStorage = false; + } + + async Task ConfirmAddStorage() + { + // TODO: Validation + + _savingStorage = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await StorageByMachineService.CreateAsync(Id, + (StorageType)_addingStorageType, + (StorageInterface)_addingStorageInterface, + _unknownStorageSize ? null : _addingStorageSize, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineStorage = await StorageByMachineService.GetByMachine(Id); + + _addingStorage = false; + _savingStorage = false; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ValidateStorageSize(ValidatorEventArgs e) + { + if(!(e.Value is long item)) { - _addingSound = true; - _savingSound = false; - _addingSoundId = _soundSynths.First().Id; + e.Status = ValidationStatus.Error; + + return; } - void CancelAddSound() + e.Status = item > 0 ? ValidationStatus.Success : ValidationStatus.Error; + } + + void ShowScreenDeleteModal(long itemId) + { + _currentScreenByMachine = _machineScreens.FirstOrDefault(n => n.Id == itemId); + _deletingScreenByMachine = true; + _deleteTitle = L["Delete screen from this machine"]; + _deleteText = L["Are you sure you want to delete the selected screen from this machine?"]; + + _frmDelete.Show(); + } + + async Task ConfirmDeleteScreenByMachine() + { + if(_currentScreenByMachine is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ScreensByMachineService.DeleteAsync(_currentScreenByMachine.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _machineScreens = await ScreensByMachineService.GetByMachine(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void OnAddScreenClick() + { + _addingScreen = true; + _savingScreen = false; + _addingScreenId = _screens.First(s => _machineScreens.All(m => m.ScreenId == s.Id)).Id; + } + + void CancelAddScreen() + { + _addingScreen = false; + _savingScreen = false; + _addingScreenId = null; + } + + async Task ConfirmAddScreen() + { + if(_addingScreenId is null || _addingScreenId <= 0) { - _addingSound = false; - _savingSound = false; - _addingSoundId = null; + CancelAddScreen(); + + return; } - async Task ConfirmAddSound() - { - if(_addingSoundId is null || - _addingSoundId <= 0) - { - CancelAddSound(); + _savingScreen = true; - return; - } + // Yield thread to let UI to update + await Task.Yield(); - _savingSound = true; + await ScreensByMachineService.CreateAsync(_addingScreenId.Value, + Id, + (await UserManager.GetUserAsync(_authState.User)).Id); - // Yield thread to let UI to update - await Task.Yield(); + _machineScreens = await ScreensByMachineService.GetByMachine(Id); - await SoundSynthsByMachineService.CreateAsync(_addingSoundId.Value, Id, - (await UserManager.GetUserAsync(_authState.User)).Id); + _addingScreen = false; + _savingScreen = false; + _addingScreenId = null; - _machineSound = await SoundSynthsByMachineService.GetByMachine(Id); + // Yield thread to let UI to update + await Task.Yield(); - _addingSound = false; - _savingSound = false; - _addingSoundId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ShowCpuDeleteModal(long itemId) - { - _currentCpuByMachine = _machineCpus.FirstOrDefault(n => n.Id == itemId); - _deletingCpuByMachine = true; - _deleteTitle = L["Delete processor from this machine"]; - - string speed = _currentCpuByMachine?.Speed == null ? L["Unknown (processor by machine speed)"] - : string.Format(L["{0:F3} MHz"], _currentCpuByMachine?.Speed); - - _deleteText = - string.Format(L["Are you sure you want to delete the processor {0} with speed {2} manufactured by {1} from this machine?"], - _currentCpuByMachine?.Name, _currentCpuByMachine?.CompanyName, speed); - - _frmDelete.Show(); - } - - async Task ConfirmDeleteCpuByMachine() - { - if(_currentCpuByMachine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await ProcessorsByMachineService.DeleteAsync(_currentCpuByMachine.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineCpus = await ProcessorsByMachineService.GetByMachine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void OnAddCpuClick() - { - _addingCpu = true; - _savingCpu = false; - _addingCpuId = _cpus.First().Id; - _addingProcessorSpeed = 0; - _unknownProcessorSpeed = true; - } - - void CancelAddCpu() - { - _addingCpu = false; - _savingCpu = false; - _addingCpuId = null; - } - - async Task ConfirmAddCpu() - { - if(_addingCpuId is null || - _addingCpuId <= 0) - { - CancelAddCpu(); - - return; - } - - _savingCpu = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await ProcessorsByMachineService.CreateAsync(_addingCpuId.Value, Id, - _unknownProcessorSpeed ? null : _addingProcessorSpeed, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineCpus = await ProcessorsByMachineService.GetByMachine(Id); - - _addingCpu = false; - _savingCpu = false; - _addingCpuId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ValidateProcessorSpeed(ValidatorEventArgs e) - { - if(!(e.Value is float item)) - { - e.Status = ValidationStatus.Error; - - return; - } - - e.Status = item > 0 ? ValidationStatus.Success : ValidationStatus.Error; - } - - void ShowMemoryDeleteModal(long itemId) - { - _currentMemoryByMachine = _machineMemories.FirstOrDefault(n => n.Id == itemId); - _deletingMemoryByMachine = true; - _deleteTitle = L["Delete memory from this machine"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the memory type {0} with usage {1} from this machine?"], - _currentMemoryByMachine?.Type, _currentMemoryByMachine?.Usage); - - _frmDelete.Show(); - } - - async Task ConfirmDeleteMemoryByMachine() - { - if(_currentMemoryByMachine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await MemoriesByMachineService.DeleteAsync(_currentMemoryByMachine.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineMemories = await MemoriesByMachineService.GetByMachine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void OnAddMemoryClick() - { - _addingMemory = true; - _savingMemory = false; - _addingMemorySpeed = 0; - _unknownMemorySpeed = true; - _addingMemorySize = 0; - _unknownMemorySize = true; - } - - void CancelAddMemory() - { - _addingMemory = false; - _savingMemory = false; - } - - async Task ConfirmAddMemory() - { - // TODO: Validation - - _savingMemory = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await MemoriesByMachineService.CreateAsync(Id, (MemoryType)_addingMemoryType, - (MemoryUsage)_addingMemoryUsage, - _unknownMemorySize ? null : _addingMemorySize, - _unknownMemorySpeed ? null : _addingMemorySpeed, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineMemories = await MemoriesByMachineService.GetByMachine(Id); - - _addingMemory = false; - _savingMemory = false; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ValidateMemorySpeed(ValidatorEventArgs e) - { - if(!(e.Value is double item)) - { - e.Status = ValidationStatus.Error; - - return; - } - - e.Status = item > 0 ? ValidationStatus.Success : ValidationStatus.Error; - } - - void ValidateMemorySize(ValidatorEventArgs e) - { - if(!(e.Value is long item)) - { - e.Status = ValidationStatus.Error; - - return; - } - - e.Status = item > 0 ? ValidationStatus.Success : ValidationStatus.Error; - } - - void ShowStorageDeleteModal(long itemId) - { - _currentStorageByMachine = _machineStorage.FirstOrDefault(n => n.Id == itemId); - _deletingStorageByMachine = true; - _deleteTitle = L["Delete storage from this machine"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the storage type {0} with interface {1} from this machine?"], - _currentStorageByMachine?.Type, _currentStorageByMachine?.Interface); - - _frmDelete.Show(); - } - - async Task ConfirmDeleteStorageByMachine() - { - if(_currentStorageByMachine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await StorageByMachineService.DeleteAsync(_currentStorageByMachine.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineStorage = await StorageByMachineService.GetByMachine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void OnAddStorageClick() - { - _addingStorage = true; - _savingStorage = false; - _addingStorageSize = 0; - _unknownStorageSize = true; - } - - void CancelAddStorage() - { - _addingStorage = false; - _savingStorage = false; - } - - async Task ConfirmAddStorage() - { - // TODO: Validation - - _savingStorage = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await StorageByMachineService.CreateAsync(Id, (StorageType)_addingStorageType, - (StorageInterface)_addingStorageInterface, - _unknownStorageSize ? null : _addingStorageSize, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineStorage = await StorageByMachineService.GetByMachine(Id); - - _addingStorage = false; - _savingStorage = false; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ValidateStorageSize(ValidatorEventArgs e) - { - if(!(e.Value is long item)) - { - e.Status = ValidationStatus.Error; - - return; - } - - e.Status = item > 0 ? ValidationStatus.Success : ValidationStatus.Error; - } - - void ShowScreenDeleteModal(long itemId) - { - _currentScreenByMachine = _machineScreens.FirstOrDefault(n => n.Id == itemId); - _deletingScreenByMachine = true; - _deleteTitle = L["Delete screen from this machine"]; - _deleteText = L["Are you sure you want to delete the selected screen from this machine?"]; - - _frmDelete.Show(); - } - - async Task ConfirmDeleteScreenByMachine() - { - if(_currentScreenByMachine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await ScreensByMachineService.DeleteAsync(_currentScreenByMachine.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineScreens = await ScreensByMachineService.GetByMachine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void OnAddScreenClick() - { - _addingScreen = true; - _savingScreen = false; - _addingScreenId = _screens.First(s => _machineScreens.All(m => m.ScreenId == s.Id)).Id; - } - - void CancelAddScreen() - { - _addingScreen = false; - _savingScreen = false; - _addingScreenId = null; - } - - async Task ConfirmAddScreen() - { - if(_addingScreenId is null || - _addingScreenId <= 0) - { - CancelAddScreen(); - - return; - } - - _savingScreen = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await ScreensByMachineService.CreateAsync(_addingScreenId.Value, Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _machineScreens = await ScreensByMachineService.GetByMachine(Id); - - _addingScreen = false; - _savingScreen = false; - _addingScreenId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/MachineFamily.razor b/Marechai/Pages/Admin/Details/MachineFamily.razor index eb6cd0d3..c537dab5 100644 --- a/Marechai/Pages/Admin/Details/MachineFamily.razor +++ b/Marechai/Pages/Admin/Details/MachineFamily.razor @@ -31,13 +31,13 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject CompaniesService CompaniesService -@inject NavigationManager NavigationManager -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject CompaniesService CompaniesService +@inject NavigationManager NavigationManager +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Machine family details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -48,10 +48,10 @@ @L["Company"] @@ -66,18 +66,19 @@ @if(_editing) { @L["Must not contain \"family\" or \"series\". Different regional names should be separated with /. Different numbers should be separated with comma."] -} + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/MachineFamily.razor.cs b/Marechai/Pages/Admin/Details/MachineFamily.razor.cs index e0eeb156..57bf5a15 100644 --- a/Marechai/Pages/Admin/Details/MachineFamily.razor.cs +++ b/Marechai/Pages/Admin/Details/MachineFamily.razor.cs @@ -32,84 +32,79 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class MachineFamily { - public partial class MachineFamily + AuthenticationState _authState; + List _companies; + bool _creating; + bool _editing; + bool _loaded; + MachineFamilyViewModel _model; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - AuthenticationState _authState; - List _companies; - bool _creating; - bool _editing; - bool _loaded; - MachineFamilyViewModel _model; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; + _loaded = true; - _loaded = true; + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/machine_families/create", StringComparison.InvariantCulture); - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/machine_families/create", - StringComparison.InvariantCulture); + if(Id <= 0 && !_creating) return; - if(Id <= 0 && - !_creating) - return; + _companies = await CompaniesService.GetAsync(); + _model = _creating ? new MachineFamilyViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _companies = await CompaniesService.GetAsync(); - _model = _creating ? new MachineFamilyViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/machine_families/edit/", StringComparison.InvariantCulture); - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/machine_families/edit/", - StringComparison.InvariantCulture); - - StateHasChanged(); - } - - void OnEditClicked() - { - _editing = true; - StateHasChanged(); - } - - async void OnCancelClicked() - { - _editing = false; - - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/machine_families"); - - return; - } - - _model = await Service.GetAsync(Id); - StateHasChanged(); - } - - async void OnSaveClicked() - { - if(string.IsNullOrWhiteSpace(_model.Name) || - _model.Name?.Length > 255) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - StateHasChanged(); - } - - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Family name must contain less than 255 characters."], 255); + StateHasChanged(); } + + void OnEditClicked() + { + _editing = true; + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) + { + NavigationManager.ToBaseRelativePath("admin/machine_families"); + + return; + } + + _model = await Service.GetAsync(Id); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(string.IsNullOrWhiteSpace(_model.Name) || _model.Name?.Length > 255) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Family name must contain less than 255 characters."], 255); } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/MachinePhoto.razor b/Marechai/Pages/Admin/Details/MachinePhoto.razor index d0e44c02..5e511484 100644 --- a/Marechai/Pages/Admin/Details/MachinePhoto.razor +++ b/Marechai/Pages/Admin/Details/MachinePhoto.razor @@ -27,18 +27,18 @@ @page "/admin/machines/photo/details/{Id:guid}" @page "/admin/machines/photo/edit/{Id:guid}" -@using Marechai.Database.Models @using Marechai.Database +@using Marechai.Database.Models @using Orientation = Marechai.Database.Orientation @inherits OwningComponentBase @inject IStringLocalizer L -@inject NavigationManager NavigationManager -@inject LicensesService LicensesService -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject NavigationManager NavigationManager +@inject LicensesService LicensesService +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Machine photo details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -46,685 +46,699 @@ return; }
- - @L["Machine"] - - - - @L["Uploaded by"] - ")" /> - - - @L["Uploaded date"] - - - - @L["License"] - - -@if(_editing || _model.Author != null) -{ - @L["Author"] - @if(_editing) - { - @L["Unknown (author)"] -} - @if(!_editing || - !_unknownSource) - { - - - - @L["Please enter a valid author."] - - - -} - } -@if(_editing || _model.Source != null) -{ + @L["Machine"] + + - @L["Source URL"] - @if(_editing) - { - @L["Unknown (source url)"] -} - @if(!_editing || - !_unknownSource) - { - - - - @L["Please enter a valid source URL."] - - - -} - } -@if(_editing || _model.Aperture != null) -{ + @L["Uploaded by"] + ")"/> + - @L["Aperture"] - @if(_editing) - { - @L["Unknown (aperture)"] -} - @if(!_editing || - !_unknownAperture) - { - - - - @L["Please enter a valid aperture."] - - - -} - } -@if(_editing || _model.CameraManufacturer != null) -{ + @L["Uploaded date"] + + - @L["Camera manufacturer"] - @if(_editing) - { - @L["Unknown (camera manufacturer)"] -} - @if(!_editing || - !_unknownCameraManufacturer) - { - - - - @L["Please enter a valid camera manufacturer."] - - - -} - } -@if(_editing || _model.CameraModel != null) -{ - - @L["Camera model"] - @if(_editing) - { - @L["Unknown (camera model)"] -} - @if(!_editing || - !_unknownCameraModel) - { - - - - @L["Please enter a valid camera model."] - - - -} - } -@if(_editing || _model.ColorSpace != null) -{ - - @L["Color space"] - @if(_editing) - { - @L["Unknown (color space)"] -} - @if(!_editing || - !_unknownColorSpace) - { - -} - } -@if(_editing || _model.Contrast != null) -{ - - @L["Contrast"] - @if(_editing) - { - @L["Unknown (contrast)"] -} - @if(!_editing || - !_unknownContrast) - { - -} - } -@if(_editing || _model.CreationDate != null) -{ - - @L["Creation date"] - @if(_editing) - { - @L["Unknown (creation date)"] -} - @if(!_editing || - !_unknownCreationDate) - { - - - - @L["Please enter a correct creation date."] - - - -} - } -@if(_editing || _model.DigitalZoomRatio != null) -{ - - @L["Digital zoom ratio"] - @if(_editing) - { - @L["Unknown (digital zoom ratio)"] -} - @if(!_editing || - !_unknownDigitalZoomRatio) - { - - - - @L["Please enter a valid digital zoom ratio."] - - - -} - } -@if(_editing || _model.ExifVersion != null) -{ - - @L["Exif version"] - @if(_editing) - { - @L["Unknown (exif version)"] -} - @if(!_editing || - !_unknownExifVersion) - { - - - - @L["Please enter a valid Exif version."] - - - -} - } -@if(_editing || _model.ExposureTime != null) -{ - - @L["Exposure time"] - @if(_editing) - { - @L["Unknown (exposure time)"] -} - @if(!_editing || - !_unknownExposure) - { - - - - @L["Please enter a valid exposure time."] - - - -} - } -@if(_editing || _model.ExposureMethod != null) -{ - - @L["Exposure mode"] - @if(_editing) - { - @L["Unknown (exposure mode)"] -} - @if(!_editing || - !_unknownExposureMethod) - { - -} - } -@if(_editing || _model.ExposureProgram != null) -{ - - @L["Exposure program"] - @if(_editing) - { - @L["Unknown (exposure program)"] -} - @if(!_editing || - !_unknownExposureProgram) - { - -} - } -@if(_editing || _model.Flash != null) -{ - - @L["Flash"] - @if(_editing) - { - @L["Unknown (flash)"] -} - @if(!_editing || - !_unknownFlash) - { - -} - } -@if(_editing || _model.Focal != null) -{ - - @L["F-number"] - @if(_editing) - { - @L["Unknown (f-number)"] -} - @if(!_editing || - !_unknownFocal) - { - - - - @L["Please enter a valid focal number."] - - - -} - } -@if(_editing || _model.FocalLength != null) -{ - - @L["Focal length"] - @if(_editing) - { - @L["Unknown (focal length)"] -} - @if(!_editing || - !_unknownFocalLength) - { - - - - @L["Please enter a valid focal length."] - - - -} - } -@if(_editing || _model.FocalLengthEquivalent != null) -{ - - @L["Focal length in 35mm film"] - @if(_editing) - { - @L["Unknown (focal length in 35mm film)"] -} - @if(!_editing || - !_unknownFocalLengthEquivalent) - { - - - - @L["Please enter a valid focal length in 35mm film."] - - - -} - } -@if(_editing || _model.HorizontalResolution != null) -{ - - @L["Horizontal resolution"] - @if(_editing) - { - @L["Unknown (horizontal resolution)"] -} - @if(!_editing || - !_unknownHorizontalResolution) - { - - - - @L["Please enter a valid horizontal resolution."] - - - -} - } -@if(_editing || _model.IsoRating != null) -{ - - @L["ISO rating"] - @if(_editing) - { - @L["Unknown (ISO rating)"] -} - @if(!_editing || - !_unknownIsoRating) - { - - - - @L["Please enter a valid ISO rating."] - - - -} - } -@if(_editing || _model.Lens != null) -{ - - @L["Lens"] - @if(_editing) - { - @L["Unknown (lens)"] -} - @if(!_editing || - !_unknownLens) - { - - - - @L["Please enter a valid lens."] - - - -} - } -@if(_editing || _model.LightSource != null) -{ - - @L["Light source"] - @if(_editing) - { - @L["Unknown (light source)"] -} - @if(!_editing || - !_unknownLightSource) - { - -} - } -@if(_editing || _model.MeteringMode != null) -{ - - @L["Metering mode"] - @if(_editing) - { - @L["Unknown (metering mode)"] -} - @if(!_editing || - !_unknownMeteringMode) - { - -} - } -@if(_editing || _model.ResolutionUnit != null) -{ - - @L["Resolution unit"] - @if(_editing) - { - @L["Unknown (resolution unit)"] -} - @if(!_editing || - !_unknownResolutionUnit) - { - -} - } -@if(_editing || _model.Orientation != null) -{ - - @L["Orientation"] - @if(_editing) - { - @L["Unknown (orientation)"] -} - @if(!_editing || - !_unknownOrientation) - { - -} - } -@if(_editing || _model.Saturation != null) -{ - - @L["Saturation"] - @if(_editing) - { - @L["Unknown (saturation)"] -} - @if(!_editing || - !_unknownSaturation) - { - -} - } -@if(_editing || _model.SceneCaptureType != null) -{ - - @L["Scene capture type"] - @if(_editing) - { - @L["Unknown (scene capture type)"] -} - @if(!_editing || - !_unknownSceneCaptureType) - { - -} - } -@if(_editing || _model.SensingMethod != null) -{ - - @L["Sensing method"] - @if(_editing) - { - @L["Unknown (sensing method)"] -} - @if(!_editing || - !_unknownSensingMethod) - { - -} - } -@if(_editing || _model.Sharpness != null) -{ - - @L["Sharpness"] - @if(_editing) - { - @L["Unknown (sharpness)"] -} - @if(!_editing || - !_unknownSharpness) - { - -} - } -@if(_editing || _model.SoftwareUsed != null) -{ - - @L["Software used"] - @if(_editing) - { - @L["Unknown (software used)"] -} - @if(!_editing || - !_unknownSoftwareUsed) - { - - - - @L["Please enter a valid software used."] - - - -} - } -@if(_editing || _model.SubjectDistanceRange != null) -{ - - @L["Subject distance range"] - @if(_editing) - { - @L["Unknown (subject distance range)"] -} - @if(!_editing || - !_unknownSubjectDistanceRange) - { - -} - } -@if(_editing || _model.VerticalResolution != null) -{ - - @L["Vertical resolution"] - @if(_editing) - { - @L["Unknown (vertical resolution)"] -} - @if(!_editing || - !_unknownVerticalResolution) - { - - - - @L["Please enter a valid vertical resolution."] - - - -} - } -@if(_editing || _model.WhiteBalance != null) -{ - - @L["White balance"] - @if(_editing) - { - @L["Unknown (white balance)"] -} - @if(!_editing || - !_unknownWhiteBalance) - { - -} - } -@if(_editing || _model.Comments != null) -{ - - @L["User comments"] - @if(_editing) - { - @L["Unknown or empty (user comments)"] -} - @if(!_editing || - !_unknownComments) - { - - - - @L["Please enter valid comments."] - - - -} - } + @L["License"] + + + @if(_editing || _model.Author != null) + { + + @L["Author"] + @if(_editing) + { + @L["Unknown (author)"] + } + @if(!_editing || !_unknownSource) + { + + + + @L["Please enter a valid author."] + + + + } + + } + @if(_editing || _model.Source != null) + { + + @L["Source URL"] + @if(_editing) + { + @L["Unknown (source url)"] + } + @if(!_editing || !_unknownSource) + { + + + + @L["Please enter a valid source URL."] + + + + } + + } + @if(_editing || _model.Aperture != null) + { + + @L["Aperture"] + @if(_editing) + { + @L["Unknown (aperture)"] + } + @if(!_editing || !_unknownAperture) + { + + + + @L["Please enter a valid aperture."] + + + + } + + } + @if(_editing || _model.CameraManufacturer != null) + { + + @L["Camera manufacturer"] + @if(_editing) + { + @L["Unknown (camera manufacturer)"] + } + @if(!_editing || !_unknownCameraManufacturer) + { + + + + @L["Please enter a valid camera manufacturer."] + + + + } + + } + @if(_editing || _model.CameraModel != null) + { + + @L["Camera model"] + @if(_editing) + { + @L["Unknown (camera model)"] + } + @if(!_editing || !_unknownCameraModel) + { + + + + @L["Please enter a valid camera model."] + + + + } + + } + @if(_editing || _model.ColorSpace != null) + { + + @L["Color space"] + @if(_editing) + { + @L["Unknown (color space)"] + } + @if(!_editing || !_unknownColorSpace) + { + + } + + } + @if(_editing || _model.Contrast != null) + { + + @L["Contrast"] + @if(_editing) + { + @L["Unknown (contrast)"] + } + @if(!_editing || !_unknownContrast) + { + + } + + } + @if(_editing || _model.CreationDate != null) + { + + @L["Creation date"] + @if(_editing) + { + @L["Unknown (creation date)"] + } + @if(!_editing || !_unknownCreationDate) + { + + + + @L["Please enter a correct creation date."] + + + + } + + } + @if(_editing || _model.DigitalZoomRatio != null) + { + + @L["Digital zoom ratio"] + @if(_editing) + { + @L["Unknown (digital zoom ratio)"] + } + @if(!_editing || !_unknownDigitalZoomRatio) + { + + + + @L["Please enter a valid digital zoom ratio."] + + + + } + + } + @if(_editing || _model.ExifVersion != null) + { + + @L["Exif version"] + @if(_editing) + { + @L["Unknown (exif version)"] + } + @if(!_editing || !_unknownExifVersion) + { + + + + @L["Please enter a valid Exif version."] + + + + } + + } + @if(_editing || _model.ExposureTime != null) + { + + @L["Exposure time"] + @if(_editing) + { + @L["Unknown (exposure time)"] + } + @if(!_editing || !_unknownExposure) + { + + + + @L["Please enter a valid exposure time."] + + + + } + + } + @if(_editing || _model.ExposureMethod != null) + { + + @L["Exposure mode"] + @if(_editing) + { + @L["Unknown (exposure mode)"] + } + @if(!_editing || !_unknownExposureMethod) + { + + } + + } + @if(_editing || _model.ExposureProgram != null) + { + + @L["Exposure program"] + @if(_editing) + { + @L["Unknown (exposure program)"] + } + @if(!_editing || !_unknownExposureProgram) + { + + } + + } + @if(_editing || _model.Flash != null) + { + + @L["Flash"] + @if(_editing) + { + @L["Unknown (flash)"] + } + @if(!_editing || !_unknownFlash) + { + + } + + } + @if(_editing || _model.Focal != null) + { + + @L["F-number"] + @if(_editing) + { + @L["Unknown (f-number)"] + } + @if(!_editing || !_unknownFocal) + { + + + + @L["Please enter a valid focal number."] + + + + } + + } + @if(_editing || _model.FocalLength != null) + { + + @L["Focal length"] + @if(_editing) + { + @L["Unknown (focal length)"] + } + @if(!_editing || !_unknownFocalLength) + { + + + + @L["Please enter a valid focal length."] + + + + } + + } + @if(_editing || _model.FocalLengthEquivalent != null) + { + + @L["Focal length in 35mm film"] + @if(_editing) + { + @L["Unknown (focal length in 35mm film)"] + } + @if(!_editing || !_unknownFocalLengthEquivalent) + { + + + + @L["Please enter a valid focal length in 35mm film."] + + + + } + + } + @if(_editing || _model.HorizontalResolution != null) + { + + @L["Horizontal resolution"] + @if(_editing) + { + @L["Unknown (horizontal resolution)"] + } + @if(!_editing || !_unknownHorizontalResolution) + { + + + + @L["Please enter a valid horizontal resolution."] + + + + } + + } + @if(_editing || _model.IsoRating != null) + { + + @L["ISO rating"] + @if(_editing) + { + @L["Unknown (ISO rating)"] + } + @if(!_editing || !_unknownIsoRating) + { + + + + @L["Please enter a valid ISO rating."] + + + + } + + } + @if(_editing || _model.Lens != null) + { + + @L["Lens"] + @if(_editing) + { + @L["Unknown (lens)"] + } + @if(!_editing || !_unknownLens) + { + + + + @L["Please enter a valid lens."] + + + + } + + } + @if(_editing || _model.LightSource != null) + { + + @L["Light source"] + @if(_editing) + { + @L["Unknown (light source)"] + } + @if(!_editing || !_unknownLightSource) + { + + } + + } + @if(_editing || _model.MeteringMode != null) + { + + @L["Metering mode"] + @if(_editing) + { + @L["Unknown (metering mode)"] + } + @if(!_editing || !_unknownMeteringMode) + { + + } + + } + @if(_editing || _model.ResolutionUnit != null) + { + + @L["Resolution unit"] + @if(_editing) + { + @L["Unknown (resolution unit)"] + } + @if(!_editing || !_unknownResolutionUnit) + { + + } + + } + @if(_editing || _model.Orientation != null) + { + + @L["Orientation"] + @if(_editing) + { + @L["Unknown (orientation)"] + } + @if(!_editing || !_unknownOrientation) + { + + } + + } + @if(_editing || _model.Saturation != null) + { + + @L["Saturation"] + @if(_editing) + { + @L["Unknown (saturation)"] + } + @if(!_editing || !_unknownSaturation) + { + + } + + } + @if(_editing || _model.SceneCaptureType != null) + { + + @L["Scene capture type"] + @if(_editing) + { + @L["Unknown (scene capture type)"] + } + @if(!_editing || !_unknownSceneCaptureType) + { + + } + + } + @if(_editing || _model.SensingMethod != null) + { + + @L["Sensing method"] + @if(_editing) + { + @L["Unknown (sensing method)"] + } + @if(!_editing || !_unknownSensingMethod) + { + + } + + } + @if(_editing || _model.Sharpness != null) + { + + @L["Sharpness"] + @if(_editing) + { + @L["Unknown (sharpness)"] + } + @if(!_editing || !_unknownSharpness) + { + + } + + } + @if(_editing || _model.SoftwareUsed != null) + { + + @L["Software used"] + @if(_editing) + { + @L["Unknown (software used)"] + } + @if(!_editing || !_unknownSoftwareUsed) + { + + + + @L["Please enter a valid software used."] + + + + } + + } + @if(_editing || _model.SubjectDistanceRange != null) + { + + @L["Subject distance range"] + @if(_editing) + { + @L["Unknown (subject distance range)"] + } + @if(!_editing || !_unknownSubjectDistanceRange) + { + + } + + } + @if(_editing || _model.VerticalResolution != null) + { + + @L["Vertical resolution"] + @if(_editing) + { + @L["Unknown (vertical resolution)"] + } + @if(!_editing || !_unknownVerticalResolution) + { + + + + @L["Please enter a valid vertical resolution."] + + + + } + + } + @if(_editing || _model.WhiteBalance != null) + { + + @L["White balance"] + @if(_editing) + { + @L["Unknown (white balance)"] + } + @if(!_editing || !_unknownWhiteBalance) + { + + } + + } + @if(_editing || _model.Comments != null) + { + + @L["User comments"] + @if(_editing) + { + @L["Unknown or empty (user comments)"] + } + @if(!_editing || !_unknownComments) + { + + + + @L["Please enter valid comments."] + + + + } + + }
- +
@if(!_editing) { -} + } else { + -} + } @L["Back to machine"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/MachinePhoto.razor.cs b/Marechai/Pages/Admin/Details/MachinePhoto.razor.cs index a2734bab..b261e411 100644 --- a/Marechai/Pages/Admin/Details/MachinePhoto.razor.cs +++ b/Marechai/Pages/Admin/Details/MachinePhoto.razor.cs @@ -35,381 +35,358 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; using Orientation = Marechai.Database.Orientation; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class MachinePhoto { - public partial class MachinePhoto + const int MAX_UPLOAD_SIZE = 25 * 1048576; + AuthenticationState _authState; + bool _editing; + List _licenses; + bool _loaded; + MachinePhotoViewModel _model; + bool _unknownAperture; + bool _unknownAuthor; + bool _unknownCameraManufacturer; + bool _unknownCameraModel; + bool _unknownColorSpace; + bool _unknownComments; + bool _unknownContrast; + bool _unknownCreationDate; + bool _unknownDigitalZoomRatio; + bool _unknownExifVersion; + bool _unknownExposure; + bool _unknownExposureMethod; + bool _unknownExposureProgram; + bool _unknownFlash; + bool _unknownFocal; + bool _unknownFocalLength; + bool _unknownFocalLengthEquivalent; + bool _unknownHorizontalResolution; + bool _unknownIsoRating; + bool _unknownLens; + bool _unknownLightSource; + bool _unknownMeteringMode; + bool _unknownOrientation; + bool _unknownResolutionUnit; + bool _unknownSaturation; + bool _unknownSceneCaptureType; + bool _unknownSensingMethod; + bool _unknownSharpness; + bool _unknownSoftwareUsed; + bool _unknownSource; + bool _unknownSubjectDistanceRange; + bool _unknownVerticalResolution; + bool _unknownWhiteBalance; + ApplicationUser _user; + [Parameter] + public Guid Id { get; set; } + [Parameter] + public int MachineId { get; set; } + + ushort ColorSpace { - const int _maxUploadSize = 25 * 1048576; - AuthenticationState _authState; - bool _editing; - List _licenses; - bool _loaded; - MachinePhotoViewModel _model; - bool _unknownAperture; - bool _unknownAuthor; - bool _unknownCameraManufacturer; - bool _unknownCameraModel; - bool _unknownColorSpace; - bool _unknownComments; - bool _unknownContrast; - bool _unknownCreationDate; - bool _unknownDigitalZoomRatio; - bool _unknownExifVersion; - bool _unknownExposure; - bool _unknownExposureMethod; - bool _unknownExposureProgram; - bool _unknownFlash; - bool _unknownFocal; - bool _unknownFocalLength; - bool _unknownFocalLengthEquivalent; - bool _unknownHorizontalResolution; - bool _unknownIsoRating; - bool _unknownLens; - bool _unknownLightSource; - bool _unknownMeteringMode; - bool _unknownOrientation; - bool _unknownResolutionUnit; - bool _unknownSaturation; - bool _unknownSceneCaptureType; - bool _unknownSensingMethod; - bool _unknownSharpness; - bool _unknownSoftwareUsed; - bool _unknownSource; - bool _unknownSubjectDistanceRange; - bool _unknownVerticalResolution; - bool _unknownWhiteBalance; - ApplicationUser _user; - [Parameter] - public Guid Id { get; set; } - [Parameter] - public int MachineId { get; set; } - - ushort ColorSpace + get { - get - { - if(_model.ColorSpace is null) - return 0; + if(_model.ColorSpace is null) return 0; - return (ushort)_model.ColorSpace; - } - set => _model.ColorSpace = (ColorSpace)value; + return (ushort)_model.ColorSpace; } - - ushort Contrast - { - get - { - if(_model.Contrast is null) - return 0; - - return (ushort)_model.Contrast; - } - set => _model.Contrast = (Contrast)value; - } - - ushort ExposureMode - { - get - { - if(_model.ExposureMethod is null) - return 0; - - return (ushort)_model.ExposureMethod; - } - set => _model.ExposureMethod = (ExposureMode)value; - } - - ushort ExposureProgram - { - get - { - if(_model.ExposureProgram is null) - return 0; - - return (ushort)_model.ExposureProgram; - } - set => _model.ExposureProgram = (ExposureProgram)value; - } - - ushort Flash - { - get - { - if(_model.Flash is null) - return 0; - - return (ushort)_model.Flash; - } - set => _model.Flash = (Flash)value; - } - - ushort LightSource - { - get - { - if(_model.LightSource is null) - return 0; - - return (ushort)_model.LightSource; - } - set => _model.LightSource = (LightSource)value; - } - - ushort MeteringMode - { - get - { - if(_model.MeteringMode is null) - return 0; - - return (ushort)_model.MeteringMode; - } - set => _model.MeteringMode = (MeteringMode)value; - } - - ushort ResolutionUnit - { - get - { - if(_model.ResolutionUnit is null) - return 0; - - return (ushort)_model.ResolutionUnit; - } - set => _model.ResolutionUnit = (ResolutionUnit)value; - } - - ushort Orientation - { - get - { - if(_model.Orientation is null) - return 0; - - return (ushort)_model.Orientation; - } - set => _model.Orientation = (Orientation)value; - } - - ushort Saturation - { - get - { - if(_model.Saturation is null) - return 0; - - return (ushort)_model.Saturation; - } - set => _model.Saturation = (Saturation)value; - } - - ushort SceneCaptureType - { - get - { - if(_model.SceneCaptureType is null) - return 0; - - return (ushort)_model.SceneCaptureType; - } - set => _model.SceneCaptureType = (SceneCaptureType)value; - } - - ushort SensingMethod - { - get - { - if(_model.SensingMethod is null) - return 0; - - return (ushort)_model.SensingMethod; - } - set => _model.SensingMethod = (SensingMethod)value; - } - - ushort Sharpness - { - get - { - if(_model.Sharpness is null) - return 0; - - return (ushort)_model.Sharpness; - } - set => _model.Sharpness = (Sharpness)value; - } - - ushort SubjectDistanceRange - { - get - { - if(_model.SubjectDistanceRange is null) - return 0; - - return (ushort)_model.SubjectDistanceRange; - } - set => _model.SubjectDistanceRange = (SubjectDistanceRange)value; - } - - ushort WhiteBalance - { - get - { - if(_model.WhiteBalance is null) - return 0; - - return (ushort)_model.WhiteBalance; - } - set => _model.WhiteBalance = (WhiteBalance)value; - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _loaded = true; - - if(Id == Guid.Empty) - return; - - _model = await Service.GetAsync(Id); - _licenses = await LicensesService.GetAsync(); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - _editing = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/machines/photo/edit/", StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - _user = await UserManager.FindByIdAsync(_model.UserId); - - StateHasChanged(); - } - - void SetCheckboxes() - { - _unknownAperture = _model.Aperture is null; - _unknownAuthor = _model.Author is null; - _unknownSource = _model.Source is null; - _unknownCameraManufacturer = _model.CameraManufacturer is null; - _unknownCameraModel = _model.CameraModel is null; - _unknownColorSpace = _model.ColorSpace is null; - _unknownContrast = _model.Contrast is null; - _unknownCreationDate = _model.CreationDate is null; - _unknownDigitalZoomRatio = _model.DigitalZoomRatio is null; - _unknownExifVersion = _model.ExifVersion is null; - _unknownExposure = _model.ExposureTime is null; - _unknownExposureMethod = _model.ExposureMethod is null; - _unknownExposureProgram = _model.ExposureProgram is null; - _unknownFlash = _model.Flash is null; - _unknownFocal = _model.Focal is null; - _unknownFocalLength = _model.FocalLength is null; - _unknownFocalLengthEquivalent = _model.FocalLengthEquivalent is null; - _unknownIsoRating = _model.IsoRating is null; - _unknownLens = _model.Lens is null; - _unknownLightSource = _model.LightSource is null; - _unknownMeteringMode = _model.MeteringMode is null; - _unknownResolutionUnit = _model.ResolutionUnit is null; - _unknownOrientation = _model.Orientation is null; - _unknownSaturation = _model.Saturation is null; - _unknownSceneCaptureType = _model.SceneCaptureType is null; - _unknownSensingMethod = _model.SensingMethod is null; - _unknownSharpness = _model.Sharpness is null; - _unknownSoftwareUsed = _model.SoftwareUsed is null; - _unknownSubjectDistanceRange = _model.SoftwareUsed is null; - _unknownHorizontalResolution = _model.HorizontalResolution is null; - _unknownVerticalResolution = _model.VerticalResolution is null; - _unknownWhiteBalance = _model.WhiteBalance is null; - _unknownComments = _model.Comments is null; - } - - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } - - async void OnCancelClicked() - { - _editing = false; - - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - async void OnSaveClicked() - { - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - _editing = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) - { - if(e.Value is double item && - item > 0) - e.Status = ValidationStatus.Success; - else - e.Status = ValidationStatus.Error; - } - - void ValidateDoubleBiggerOrEqualThanZero(ValidatorEventArgs e) - { - if(e.Value is double item && - item >= 0) - e.Status = ValidationStatus.Success; - else - e.Status = ValidationStatus.Error; - } - - void ValidateUnsignedShortBiggerThanZero(ValidatorEventArgs e) - { - if(e.Value is ushort item && - item > 0) - e.Status = ValidationStatus.Success; - else - e.Status = ValidationStatus.Error; - } - - void ValidateAuthor(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Author must be 255 characters or less."], 255); - - void ValidateSource(ValidatorEventArgs e) => - Validators.ValidateUrl(e, L["Source URL must be smaller than 255 characters."], 255); - - void ValidateCameraManufacturer(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Camera manufacturer must be 255 characters or less."], 255); - - void ValidateCameraModel(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Camera model must be 255 characters or less."], 255); - - void ValidateDate(ValidatorEventArgs e) - { - if(!(e.Value is DateTime item) || - item.Year <= 1816 || - item >= DateTime.UtcNow) - e.Status = ValidationStatus.Error; - else - e.Status = ValidationStatus.Success; - } - - void ValidateExifVersion(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Exif version must be 255 characters or less."], 255); - - void ValidateLens(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Lens name must be 255 characters or less."], 255); - - void ValidateSoftwareUsed(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Software used must be 255 characters or less."], 255); - - void ValidateComments(ValidatorEventArgs e) => - Validators.ValidateString(e, L["User comments must be 255 characters or less."], 255); + set => _model.ColorSpace = (ColorSpace)value; } + + ushort Contrast + { + get + { + if(_model.Contrast is null) return 0; + + return (ushort)_model.Contrast; + } + set => _model.Contrast = (Contrast)value; + } + + ushort ExposureMode + { + get + { + if(_model.ExposureMethod is null) return 0; + + return (ushort)_model.ExposureMethod; + } + set => _model.ExposureMethod = (ExposureMode)value; + } + + ushort ExposureProgram + { + get + { + if(_model.ExposureProgram is null) return 0; + + return (ushort)_model.ExposureProgram; + } + set => _model.ExposureProgram = (ExposureProgram)value; + } + + ushort Flash + { + get + { + if(_model.Flash is null) return 0; + + return (ushort)_model.Flash; + } + set => _model.Flash = (Flash)value; + } + + ushort LightSource + { + get + { + if(_model.LightSource is null) return 0; + + return (ushort)_model.LightSource; + } + set => _model.LightSource = (LightSource)value; + } + + ushort MeteringMode + { + get + { + if(_model.MeteringMode is null) return 0; + + return (ushort)_model.MeteringMode; + } + set => _model.MeteringMode = (MeteringMode)value; + } + + ushort ResolutionUnit + { + get + { + if(_model.ResolutionUnit is null) return 0; + + return (ushort)_model.ResolutionUnit; + } + set => _model.ResolutionUnit = (ResolutionUnit)value; + } + + ushort Orientation + { + get + { + if(_model.Orientation is null) return 0; + + return (ushort)_model.Orientation; + } + set => _model.Orientation = (Orientation)value; + } + + ushort Saturation + { + get + { + if(_model.Saturation is null) return 0; + + return (ushort)_model.Saturation; + } + set => _model.Saturation = (Saturation)value; + } + + ushort SceneCaptureType + { + get + { + if(_model.SceneCaptureType is null) return 0; + + return (ushort)_model.SceneCaptureType; + } + set => _model.SceneCaptureType = (SceneCaptureType)value; + } + + ushort SensingMethod + { + get + { + if(_model.SensingMethod is null) return 0; + + return (ushort)_model.SensingMethod; + } + set => _model.SensingMethod = (SensingMethod)value; + } + + ushort Sharpness + { + get + { + if(_model.Sharpness is null) return 0; + + return (ushort)_model.Sharpness; + } + set => _model.Sharpness = (Sharpness)value; + } + + ushort SubjectDistanceRange + { + get + { + if(_model.SubjectDistanceRange is null) return 0; + + return (ushort)_model.SubjectDistanceRange; + } + set => _model.SubjectDistanceRange = (SubjectDistanceRange)value; + } + + ushort WhiteBalance + { + get + { + if(_model.WhiteBalance is null) return 0; + + return (ushort)_model.WhiteBalance; + } + set => _model.WhiteBalance = (WhiteBalance)value; + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; + + _loaded = true; + + if(Id == Guid.Empty) return; + + _model = await Service.GetAsync(Id); + _licenses = await LicensesService.GetAsync(); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + _editing = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/machines/photo/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + _user = await UserManager.FindByIdAsync(_model.UserId); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownAperture = _model.Aperture is null; + _unknownAuthor = _model.Author is null; + _unknownSource = _model.Source is null; + _unknownCameraManufacturer = _model.CameraManufacturer is null; + _unknownCameraModel = _model.CameraModel is null; + _unknownColorSpace = _model.ColorSpace is null; + _unknownContrast = _model.Contrast is null; + _unknownCreationDate = _model.CreationDate is null; + _unknownDigitalZoomRatio = _model.DigitalZoomRatio is null; + _unknownExifVersion = _model.ExifVersion is null; + _unknownExposure = _model.ExposureTime is null; + _unknownExposureMethod = _model.ExposureMethod is null; + _unknownExposureProgram = _model.ExposureProgram is null; + _unknownFlash = _model.Flash is null; + _unknownFocal = _model.Focal is null; + _unknownFocalLength = _model.FocalLength is null; + _unknownFocalLengthEquivalent = _model.FocalLengthEquivalent is null; + _unknownIsoRating = _model.IsoRating is null; + _unknownLens = _model.Lens is null; + _unknownLightSource = _model.LightSource is null; + _unknownMeteringMode = _model.MeteringMode is null; + _unknownResolutionUnit = _model.ResolutionUnit is null; + _unknownOrientation = _model.Orientation is null; + _unknownSaturation = _model.Saturation is null; + _unknownSceneCaptureType = _model.SceneCaptureType is null; + _unknownSensingMethod = _model.SensingMethod is null; + _unknownSharpness = _model.Sharpness is null; + _unknownSoftwareUsed = _model.SoftwareUsed is null; + _unknownSubjectDistanceRange = _model.SoftwareUsed is null; + _unknownHorizontalResolution = _model.HorizontalResolution is null; + _unknownVerticalResolution = _model.VerticalResolution is null; + _unknownWhiteBalance = _model.WhiteBalance is null; + _unknownComments = _model.Comments is null; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + _editing = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) + { + if(e.Value is double item && item > 0) + e.Status = ValidationStatus.Success; + else + e.Status = ValidationStatus.Error; + } + + void ValidateDoubleBiggerOrEqualThanZero(ValidatorEventArgs e) + { + if(e.Value is double item && item >= 0) + e.Status = ValidationStatus.Success; + else + e.Status = ValidationStatus.Error; + } + + void ValidateUnsignedShortBiggerThanZero(ValidatorEventArgs e) + { + if(e.Value is ushort item && item > 0) + e.Status = ValidationStatus.Success; + else + e.Status = ValidationStatus.Error; + } + + void ValidateAuthor(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Author must be 255 characters or less."], 255); + + void ValidateSource(ValidatorEventArgs e) => + Validators.ValidateUrl(e, L["Source URL must be smaller than 255 characters."], 255); + + void ValidateCameraManufacturer(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Camera manufacturer must be 255 characters or less."], 255); + + void ValidateCameraModel(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Camera model must be 255 characters or less."], 255); + + void ValidateDate(ValidatorEventArgs e) + { + if(!(e.Value is DateTime item) || item.Year <= 1816 || item >= DateTime.UtcNow) + e.Status = ValidationStatus.Error; + else + e.Status = ValidationStatus.Success; + } + + void ValidateExifVersion(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Exif version must be 255 characters or less."], 255); + + void ValidateLens(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Lens name must be 255 characters or less."], 255); + + void ValidateSoftwareUsed(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Software used must be 255 characters or less."], 255); + + void ValidateComments(ValidatorEventArgs e) => + Validators.ValidateString(e, L["User comments must be 255 characters or less."], 255); } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Magazine.razor b/Marechai/Pages/Admin/Details/Magazine.razor index b89b5896..44b6d7ec 100644 --- a/Marechai/Pages/Admin/Details/Magazine.razor +++ b/Marechai/Pages/Admin/Details/Magazine.razor @@ -31,18 +31,18 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject Iso31661NumericService CountriesService -@inject DocumentCompaniesService CompaniesService -@inject DocumentRolesService DocumentRolesService -@inject CompaniesByMagazineService CompaniesByMagazineService -@inject NavigationManager NavigationManager -@inject IWebHostEnvironment Host -@inject IJSRuntime JSRuntime -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject Iso31661NumericService CountriesService +@inject DocumentCompaniesService CompaniesService +@inject DocumentRolesService DocumentRolesService +@inject CompaniesByMagazineService CompaniesByMagazineService +@inject NavigationManager NavigationManager +@inject IWebHostEnvironment Host +@inject IJSRuntime JSRuntime +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Magazine details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -67,9 +67,8 @@ @if(_editing) { @L["Unknown (native title)"] -} - @if(!_editing || - !_unknownNativeTitle) + } + @if(!_editing || !_unknownNativeTitle) { @@ -78,19 +77,19 @@ -} + } -} + } @if(_editing || _model.FirstPublication != null) { @L["First publication"] @if(_editing) { - @L["Unknown (first publication date)"] -} - @if(!_editing || - !_unknownFirstPublication) + @L["Unknown (first publication date)"] + } + @if(!_editing || !_unknownFirstPublication) { @@ -99,9 +98,9 @@ -} + } -} + } @if(_editing || _model.CountryId != null) { @@ -109,19 +108,18 @@ @if(_editing) { @L["Unknown (country of publication)"] -} - @if(!_editing || - !_unknownCountry) + } + @if(!_editing || !_unknownCountry) { -} + } -} + } @if(_editing || _model.Issn != null) { @@ -129,9 +127,8 @@ @if(_editing) { @L["Unknown (ISSN)"] -} - @if(!_editing || - !_unknownIssn) + } + @if(!_editing || !_unknownIssn) { @@ -140,52 +137,56 @@ -} + } -} + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
@if(!_editing) { -
+

@L["Companies involved in this magazine"]

+ + @if(_addingCompany) {
@L["Company"] @L["Role"]
} + @if(_magazineCompanies?.Count > 0) {
@@ -202,7 +203,7 @@ - @foreach(var item in _magazineCompanies) + @foreach(CompanyByMagazineViewModel item in _magazineCompanies) { @@ -212,7 +213,8 @@ @item.Role - + } @@ -222,18 +224,20 @@ } - + @_deleteTitle - + @_deleteText - + - } \ No newline at end of file + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Magazine.razor.cs b/Marechai/Pages/Admin/Details/Magazine.razor.cs index a55a38fe..d7090ca3 100644 --- a/Marechai/Pages/Admin/Details/Magazine.razor.cs +++ b/Marechai/Pages/Admin/Details/Magazine.razor.cs @@ -34,243 +34,235 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class Magazine { - public partial class Magazine + bool _addingCompany; + int? _addingCompanyId; + string _addingCompanyRoleId; + AuthenticationState _authState; + List _companies; + List _countries; + bool _creating; + CompanyByMagazineViewModel _currentCompanyByMagazine; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _deletingCompanyByMagazine; + bool _editing; + Modal _frmDelete; + bool _loaded; + List _magazineCompanies; + MagazineViewModel _model; + List _roles; + bool _savingCompany; + bool _unknownCountry; + bool _unknownFirstPublication; + bool _unknownIssn; + bool _unknownNativeTitle; + + [Parameter] + public long Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - bool _addingCompany; - int? _addingCompanyId; - string _addingCompanyRoleId; - AuthenticationState _authState; - List _companies; - List _countries; - bool _creating; - CompanyByMagazineViewModel _currentCompanyByMagazine; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _deletingCompanyByMagazine; - bool _editing; - Modal _frmDelete; - bool _loaded; - List _magazineCompanies; - MagazineViewModel _model; - List _roles; - bool _savingCompany; - bool _unknownCountry; - bool _unknownFirstPublication; - bool _unknownIssn; - bool _unknownNativeTitle; + if(_loaded) return; - [Parameter] - public long Id { get; set; } + _loaded = true; - protected override async Task OnAfterRenderAsync(bool firstRender) + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/magazines/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _countries = await CountriesService.GetAsync(); + _companies = await CompaniesService.GetAsync(); + _roles = await DocumentRolesService.GetEnabledAsync(); + _model = _creating ? new MagazineViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _addingCompanyRoleId = _roles.First().Id; + _magazineCompanies = await CompaniesByMagazineService.GetByMagazine(Id); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/magazines/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownCountry = !_model.CountryId.HasValue; + _unknownNativeTitle = string.IsNullOrWhiteSpace(_model.NativeTitle); + _unknownFirstPublication = !_model.FirstPublication.HasValue; + _unknownIssn = string.IsNullOrWhiteSpace(_model.Issn); + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - if(_loaded) - return; + NavigationManager.ToBaseRelativePath("admin/magazines"); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/magazines/create", StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _countries = await CountriesService.GetAsync(); - _companies = await CompaniesService.GetAsync(); - _roles = await DocumentRolesService.GetEnabledAsync(); - _model = _creating ? new MagazineViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _addingCompanyRoleId = _roles.First().Id; - _magazineCompanies = await CompaniesByMagazineService.GetByMagazine(Id); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/magazines/edit/", - StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownNativeTitle) + _model.NativeTitle = null; + else if(string.IsNullOrWhiteSpace(_model.NativeTitle)) return; + + if(_unknownCountry) + _model.CountryId = null; + else if(_model.CountryId < 0) return; + + if(_unknownFirstPublication) + _model.FirstPublication = null; + else if(_model.FirstPublication?.Date >= DateTime.UtcNow.Date) return; + + if(_unknownIssn) + _model.Issn = null; + else if(string.IsNullOrWhiteSpace(_model.Issn)) return; + + if(string.IsNullOrWhiteSpace(_model.Title)) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateTitle(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Title must be smaller than 256 characters."], 256); + + void ValidateFirstPublication(ValidatorEventArgs e) => Validators.ValidateDate(e); + + void ValidateNativeTitle(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Native title must be smaller than 256 characters."], 256); + + void ValidateIssn(ValidatorEventArgs e) => Validators.ValidateIssn(e); + + void OnAddCompanyClick() + { + _addingCompany = true; + _savingCompany = false; + _addingCompanyId = _companies.First().Id; + } + + void CancelAddCompany() + { + _addingCompany = false; + _savingCompany = false; + _addingCompanyId = null; + } + + async Task ConfirmAddCompany() + { + if(_addingCompanyId is null || _addingCompanyId <= 0) { - _unknownCountry = !_model.CountryId.HasValue; - _unknownNativeTitle = string.IsNullOrWhiteSpace(_model.NativeTitle); - _unknownFirstPublication = !_model.FirstPublication.HasValue; - _unknownIssn = string.IsNullOrWhiteSpace(_model.Issn); + CancelAddCompany(); + + return; } - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } + _savingCompany = true; - async void OnCancelClicked() - { - _editing = false; + // Yield thread to let UI to update + await Task.Yield(); - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/magazines"); + await CompaniesByMagazineService.CreateAsync(_addingCompanyId.Value, + Id, + _addingCompanyRoleId, + (await UserManager.GetUserAsync(_authState.User)).Id); - return; - } + _magazineCompanies = await CompaniesByMagazineService.GetByMagazine(Id); - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + _addingCompany = false; + _savingCompany = false; + _addingCompanyId = null; - async void OnSaveClicked() - { - if(_unknownNativeTitle) - _model.NativeTitle = null; - else if(string.IsNullOrWhiteSpace(_model.NativeTitle)) - return; + // Yield thread to let UI to update + await Task.Yield(); - if(_unknownCountry) - _model.CountryId = null; - else if(_model.CountryId < 0) - return; + // Tell we finished loading + StateHasChanged(); + } - if(_unknownFirstPublication) - _model.FirstPublication = null; - else if(_model.FirstPublication?.Date >= DateTime.UtcNow.Date) - return; + void ShowCompanyDeleteModal(long itemId) + { + _currentCompanyByMagazine = _magazineCompanies.FirstOrDefault(n => n.Id == itemId); + _deletingCompanyByMagazine = true; + _deleteTitle = L["Delete company from this magazine"]; - if(_unknownIssn) - _model.Issn = null; - else if(string.IsNullOrWhiteSpace(_model.Issn)) - return; + _deleteText = + string.Format(L["Are you sure you want to delete the company {0} with role {1} from this magazine?"], + _currentCompanyByMagazine?.Company, + _currentCompanyByMagazine?.Role); - if(string.IsNullOrWhiteSpace(_model.Title)) - return; + _frmDelete.Show(); + } - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _deletingCompanyByMagazine = false; + _currentCompanyByMagazine = null; + } - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + void HideModal() => _frmDelete.Hide(); - void ValidateTitle(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Title must be smaller than 256 characters."], 256); + async void ConfirmDelete() + { + if(_deletingCompanyByMagazine) await ConfirmDeleteCompanyByMachine(); + } - void ValidateFirstPublication(ValidatorEventArgs e) => Validators.ValidateDate(e); + async Task ConfirmDeleteCompanyByMachine() + { + if(_currentCompanyByMagazine is null) return; - void ValidateNativeTitle(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Native title must be smaller than 256 characters."], 256); + _deleteInProgress = true; - void ValidateIssn(ValidatorEventArgs e) => Validators.ValidateIssn(e); + // Yield thread to let UI to update + await Task.Yield(); - void OnAddCompanyClick() - { - _addingCompany = true; - _savingCompany = false; - _addingCompanyId = _companies.First().Id; - } + await CompaniesByMagazineService.DeleteAsync(_currentCompanyByMagazine.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); - void CancelAddCompany() - { - _addingCompany = false; - _savingCompany = false; - _addingCompanyId = null; - } + _magazineCompanies = await CompaniesByMagazineService.GetByMagazine(Id); - async Task ConfirmAddCompany() - { - if(_addingCompanyId is null || - _addingCompanyId <= 0) - { - CancelAddCompany(); + _deleteInProgress = false; + _frmDelete.Hide(); - return; - } + // Yield thread to let UI to update + await Task.Yield(); - _savingCompany = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await CompaniesByMagazineService.CreateAsync(_addingCompanyId.Value, Id, _addingCompanyRoleId, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _magazineCompanies = await CompaniesByMagazineService.GetByMagazine(Id); - - _addingCompany = false; - _savingCompany = false; - _addingCompanyId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ShowCompanyDeleteModal(long itemId) - { - _currentCompanyByMagazine = _magazineCompanies.FirstOrDefault(n => n.Id == itemId); - _deletingCompanyByMagazine = true; - _deleteTitle = L["Delete company from this magazine"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the company {0} with role {1} from this magazine?"], - _currentCompanyByMagazine?.Company, _currentCompanyByMagazine?.Role); - - _frmDelete.Show(); - } - - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _deletingCompanyByMagazine = false; - _currentCompanyByMagazine = null; - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_deletingCompanyByMagazine) - await ConfirmDeleteCompanyByMachine(); - } - - async Task ConfirmDeleteCompanyByMachine() - { - if(_currentCompanyByMagazine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await CompaniesByMagazineService.DeleteAsync(_currentCompanyByMagazine.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _magazineCompanies = await CompaniesByMagazineService.GetByMagazine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/MagazineIssue.razor b/Marechai/Pages/Admin/Details/MagazineIssue.razor index 7e96cfac..c69566e0 100644 --- a/Marechai/Pages/Admin/Details/MagazineIssue.razor +++ b/Marechai/Pages/Admin/Details/MagazineIssue.razor @@ -28,28 +28,28 @@ @page "/admin/magazine_issues/details/{Id:long}" @page "/admin/magazine_issues/edit/{Id:long}" @page "/admin/magazine_issues/create" -@using Marechai.Database.Models @using Marechai.Database +@using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject MagazinesService MagazinesService -@inject MachineFamiliesService MachineFamiliesService -@inject MagazinesByMachineFamilyService MagazinesByMachineFamilyService -@inject MachinesService MachinesService -@inject MagazinesByMachineService MagazinesByMachineService -@inject DocumentPeopleService PeopleService -@inject PeopleByMagazineService PeopleByMagazineService -@inject DocumentRolesService DocumentRolesService -@inject IFileReaderService FileReaderService -@inject MagazineScansService MagazineScansService -@inject NavigationManager NavigationManager -@inject IWebHostEnvironment Host -@inject IJSRuntime JSRuntime -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject MagazinesService MagazinesService +@inject MachineFamiliesService MachineFamiliesService +@inject MagazinesByMachineFamilyService MagazinesByMachineFamilyService +@inject MachinesService MachinesService +@inject MagazinesByMachineService MagazinesByMachineService +@inject DocumentPeopleService PeopleService +@inject PeopleByMagazineService PeopleByMagazineService +@inject DocumentRolesService DocumentRolesService +@inject IFileReaderService FileReaderService +@inject MagazineScansService MagazineScansService +@inject NavigationManager NavigationManager +@inject IWebHostEnvironment Host +@inject IJSRuntime JSRuntime +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Magazine issue details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -60,10 +60,10 @@ @L["Magazine"] @@ -83,9 +83,8 @@ @if(_editing) { @L["Unknown (native caption)"] -} - @if(!_editing || - !_unknownNativeCaption) + } + @if(!_editing || !_unknownNativeCaption) { @@ -94,9 +93,9 @@ -} + } -} + } @if(_editing || _model.Published != null) { @@ -104,11 +103,11 @@ @if(_editing) { @L["Unknown (publication date)"] -} - @if(!_editing || - !_unknownPublished) + } + @if(!_editing || !_unknownPublished) { @L["If the date of exact publication is unknown, set as first day of first month the publication applies to. E.g. July/August 1998 -> 1st July 1998"] + @@ -116,9 +115,9 @@ -} + } -} + } @if(_editing || _model.ProductCode != null) { @@ -126,9 +125,8 @@ @if(_editing) { @L["Unknown (Product code)"] -} - @if(!_editing || - !_unknownProductCode) + } + @if(!_editing || !_unknownProductCode) { @@ -137,9 +135,9 @@ -} + } -} + } @if(_editing || _model.Pages.HasValue) { @@ -147,9 +145,8 @@ @if(_editing) { @L["Unknown (pages)"] -} - @if(!_editing || - !_unknownPages) + } + @if(!_editing || !_unknownPages) { @@ -158,9 +155,9 @@ -} + } -} + } @if(_editing || _model.IssueNumber.HasValue) { @@ -168,9 +165,8 @@ @if(_editing) { @L["Unknown (issue number)"] -} - @if(!_editing || - !_unknownIssueNumber) + } + @if(!_editing || !_unknownIssueNumber) { @@ -179,56 +175,56 @@ -} + } -} + }
- @if(!_editing && - !_editingScan && - !_addingScan) + @if(!_editing && !_editingScan && !_addingScan) { -} + } else { + -} + } @L["Back to list"]
-@if(!_editing && - !_editingScan && - !_addingScan) +@if(!_editing && !_editingScan && !_addingScan) { -
+

@L["People involved in this magazine"]

+ + @if(_addingPerson) {
@L["Person"] @L["Role"]
} + @if(_magazinePeople?.Count > 0) {
@@ -245,7 +241,7 @@ - @foreach(var item in _magazinePeople) + @foreach(PersonByMagazineViewModel item in _magazinePeople) { @@ -255,7 +251,8 @@ @item.Role - + } @@ -264,25 +261,31 @@
} -
+

@L["Machine families this magazine issue talks about"]

- + + + @if(_addingMachineFamily) {
@L["Family"] - - + +
} + @if(_magazineMachineFamilies?.Count > 0) {
@@ -296,14 +299,15 @@ - @foreach(var item in _magazineMachineFamilies) + @foreach(MagazineByMachineFamilyViewModel item in _magazineMachineFamilies) { @item.MachineFamily - + } @@ -312,25 +316,28 @@
} -
+

@L["Machines this magazine talks about"]

+ + @if(_addingMachine) {
@L[""]
} + @if(_magazineMachines?.Count > 0) {
@@ -344,14 +351,15 @@ - @foreach(var item in _magazineMachines) + @foreach(MagazineByMachineViewModel item in _magazineMachines) { @item.Machine - + } @@ -365,19 +373,31 @@ @if(_scans.Count > 0) { - foreach(var scan in _scans) + foreach(Guid scan in _scans) {
- - - - - + + + + +
- +
@@ -386,21 +406,23 @@ } - + @_deleteTitle - + @_deleteText - + - } + +} @if(_addingScan && !_editing) { @@ -409,17 +431,20 @@ @if(!_uploading) { @L["Choose scan file"] - -
+ + +
+ @L["Scan type"] + @L["Page"] @L["Unknown (scan page)"] @@ -432,17 +457,23 @@ -} + } -
+ + + +
} else { @L["Uploading..."]
-
@($"{_progressValue:F2}")%
+
@($"{_progressValue:F2}")% +
} + @if(_uploadError) { @_uploadErrorMessage @@ -451,758 +482,824 @@ else {
@string.Format(L["Image format recognized as {0}"], _imageFormat)
+ @if(_allFinished) { @L["All finished!"] } + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- @L["Extracting Exif information..."] - - @if(_extractExif == true) - { - @L["OK!"] - } - else if(_extractExif == false) - { - @L["Error!"] - } -
- @L["Moving file to proper place..."] - - @if(_moveFile == true) - { - @L["OK!"] - } - else if(_moveFile == false) - { - @L["Error!"] - } - - @if(_moveFile == true) - { - - - - } -
- @L["Converting photo to JPEG with an HD resolution (thumbnail)..."] - - @if(_convertJpegHdTh == true) - { - @L["OK!"] - } - else if(_convertJpegHdTh == false) - { - @L["Error!"] - } - - @if(_convertJpegHdTh == true) - { - - - - } -
- @L["Converting photo to JPEG with a 1440p resolution (thumbnail)..."] - - @if(_convertJpeg1440Th == true) - { - @L["OK!"] - } - else if(_convertJpeg1440Th == false) - { - @L["Error!"] - } - - @if(_convertJpeg1440Th == true) - { - - - - } -
- @L["Converting photo to JPEG with a 4K resolution (thumbnail)..."] - - @if(_convertJpeg4kTh == true) - { - @L["OK!"] - } - else if(_convertJpeg4kTh == false) - { - @L["Error!"] - } - - @if(_convertJpeg4kTh == true) - { - - - - } -
- @L["Converting photo to JPEG with an HD resolution..."] - - @if(_convertJpegHd == true) - { - @L["OK!"] - } - else if(_convertJpegHd == false) - { - @L["Error!"] - } - - @if(_convertJpegHd == true) - { - - - - } -
- @L["Converting photo to JPEG with a 1440p resolution..."] - - @if(_convertJpeg1440 == true) - { - @L["OK!"] - } - else if(_convertJpeg1440 == false) - { - @L["Error!"] - } - - @if(_convertJpeg1440 == true) - { - - - - } -
- @L["Converting photo to JPEG with a 4K resolution..."] - - @if(_convertJpeg4k == true) - { - @L["OK!"] - } - else if(_convertJpeg4k == false) - { - @L["Error!"] - } - - @if(_convertJpeg4k == true) - { - - - - } -
- @L["Converting photo to JPEG2000 with an HD resolution (thumbnail)..."] - - @if(_convertJp2kHdTh == true) - { - @L["OK!"] - } - else if(_convertJp2kHdTh == false) - { - @L["Error!"] - } - - @if(_convertJp2kHdTh == true) - { - - - - } -
- @L["Converting photo to JPEG2000 with a 1440p resolution (thumbnail)..."] - - @if(_convertJp2k1440Th == true) - { - @L["OK!"] - } - else if(_convertJp2k1440Th == false) - { - @L["Error!"] - } - - @if(_convertJp2k1440Th == true) - { - - - - } -
- @L["Converting photo to JPEG2000 with a 4K resolution (thumbnail)..."] - - @if(_convertJp2k4kTh == true) - { - @L["OK!"] - } - else if(_convertJp2k4kTh == false) - { - @L["Error!"] - } - - @if(_convertJp2k4kTh == true) - { - - - - } -
- @L["Converting photo to JPEG2000 with an HD resolution..."] - - @if(_convertJp2kHd == true) - { - @L["OK!"] - } - else if(_convertJp2kHd == false) - { - @L["Error!"] - } - - @if(_convertJp2kHd == true) - { - - - - } -
- @L["Converting photo to JPEG2000 with a 1440p resolution..."] - - @if(_convertJp2k1440 == true) - { - @L["OK!"] - } - else if(_convertJp2k1440 == false) - { - @L["Error!"] - } - - @if(_convertJp2k1440 == true) - { - - - - } -
- @L["Converting photo to JPEG2000 with a 4K resolution..."] - - @if(_convertJp2k4k == true) - { - @L["OK!"] - } - else if(_convertJp2k4k == false) - { - @L["Error!"] - } - - @if(_convertJp2k4k == true) - { - - - - } -
- @L["Converting photo to WebP with an HD resolution (thumbnail)..."] - - @if(_convertWebpHdTh == true) - { - @L["OK!"] - } - else if(_convertWebpHdTh == false) - { - @L["Error!"] - } - - @if(_convertWebpHdTh == true) - { - - - - } -
- @L["Converting photo to WebP with a 1440p resolution (thumbnail)..."] - - @if(_convertWebp1440Th == true) - { - @L["OK!"] - } - else if(_convertWebp1440Th == false) - { - @L["Error!"] - } - - @if(_convertWebp1440Th == true) - { - - - - } -
- @L["Converting photo to WebP with a 4K resolution (thumbnail)..."] - - @if(_convertWebp4kTh == true) - { - @L["OK!"] - } - else if(_convertWebp4kTh == false) - { - @L["Error!"] - } - - @if(_convertWebp4kTh == true) - { - - - - } -
- @L["Converting photo to WebP with an HD resolution..."] - - @if(_convertWebpHd == true) - { - @L["OK!"] - } - else if(_convertWebpHd == false) - { - @L["Error!"] - } - - @if(_convertWebpHd == true) - { - - - - } -
- @L["Converting photo to WebP with a 1440p resolution..."] - - @if(_convertWebp1440 == true) - { - @L["OK!"] - } - else if(_convertWebp1440 == false) - { - @L["Error!"] - } - - @if(_convertWebp1440 == true) - { - - - - } -
- @L["Converting photo to WebP with a 4K resolution..."] - - @if(_convertWebp4k == true) - { - @L["OK!"] - } - else if(_convertWebp4k == false) - { - @L["Error!"] - } - - @if(_convertWebp4k == true) - { - - - - } -
- @L["Converting photo to HEIF with an HD resolution (thumbnail)..."] - - @if(_convertHeifHdTh == true) - { - @L["OK!"] - } - else if(_convertHeifHdTh == false) - { - @L["Error!"] - } - - @if(_convertHeifHdTh == true) - { - - - - } -
- @L["Converting photo to HEIF with a 1440p resolution (thumbnail)..."] - - @if(_convertHeif1440Th == true) - { - @L["OK!"] - } - else if(_convertHeif1440Th == false) - { - @L["Error!"] - } - - @if(_convertHeif1440Th == true) - { - - - - } -
- @L["Converting photo to HEIF with a 4K resolution (thumbnail)..."] - - @if(_convertHeif4kTh == true) - { - @L["OK!"] - } - else if(_convertHeif4kTh == false) - { - @L["Error!"] - } - - @if(_convertHeif4kTh == true) - { - - - - } -
- @L["Converting photo to HEIF with an HD resolution..."] - - @if(_convertHeifHd == true) - { - @L["OK!"] - } - else if(_convertHeifHd == false) - { - @L["Error!"] - } - - @if(_convertHeifHd == true) - { - - - - } -
- @L["Converting photo to HEIF with a 1440p resolution..."] - - @if(_convertHeif1440 == true) - { - @L["OK!"] - } - else if(_convertHeif1440 == false) - { - @L["Error!"] - } - - @if(_convertHeif1440 == true) - { - - - - } -
- @L["Converting photo to HEIF with a 4K resolution..."] - - @if(_convertHeif4k == true) - { - @L["OK!"] - } - else if(_convertHeif4k == false) - { - @L["Error!"] - } - - @if(_convertHeif4k == true) - { - - - - } -
- @L["Converting photo to AV1F with an HD resolution (thumbnail)..."] - - @if(_convertAvifHdTh == true) - { - @L["OK!"] - } - else if(_convertAvifHdTh == false) - { - @L["Error!"] - } - - @if(_convertAvifHdTh == true) - { - - - - } -
- @L["Converting photo to AV1F with a 1440p resolution (thumbnail)..."] - - @if(_convertAvif1440Th == true) - { - @L["OK!"] - } - else if(_convertAvif1440Th == false) - { - @L["Error!"] - } - - @if(_convertAvif1440Th == true) - { - - - - } -
- @L["Converting photo to AV1F with a 4K resolution (thumbnail)..."] - - @if(_convertAvif4kTh == true) - { - @L["OK!"] - } - else if(_convertAvif4kTh == false) - { - @L["Error!"] - } - - @if(_convertAvif4kTh == true) - { - - - - } -
- @L["Converting photo to AV1F with an HD resolution..."] - - @if(_convertAvifHd == true) - { - @L["OK!"] - } - else if(_convertAvifHd == false) - { - @L["Error!"] - } - - @if(_convertAvifHd == true) - { - - - - } -
- @L["Converting photo to AV1F with a 1440p resolution..."] - - @if(_convertAvif1440 == true) - { - @L["OK!"] - } - else if(_convertAvif1440 == false) - { - @L["Error!"] - } - - @if(_convertAvif1440 == true) - { - - - - } -
- @L["Converting photo to AV1F with a 4K resolution..."] - - @if(_convertAvif4k == true) - { - @L["OK!"] - } - else if(_convertAvif4k == false) - { - @L["Error!"] - } - - @if(_convertAvif4k == true) - { - - - - } -
- @L["Adding photo to database..."] - - @if(_addToDatabase == true) - { - @L["OK!"] - } - else if(_addToDatabase == false) - { - @L["Error!"] - } - -
+ @L["Extracting Exif information..."] + + @if(_extractExif == true) + { + @L["OK!"] + } + else if(_extractExif == false) + { + @L["Error!"] + } +
+ @L["Moving file to proper place..."] + + @if(_moveFile == true) + { + @L["OK!"] + } + else if(_moveFile == false) + { + @L["Error!"] + } + + @if(_moveFile == true) + { + + + + } +
+ @L["Converting photo to JPEG with an HD resolution (thumbnail)..."] + + @if(_convertJpegHdTh == true) + { + @L["OK!"] + } + else if(_convertJpegHdTh == false) + { + @L["Error!"] + } + + @if(_convertJpegHdTh == true) + { + + + + } +
+ @L["Converting photo to JPEG with a 1440p resolution (thumbnail)..."] + + @if(_convertJpeg1440Th == true) + { + @L["OK!"] + } + else if(_convertJpeg1440Th == false) + { + @L["Error!"] + } + + @if(_convertJpeg1440Th == true) + { + + + + } +
+ @L["Converting photo to JPEG with a 4K resolution (thumbnail)..."] + + @if(_convertJpeg4kTh == true) + { + @L["OK!"] + } + else if(_convertJpeg4kTh == false) + { + @L["Error!"] + } + + @if(_convertJpeg4kTh == true) + { + + + + } +
+ @L["Converting photo to JPEG with an HD resolution..."] + + @if(_convertJpegHd == true) + { + @L["OK!"] + } + else if(_convertJpegHd == false) + { + @L["Error!"] + } + + @if(_convertJpegHd == true) + { + + + + } +
+ @L["Converting photo to JPEG with a 1440p resolution..."] + + @if(_convertJpeg1440 == true) + { + @L["OK!"] + } + else if(_convertJpeg1440 == false) + { + @L["Error!"] + } + + @if(_convertJpeg1440 == true) + { + + + + } +
+ @L["Converting photo to JPEG with a 4K resolution..."] + + @if(_convertJpeg4k == true) + { + @L["OK!"] + } + else if(_convertJpeg4k == false) + { + @L["Error!"] + } + + @if(_convertJpeg4k == true) + { + + + + } +
+ @L["Converting photo to JPEG2000 with an HD resolution (thumbnail)..."] + + @if(_convertJp2kHdTh == true) + { + @L["OK!"] + } + else if(_convertJp2kHdTh == false) + { + @L["Error!"] + } + + @if(_convertJp2kHdTh == true) + { + + + + } +
+ @L["Converting photo to JPEG2000 with a 1440p resolution (thumbnail)..."] + + @if(_convertJp2k1440Th == true) + { + @L["OK!"] + } + else if(_convertJp2k1440Th == false) + { + @L["Error!"] + } + + @if(_convertJp2k1440Th == true) + { + + + + } +
+ @L["Converting photo to JPEG2000 with a 4K resolution (thumbnail)..."] + + @if(_convertJp2k4kTh == true) + { + @L["OK!"] + } + else if(_convertJp2k4kTh == false) + { + @L["Error!"] + } + + @if(_convertJp2k4kTh == true) + { + + + + } +
+ @L["Converting photo to JPEG2000 with an HD resolution..."] + + @if(_convertJp2kHd == true) + { + @L["OK!"] + } + else if(_convertJp2kHd == false) + { + @L["Error!"] + } + + @if(_convertJp2kHd == true) + { + + + + } +
+ @L["Converting photo to JPEG2000 with a 1440p resolution..."] + + @if(_convertJp2k1440 == true) + { + @L["OK!"] + } + else if(_convertJp2k1440 == false) + { + @L["Error!"] + } + + @if(_convertJp2k1440 == true) + { + + + + } +
+ @L["Converting photo to JPEG2000 with a 4K resolution..."] + + @if(_convertJp2k4k == true) + { + @L["OK!"] + } + else if(_convertJp2k4k == false) + { + @L["Error!"] + } + + @if(_convertJp2k4k == true) + { + + + + } +
+ @L["Converting photo to WebP with an HD resolution (thumbnail)..."] + + @if(_convertWebpHdTh == true) + { + @L["OK!"] + } + else if(_convertWebpHdTh == false) + { + @L["Error!"] + } + + @if(_convertWebpHdTh == true) + { + + + + } +
+ @L["Converting photo to WebP with a 1440p resolution (thumbnail)..."] + + @if(_convertWebp1440Th == true) + { + @L["OK!"] + } + else if(_convertWebp1440Th == false) + { + @L["Error!"] + } + + @if(_convertWebp1440Th == true) + { + + + + } +
+ @L["Converting photo to WebP with a 4K resolution (thumbnail)..."] + + @if(_convertWebp4kTh == true) + { + @L["OK!"] + } + else if(_convertWebp4kTh == false) + { + @L["Error!"] + } + + @if(_convertWebp4kTh == true) + { + + + + } +
+ @L["Converting photo to WebP with an HD resolution..."] + + @if(_convertWebpHd == true) + { + @L["OK!"] + } + else if(_convertWebpHd == false) + { + @L["Error!"] + } + + @if(_convertWebpHd == true) + { + + + + } +
+ @L["Converting photo to WebP with a 1440p resolution..."] + + @if(_convertWebp1440 == true) + { + @L["OK!"] + } + else if(_convertWebp1440 == false) + { + @L["Error!"] + } + + @if(_convertWebp1440 == true) + { + + + + } +
+ @L["Converting photo to WebP with a 4K resolution..."] + + @if(_convertWebp4k == true) + { + @L["OK!"] + } + else if(_convertWebp4k == false) + { + @L["Error!"] + } + + @if(_convertWebp4k == true) + { + + + + } +
+ @L["Converting photo to HEIF with an HD resolution (thumbnail)..."] + + @if(_convertHeifHdTh == true) + { + @L["OK!"] + } + else if(_convertHeifHdTh == false) + { + @L["Error!"] + } + + @if(_convertHeifHdTh == true) + { + + + + } +
+ @L["Converting photo to HEIF with a 1440p resolution (thumbnail)..."] + + @if(_convertHeif1440Th == true) + { + @L["OK!"] + } + else if(_convertHeif1440Th == false) + { + @L["Error!"] + } + + @if(_convertHeif1440Th == true) + { + + + + } +
+ @L["Converting photo to HEIF with a 4K resolution (thumbnail)..."] + + @if(_convertHeif4kTh == true) + { + @L["OK!"] + } + else if(_convertHeif4kTh == false) + { + @L["Error!"] + } + + @if(_convertHeif4kTh == true) + { + + + + } +
+ @L["Converting photo to HEIF with an HD resolution..."] + + @if(_convertHeifHd == true) + { + @L["OK!"] + } + else if(_convertHeifHd == false) + { + @L["Error!"] + } + + @if(_convertHeifHd == true) + { + + + + } +
+ @L["Converting photo to HEIF with a 1440p resolution..."] + + @if(_convertHeif1440 == true) + { + @L["OK!"] + } + else if(_convertHeif1440 == false) + { + @L["Error!"] + } + + @if(_convertHeif1440 == true) + { + + + + } +
+ @L["Converting photo to HEIF with a 4K resolution..."] + + @if(_convertHeif4K == true) + { + @L["OK!"] + } + else if(_convertHeif4K == false) + { + @L["Error!"] + } + + @if(_convertHeif4K == true) + { + + + + } +
+ @L["Converting photo to AV1F with an HD resolution (thumbnail)..."] + + @if(_convertAvifHdTh == true) + { + @L["OK!"] + } + else if(_convertAvifHdTh == false) + { + @L["Error!"] + } + + @if(_convertAvifHdTh == true) + { + + + + } +
+ @L["Converting photo to AV1F with a 1440p resolution (thumbnail)..."] + + @if(_convertAvif1440Th == true) + { + @L["OK!"] + } + else if(_convertAvif1440Th == false) + { + @L["Error!"] + } + + @if(_convertAvif1440Th == true) + { + + + + } +
+ @L["Converting photo to AV1F with a 4K resolution (thumbnail)..."] + + @if(_convertAvif4kTh == true) + { + @L["OK!"] + } + else if(_convertAvif4kTh == false) + { + @L["Error!"] + } + + @if(_convertAvif4kTh == true) + { + + + + } +
+ @L["Converting photo to AV1F with an HD resolution..."] + + @if(_convertAvifHd == true) + { + @L["OK!"] + } + else if(_convertAvifHd == false) + { + @L["Error!"] + } + + @if(_convertAvifHd == true) + { + + + + } +
+ @L["Converting photo to AV1F with a 1440p resolution..."] + + @if(_convertAvif1440 == true) + { + @L["OK!"] + } + else if(_convertAvif1440 == false) + { + @L["Error!"] + } + + @if(_convertAvif1440 == true) + { + + + + } +
+ @L["Converting photo to AV1F with a 4K resolution..."] + + @if(_convertAvif4K == true) + { + @L["OK!"] + } + else if(_convertAvif4K == false) + { + @L["Error!"] + } + + @if(_convertAvif4K == true) + { + + + + } +
+ @L["Adding photo to database..."] + + @if(_addToDatabase == true) + { + @L["OK!"] + } + else if(_addToDatabase == false) + { + @L["Error!"] + } + +
-} + } } @@ -1211,11 +1308,11 @@
@L["Uploaded by"] - ")" /> + ")"/> @L["Uploaded date"] - + @L["Scan type"] @@ -1223,7 +1320,7 @@ @foreach(uint value in Enum.GetValues(typeof(DocumentScanType))) { @(((DocumentScanType)value).ToString()) -} + } @@ -1238,7 +1335,7 @@ -} + } @L["Author"] @@ -1252,11 +1349,12 @@ -} + } @L["Scanner manufacturer"] - @L["Unknown (scanner manufacturer)"] + @L["Unknown (scanner manufacturer)"] @if(!_unknownScanScannerManufacturer) { @@ -1266,7 +1364,7 @@ -} + } @L["Scanner model"] @@ -1280,7 +1378,7 @@ -} + } @L["Color space"] @@ -1291,9 +1389,9 @@ @foreach(ushort value in Enum.GetValues(typeof(ColorSpace))) { @(((ColorSpace)value).ToString()) -} + } -} + } @L["Creation date"] @@ -1307,7 +1405,7 @@ -} + } @L["Exif version"] @@ -1321,21 +1419,23 @@ -} + } @L["Horizontal resolution"] - @L["Unknown (horizontal resolution)"] + @L["Unknown (horizontal resolution)"] @if(!_unknownScanHorizontalResolution) { - + @L["Please enter a valid horizontal resolution."] -} + } @L["Resolution unit"] @@ -1346,9 +1446,9 @@ @foreach(ushort value in Enum.GetValues(typeof(ResolutionUnit))) { @(((ResolutionUnit)value).ToString()) -} + } -} + } @L["Software used"] @@ -1362,21 +1462,23 @@ -} + } @L["Vertical resolution"] - @L["Unknown (vertical resolution)"] + @L["Unknown (vertical resolution)"] @if(!_unknownScanVerticalResolution) { - + @L["Please enter a valid vertical resolution."] -} + } @L["User comments"] @@ -1390,7 +1492,7 @@ -} + } diff --git a/Marechai/Pages/Admin/Details/MagazineIssue.razor.cs b/Marechai/Pages/Admin/Details/MagazineIssue.razor.cs index 25db5946..da9e5e4c 100644 --- a/Marechai/Pages/Admin/Details/MagazineIssue.razor.cs +++ b/Marechai/Pages/Admin/Details/MagazineIssue.razor.cs @@ -41,1306 +41,1272 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; using Tewr.Blazor.FileReader; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class MagazineIssue { - public partial class MagazineIssue + const int MAX_UPLOAD_SIZE = 25 * 1048576; + bool _addingMachine; + bool _addingMachineFamily; + int? _addingMachineFamilyId; + int? _addingMachineId; + bool _addingPerson; + int? _addingPersonId; + string _addingPersonRoleId; + bool _addingScan; + bool? _addToDatabase; + bool _allFinished; + AuthenticationState _authState; + bool? _convertAvif1440; + bool? _convertAvif1440Th; + bool? _convertAvif4K; + bool? _convertAvif4kTh; + bool? _convertAvifHd; + bool? _convertAvifHdTh; + bool? _convertHeif1440; + bool? _convertHeif1440Th; + bool? _convertHeif4K; + bool? _convertHeif4kTh; + bool? _convertHeifHd; + bool? _convertHeifHdTh; + bool? _convertJp2k1440; + bool? _convertJp2k1440Th; + bool? _convertJp2k4k; + bool? _convertJp2k4kTh; + bool? _convertJp2kHd; + bool? _convertJp2kHdTh; + bool? _convertJpeg1440; + bool? _convertJpeg1440Th; + bool? _convertJpeg4k; + bool? _convertJpeg4kTh; + bool? _convertJpegHd; + bool? _convertJpegHdTh; + bool? _convertWebp1440; + bool? _convertWebp1440Th; + bool? _convertWebp4k; + bool? _convertWebp4kTh; + bool? _convertWebpHd; + bool? _convertWebpHdTh; + bool _creating; + MagazineByMachineViewModel _currentMagazineByMachine; + MagazineByMachineFamilyViewModel _currentMagazineByMachineFamily; + PersonByMagazineViewModel _currentPersonByMagazine; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _deletingMagazineByMachine; + bool _deletingMagazineByMachineFamily; + bool _deletingPersonByMagazine; + bool _deletingScan; + bool _editing; + bool _editingScan; + bool? _extractExif; + Modal _frmDelete; + string _imageFormat; + ElementReference _inputUpload; + bool _loaded; + List _machineFamilies; + List _machines; + List _magazineMachineFamilies; + List _magazineMachines; + List _magazinePeople; + List _magazines; + MagazineIssueViewModel _model; + bool? _moveFile; + List _people; + double _progressValue; + List _roles; + bool _savingMachine; + bool _savingMachineFamily; + bool _savingPerson; + List _scans; + ApplicationUser _scanUser; + MagazineScanViewModel _selectedScan; + bool _unknownIssueNumber; + bool _unknownNativeCaption; + bool _unknownPages; + bool _unknownProductCode; + bool _unknownPublished; + bool _unknownScanAuthor; + bool _unknownScanColorSpace; + bool _unknownScanComments; + bool _unknownScanCreationDate; + bool _unknownScanExifVersion; + bool _unknownScanHorizontalResolution; + bool _unknownScanPage; + bool _unknownScanResolutionUnit; + bool _unknownScanScannerManufacturer; + bool _unknownScanScannerModel; + bool _unknownScanSoftwareUsed; + bool _unknownScanVerticalResolution; + bool _uploaded; + bool _uploadError; + string _uploadErrorMessage; + bool _uploading; + uint? _uploadScanPage; + uint _uploadScanType; + + [Parameter] + public long Id { get; set; } + + ushort ScanColorSpace { - const int _maxUploadSize = 25 * 1048576; - bool _addingMachine; - bool _addingMachineFamily; - int? _addingMachineFamilyId; - int? _addingMachineId; - bool _addingPerson; - int? _addingPersonId; - string _addingPersonRoleId; - bool _addingScan; - bool? _addToDatabase; - bool _allFinished; - AuthenticationState _authState; - bool? _convertAvif1440; - bool? _convertAvif1440Th; - bool? _convertAvif4k; - bool? _convertAvif4kTh; - bool? _convertAvifHd; - bool? _convertAvifHdTh; - bool? _convertHeif1440; - bool? _convertHeif1440Th; - bool? _convertHeif4k; - bool? _convertHeif4kTh; - bool? _convertHeifHd; - bool? _convertHeifHdTh; - bool? _convertJp2k1440; - bool? _convertJp2k1440Th; - bool? _convertJp2k4k; - bool? _convertJp2k4kTh; - bool? _convertJp2kHd; - bool? _convertJp2kHdTh; - bool? _convertJpeg1440; - bool? _convertJpeg1440Th; - bool? _convertJpeg4k; - bool? _convertJpeg4kTh; - bool? _convertJpegHd; - bool? _convertJpegHdTh; - bool? _convertWebp1440; - bool? _convertWebp1440Th; - bool? _convertWebp4k; - bool? _convertWebp4kTh; - bool? _convertWebpHd; - bool? _convertWebpHdTh; - bool _creating; - MagazineByMachineViewModel _currentMagazineByMachine; - MagazineByMachineFamilyViewModel _currentMagazineByMachineFamily; - PersonByMagazineViewModel _currentPersonByMagazine; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _deletingMagazineByMachine; - bool _deletingMagazineByMachineFamily; - bool _deletingPersonByMagazine; - bool _deletingScan; - bool _editing; - bool _editingScan; - bool? _extractExif; - Modal _frmDelete; - string _imageFormat; - ElementReference _inputUpload; - bool _loaded; - List _machineFamilies; - List _machines; - List _magazineMachineFamilies; - List _magazineMachines; - List _magazinePeople; - List _magazines; - MagazineIssueViewModel _model; - bool? _moveFile; - List _people; - double _progressValue; - List _roles; - bool _savingMachine; - bool _savingMachineFamily; - bool _savingPerson; - List _scans; - ApplicationUser _scanUser; - MagazineScanViewModel _selectedScan; - bool _unknownIssueNumber; - bool _unknownNativeCaption; - bool _unknownPages; - bool _unknownProductCode; - bool _unknownPublished; - bool _unknownScanAuthor; - bool _unknownScanColorSpace; - bool _unknownScanComments; - bool _unknownScanCreationDate; - bool _unknownScanExifVersion; - bool _unknownScanHorizontalResolution; - bool _unknownScanPage; - bool _unknownScanResolutionUnit; - bool _unknownScanScannerManufacturer; - bool _unknownScanScannerModel; - bool _unknownScanSoftwareUsed; - bool _unknownScanVerticalResolution; - bool _uploaded; - bool _uploadError; - string _uploadErrorMessage; - bool _uploading; - uint? _uploadScanPage; - uint _uploadScanType; - - [Parameter] - public long Id { get; set; } - - ushort ScanColorSpace + get { - get + if(_selectedScan.ColorSpace is null) return 0; + + return (ushort)_selectedScan.ColorSpace; + } + set => _selectedScan.ColorSpace = (ColorSpace)value; + } + + ushort ScanResolutionUnit + { + get + { + if(_selectedScan.ResolutionUnit is null) return 0; + + return (ushort)_selectedScan.ResolutionUnit; + } + set => _selectedScan.ResolutionUnit = (ResolutionUnit)value; + } + + uint ScanType + { + get + { + if(_selectedScan.ResolutionUnit is null) return 0; + + return (uint)_selectedScan.ResolutionUnit; + } + set => _selectedScan.Type = (DocumentScanType)value; + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; + + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/magazine_issues/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _magazines = await MagazinesService.GetTitlesAsync(); + _machineFamilies = await MachineFamiliesService.GetAsync(); + _machines = await MachinesService.GetAsync(); + _roles = await DocumentRolesService.GetEnabledAsync(); + _model = _creating ? new MagazineIssueViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _addingMachineFamilyId = _machineFamilies.First().Id; + _magazineMachineFamilies = await MagazinesByMachineFamilyService.GetByMagazine(Id); + _addingMachineId = _machines.First().Id; + _magazineMachines = await MagazinesByMachineService.GetByMagazine(Id); + _addingPersonRoleId = _roles.First().Id; + _magazinePeople = await PeopleByMagazineService.GetByMagazine(Id); + _scans = await MagazineScansService.GetGuidsByMagazineAsync(Id); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/magazine_issues/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownProductCode = string.IsNullOrWhiteSpace(_model.ProductCode); + _unknownIssueNumber = !_model.IssueNumber.HasValue; + _unknownNativeCaption = string.IsNullOrWhiteSpace(_model.NativeCaption); + _unknownPublished = !_model.Published.HasValue; + _unknownPages = !_model.Pages.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) + { + NavigationManager.ToBaseRelativePath("admin/magazine_issues"); + + return; + } + + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownNativeCaption) + _model.NativeCaption = null; + else if(string.IsNullOrWhiteSpace(_model.NativeCaption)) return; + + if(_unknownPages) + _model.Pages = null; + else if(_model.Pages < 1) return; + + if(_unknownIssueNumber) + _model.IssueNumber = null; + else if(_model.IssueNumber < 1) return; + + if(_unknownPublished) + _model.Published = null; + else if(_model.Published?.Date >= DateTime.UtcNow.Date) return; + + // TODO: Recognize JAN-13, EAN-13, UPC, etc + if(_unknownProductCode) + _model.ProductCode = null; + else if(string.IsNullOrWhiteSpace(_model.ProductCode)) return; + + if(string.IsNullOrWhiteSpace(_model.Caption)) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateCaption(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Caption must be smaller than 256 characters."], 256); + + void ValidatePublished(ValidatorEventArgs e) => Validators.ValidateDate(e); + + void ValidateNativeCaption(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Native caption must be smaller than 256 characters."], 256); + + void ValidatePages(ValidatorEventArgs e) => Validators.ValidateShort(e, 1); + + void ValidateIssueNumber(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1); + + void ValidateProductCode(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Product code must be smaller than 18 characters."], 18); + + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _deletingMagazineByMachineFamily = false; + _currentMagazineByMachineFamily = null; + _deletingMagazineByMachine = false; + _currentMagazineByMachine = null; + _deletingPersonByMagazine = false; + _currentPersonByMagazine = null; + _deletingScan = false; + _selectedScan = null; + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_deletingMagazineByMachineFamily) + await ConfirmDeleteMagazineByMachineFamily(); + else if(_deletingMagazineByMachine) + await ConfirmDeleteMagazineByMachine(); + else if(_deletingPersonByMagazine) + await ConfirmDeletePersonByMagazine(); + else if(_deletingScan) await ConfirmDeleteScan(); + } + + void OnAddFamilyClick() + { + _addingMachineFamily = true; + _savingMachineFamily = false; + _addingMachineFamilyId = _machineFamilies.First().Id; + } + + void CancelAddFamily() + { + _addingMachineFamily = false; + _savingMachineFamily = false; + _addingMachineFamilyId = null; + } + + async Task ConfirmAddFamily() + { + if(_addingMachineFamilyId is null || _addingMachineFamilyId <= 0) + { + CancelAddFamily(); + + return; + } + + _savingMachineFamily = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await MagazinesByMachineFamilyService.CreateAsync(_addingMachineFamilyId.Value, + Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _magazineMachineFamilies = await MagazinesByMachineFamilyService.GetByMagazine(Id); + + _addingMachineFamily = false; + _savingMachineFamily = false; + _addingMachineFamilyId = null; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ShowMachineFamilyDeleteModal(long itemId) + { + _currentMagazineByMachineFamily = _magazineMachineFamilies.FirstOrDefault(n => n.Id == itemId); + _deletingMagazineByMachineFamily = true; + _deleteTitle = L["Delete machine family from this magazine"]; + + _deleteText = + string.Format(L["Are you sure you want to delete the machine family {0} from this magazine issue?"], + _currentMagazineByMachineFamily?.MachineFamily); + + _frmDelete.Show(); + } + + async Task ConfirmDeleteMagazineByMachineFamily() + { + if(_currentMagazineByMachineFamily is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await MagazinesByMachineFamilyService.DeleteAsync(_currentMagazineByMachineFamily.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _magazineMachineFamilies = await MagazinesByMachineFamilyService.GetByMagazine(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void OnAddMachineClick() + { + _addingMachine = true; + _savingMachine = false; + _addingMachineId = _machines.First().Id; + } + + void CancelAddMachine() + { + _addingMachine = false; + _savingMachine = false; + _addingMachineId = null; + } + + async Task ConfirmAddMachine() + { + if(_addingMachineId is null || _addingMachineId <= 0) + { + CancelAddMachine(); + + return; + } + + _savingMachine = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await MagazinesByMachineService.CreateAsync(_addingMachineId.Value, + Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _magazineMachines = await MagazinesByMachineService.GetByMagazine(Id); + + _addingMachine = false; + _savingMachine = false; + _addingMachineId = null; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ShowMachineDeleteModal(long itemId) + { + _currentMagazineByMachine = _magazineMachines.FirstOrDefault(n => n.Id == itemId); + _deletingMagazineByMachine = true; + _deleteTitle = L["Delete machine from this magazine"]; + + _deleteText = string.Format(L["Are you sure you want to delete the machine {0} from this magazine issue?"], + _currentMagazineByMachine?.Machine); + + _frmDelete.Show(); + } + + async Task ConfirmDeleteMagazineByMachine() + { + if(_currentMagazineByMachine is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await MagazinesByMachineService.DeleteAsync(_currentMagazineByMachine.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _magazineMachines = await MagazinesByMachineService.GetByMagazine(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void OnAddPersonClick() + { + _addingPerson = true; + _savingPerson = false; + _addingPersonId = _people.First().Id; + } + + void CancelAddPerson() + { + _addingPerson = false; + _savingPerson = false; + _addingPersonId = null; + } + + async Task ConfirmAddPerson() + { + if(_addingPersonId is null || _addingPersonId <= 0) + { + CancelAddPerson(); + + return; + } + + _savingPerson = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await PeopleByMagazineService.CreateAsync(_addingPersonId.Value, + Id, + _addingPersonRoleId, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _magazinePeople = await PeopleByMagazineService.GetByMagazine(Id); + + _addingPerson = false; + _savingPerson = false; + _addingPersonId = null; + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ShowPersonDeleteModal(long itemId) + { + _currentPersonByMagazine = _magazinePeople.FirstOrDefault(n => n.Id == itemId); + _deletingPersonByMagazine = true; + _deleteTitle = L["Delete person from this magazine"]; + + _deleteText = + string.Format(L["Are you sure you want to delete the person {0} with role {1} from this magazine?"], + _currentPersonByMagazine?.FullName, + _currentPersonByMagazine?.Role); + + _frmDelete.Show(); + } + + async Task ConfirmDeletePersonByMagazine() + { + if(_currentPersonByMagazine is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await PeopleByMagazineService.DeleteAsync(_currentPersonByMagazine.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _magazinePeople = await PeopleByMagazineService.GetByMagazine(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ValidateScanAuthor(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Scan author must be smaller than 256 characters."], 256); + + void ValidateScannerManufacturer(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Scanner manufacturer must be smaller than 256 characters."], 256); + + void ValidateScannerModel(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Scanner model must be smaller than 256 characters."], 256); + + void ValidateDate(ValidatorEventArgs e) + { + if(!(e.Value is DateTime item) || item.Year <= 1816 || item >= DateTime.UtcNow) + e.Status = ValidationStatus.Error; + else + e.Status = ValidationStatus.Success; + } + + void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) + { + if(e.Value is double item && item > 0) + e.Status = ValidationStatus.Success; + else + e.Status = ValidationStatus.Error; + } + + void ValidateExifVersion(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Exif version must be 255 characters or less."], 255); + + void ValidateLens(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Lens name must be 255 characters or less."], 255); + + void ValidateSoftwareUsed(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Software used must be 255 characters or less."], 255); + + void ValidateComments(ValidatorEventArgs e) => + Validators.ValidateString(e, L["User comments must be 255 characters or less."], 255); + + void ValidateUnsignedIntegerBiggerThanZero(ValidatorEventArgs e) + { + if(e.Value is uint item && item > 0) + e.Status = ValidationStatus.Success; + else + e.Status = ValidationStatus.Error; + } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + async Task UploadFile() + { + var processExiftool = new Process + { + StartInfo = { - if(_selectedScan.ColorSpace is null) - return 0; - - return (ushort)_selectedScan.ColorSpace; + FileName = "exiftool", + CreateNoWindow = true, + RedirectStandardError = true, + RedirectStandardOutput = true } - set => _selectedScan.ColorSpace = (ColorSpace)value; - } + }; - ushort ScanResolutionUnit + var processIdentify = new Process { - get + StartInfo = { - if(_selectedScan.ResolutionUnit is null) - return 0; - - return (ushort)_selectedScan.ResolutionUnit; + FileName = "identify", + CreateNoWindow = true, + RedirectStandardError = true, + RedirectStandardOutput = true } - set => _selectedScan.ResolutionUnit = (ResolutionUnit)value; - } + }; - uint ScanType + var processConvert = new Process { - get + StartInfo = { - if(_selectedScan.ResolutionUnit is null) - return 0; - - return (uint)_selectedScan.ResolutionUnit; + FileName = "convert", + CreateNoWindow = true, + RedirectStandardError = true, + RedirectStandardOutput = true } - set => _selectedScan.Type = (DocumentScanType)value; + }; + + string identifyOutput; + string convertOutput; + string exiftoolOutput; + + try + { + processIdentify.Start(); + identifyOutput = await processIdentify.StandardOutput.ReadToEndAsync(); + processIdentify.WaitForExit(); + processConvert.Start(); + convertOutput = await processConvert.StandardOutput.ReadToEndAsync(); + processConvert.WaitForExit(); + processExiftool.Start(); + exiftoolOutput = await processExiftool.StandardOutput.ReadToEndAsync(); + processExiftool.WaitForExit(); + } + catch(Exception) + { + _uploadError = true; + _uploadErrorMessage = L["Cannot run ImageMagick please contact the administrator."]; + + return; } - protected override async Task OnAfterRenderAsync(bool firstRender) + IFileReference file = (await FileReaderService.CreateReference(_inputUpload).EnumerateFilesAsync()) + .FirstOrDefault(); + + if(file is null) return; + + IFileInfo fileInfo = await file.ReadFileInfoAsync(); + + if(fileInfo.Size > MAX_UPLOAD_SIZE) { - if(_loaded) - return; + _uploadError = true; + _uploadErrorMessage = L["The selected file is too big."]; - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/magazine_issues/create", StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _magazines = await MagazinesService.GetTitlesAsync(); - _machineFamilies = await MachineFamiliesService.GetAsync(); - _machines = await MachinesService.GetAsync(); - _roles = await DocumentRolesService.GetEnabledAsync(); - _model = _creating ? new MagazineIssueViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _addingMachineFamilyId = _machineFamilies.First().Id; - _magazineMachineFamilies = await MagazinesByMachineFamilyService.GetByMagazine(Id); - _addingMachineId = _machines.First().Id; - _magazineMachines = await MagazinesByMachineService.GetByMagazine(Id); - _addingPersonRoleId = _roles.First().Id; - _magazinePeople = await PeopleByMagazineService.GetByMagazine(Id); - _scans = await MagazineScansService.GetGuidsByMagazineAsync(Id); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/magazine_issues/edit/", - StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() + string tmpPath = Path.GetTempFileName(); + + FileStream outFs; + + try { - _unknownProductCode = string.IsNullOrWhiteSpace(_model.ProductCode); - _unknownIssueNumber = !_model.IssueNumber.HasValue; - _unknownNativeCaption = string.IsNullOrWhiteSpace(_model.NativeCaption); - _unknownPublished = !_model.Published.HasValue; - _unknownPages = !_model.Pages.HasValue; + outFs = new FileStream(tmpPath, FileMode.Open, FileAccess.ReadWrite); + } + catch(Exception) + { + _uploadError = true; + _uploadErrorMessage = L["There was an error uploading the file."]; + + return; } - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } + _uploading = true; - async void OnCancelClicked() - { - _editing = false; + await using AsyncDisposableStream fs = await file.OpenReadAsync(); + var buffer = new byte[20480]; - if(_creating) + try + { + double lastProgress = 0; + int count; + + while((count = await fs.ReadAsync(buffer, 0, buffer.Length)) != 0) { - NavigationManager.ToBaseRelativePath("admin/magazine_issues"); + await outFs.WriteAsync(buffer, 0, count); - return; + double progress = (double)fs.Position * 100 / fs.Length; + + if(!(progress > lastProgress + 0.01)) continue; + + _progressValue = progress; + await InvokeAsync(StateHasChanged); + await Task.Yield(); + lastProgress = progress; } + } + catch(Exception) + { + _uploading = false; + _uploadError = true; + _uploadErrorMessage = L["There was an error uploading the file."]; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); + return; } - async void OnSaveClicked() + outFs.Close(); + _uploading = false; + await InvokeAsync(StateHasChanged); + await Task.Yield(); + + processIdentify = new Process { - if(_unknownNativeCaption) - _model.NativeCaption = null; - else if(string.IsNullOrWhiteSpace(_model.NativeCaption)) - return; - - if(_unknownPages) - _model.Pages = null; - else if(_model.Pages < 1) - return; - - if(_unknownIssueNumber) - _model.IssueNumber = null; - else if(_model.IssueNumber < 1) - return; - - if(_unknownPublished) - _model.Published = null; - else if(_model.Published?.Date >= DateTime.UtcNow.Date) - return; - - // TODO: Recognize JAN-13, EAN-13, UPC, etc - if(_unknownProductCode) - _model.ProductCode = null; - else if(string.IsNullOrWhiteSpace(_model.ProductCode)) - return; - - if(string.IsNullOrWhiteSpace(_model.Caption)) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateCaption(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Caption must be smaller than 256 characters."], 256); - - void ValidatePublished(ValidatorEventArgs e) => Validators.ValidateDate(e); - - void ValidateNativeCaption(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Native caption must be smaller than 256 characters."], 256); - - void ValidatePages(ValidatorEventArgs e) => Validators.ValidateShort(e, 1); - - void ValidateIssueNumber(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1); - - void ValidateProductCode(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Product code must be smaller than 18 characters."], 18); - - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _deletingMagazineByMachineFamily = false; - _currentMagazineByMachineFamily = null; - _deletingMagazineByMachine = false; - _currentMagazineByMachine = null; - _deletingPersonByMagazine = false; - _currentPersonByMagazine = null; - _deletingScan = false; - _selectedScan = null; - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_deletingMagazineByMachineFamily) - await ConfirmDeleteMagazineByMachineFamily(); - else if(_deletingMagazineByMachine) - await ConfirmDeleteMagazineByMachine(); - else if(_deletingPersonByMagazine) - await ConfirmDeletePersonByMagazine(); - else if(_deletingScan) - await ConfirmDeleteScan(); - } - - void OnAddFamilyClick() - { - _addingMachineFamily = true; - _savingMachineFamily = false; - _addingMachineFamilyId = _machineFamilies.First().Id; - } - - void CancelAddFamily() - { - _addingMachineFamily = false; - _savingMachineFamily = false; - _addingMachineFamilyId = null; - } - - async Task ConfirmAddFamily() - { - if(_addingMachineFamilyId is null || - _addingMachineFamilyId <= 0) + StartInfo = { - CancelAddFamily(); - - return; + FileName = "identify", + CreateNoWindow = true, + RedirectStandardError = true, + RedirectStandardOutput = true, + ArgumentList = + { + tmpPath + } } + }; - _savingMachineFamily = true; + processIdentify.Start(); + identifyOutput = await processIdentify.StandardOutput.ReadToEndAsync(); + processIdentify.WaitForExit(); - // Yield thread to let UI to update - await Task.Yield(); + if(processIdentify.ExitCode != 0 || string.IsNullOrWhiteSpace(identifyOutput)) + { + _uploading = false; + _uploadError = true; + _uploadErrorMessage = L["The uploaded file was not recognized as an image."]; + File.Delete(tmpPath); - await MagazinesByMachineFamilyService.CreateAsync(_addingMachineFamilyId.Value, Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _magazineMachineFamilies = await MagazinesByMachineFamilyService.GetByMagazine(Id); - - _addingMachineFamily = false; - _savingMachineFamily = false; - _addingMachineFamilyId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); + return; } - void ShowMachineFamilyDeleteModal(long itemId) + string[] pieces = identifyOutput.Substring(tmpPath.Length).Split(" ", StringSplitOptions.RemoveEmptyEntries); + + if(pieces.Length < 2) { - _currentMagazineByMachineFamily = _magazineMachineFamilies.FirstOrDefault(n => n.Id == itemId); - _deletingMagazineByMachineFamily = true; - _deleteTitle = L["Delete machine family from this magazine"]; + _uploading = false; + _uploadError = true; + _uploadErrorMessage = L["The uploaded file was not recognized as an image."]; + File.Delete(tmpPath); - _deleteText = - string.Format(L["Are you sure you want to delete the machine family {0} from this magazine issue?"], - _currentMagazineByMachineFamily?.MachineFamily); - - _frmDelete.Show(); + return; } - async Task ConfirmDeleteMagazineByMachineFamily() + // TODO: Move this to Helpers, keep progress + + string extension = ImageMagick.GetExtension(pieces[0]); + + if(string.IsNullOrWhiteSpace(extension)) { - if(_currentMagazineByMachineFamily is null) - return; + _uploading = false; + _uploadError = true; + _uploadErrorMessage = L["The uploaded file was not recognized as an image."]; + File.Delete(tmpPath); - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await MagazinesByMachineFamilyService.DeleteAsync(_currentMagazineByMachineFamily.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _magazineMachineFamilies = await MagazinesByMachineFamilyService.GetByMagazine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); + return; } - void OnAddMachineClick() + _imageFormat = pieces[0]; + _uploaded = true; + + _selectedScan = new MagazineScanViewModel { - _addingMachine = true; - _savingMachine = false; - _addingMachineId = _machines.First().Id; - } + UserId = (await UserManager.GetUserAsync(_authState.User)).Id, + MagazineId = Id, + Id = Guid.NewGuid(), + OriginalExtension = extension, + UploadDate = DateTime.UtcNow, + Page = _unknownScanPage ? null : _uploadScanPage, + Type = (DocumentScanType)_uploadScanType + }; - void CancelAddMachine() + try { - _addingMachine = false; - _savingMachine = false; - _addingMachineId = null; - } - - async Task ConfirmAddMachine() - { - if(_addingMachineId is null || - _addingMachineId <= 0) - { - CancelAddMachine(); - - return; - } - - _savingMachine = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await MagazinesByMachineService.CreateAsync(_addingMachineId.Value, Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _magazineMachines = await MagazinesByMachineService.GetByMagazine(Id); - - _addingMachine = false; - _savingMachine = false; - _addingMachineId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ShowMachineDeleteModal(long itemId) - { - _currentMagazineByMachine = _magazineMachines.FirstOrDefault(n => n.Id == itemId); - _deletingMagazineByMachine = true; - _deleteTitle = L["Delete machine from this magazine"]; - - _deleteText = string.Format(L["Are you sure you want to delete the machine {0} from this magazine issue?"], - _currentMagazineByMachine?.Machine); - - _frmDelete.Show(); - } - - async Task ConfirmDeleteMagazineByMachine() - { - if(_currentMagazineByMachine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await MagazinesByMachineService.DeleteAsync(_currentMagazineByMachine.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _magazineMachines = await MagazinesByMachineService.GetByMagazine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void OnAddPersonClick() - { - _addingPerson = true; - _savingPerson = false; - _addingPersonId = _people.First().Id; - } - - void CancelAddPerson() - { - _addingPerson = false; - _savingPerson = false; - _addingPersonId = null; - } - - async Task ConfirmAddPerson() - { - if(_addingPersonId is null || - _addingPersonId <= 0) - { - CancelAddPerson(); - - return; - } - - _savingPerson = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await PeopleByMagazineService.CreateAsync(_addingPersonId.Value, Id, _addingPersonRoleId, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _magazinePeople = await PeopleByMagazineService.GetByMagazine(Id); - - _addingPerson = false; - _savingPerson = false; - _addingPersonId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ShowPersonDeleteModal(long itemId) - { - _currentPersonByMagazine = _magazinePeople.FirstOrDefault(n => n.Id == itemId); - _deletingPersonByMagazine = true; - _deleteTitle = L["Delete person from this magazine"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the person {0} with role {1} from this magazine?"], - _currentPersonByMagazine?.FullName, _currentPersonByMagazine?.Role); - - _frmDelete.Show(); - } - - async Task ConfirmDeletePersonByMagazine() - { - if(_currentPersonByMagazine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await PeopleByMagazineService.DeleteAsync(_currentPersonByMagazine.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _magazinePeople = await PeopleByMagazineService.GetByMagazine(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ValidateScanAuthor(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Scan author must be smaller than 256 characters."], 256); - - void ValidateScannerManufacturer(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Scanner manufacturer must be smaller than 256 characters."], 256); - - void ValidateScannerModel(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Scanner model must be smaller than 256 characters."], 256); - - void ValidateDate(ValidatorEventArgs e) - { - if(!(e.Value is DateTime item) || - item.Year <= 1816 || - item >= DateTime.UtcNow) - e.Status = ValidationStatus.Error; - else - e.Status = ValidationStatus.Success; - } - - void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) - { - if(e.Value is double item && - item > 0) - e.Status = ValidationStatus.Success; - else - e.Status = ValidationStatus.Error; - } - - void ValidateExifVersion(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Exif version must be 255 characters or less."], 255); - - void ValidateLens(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Lens name must be 255 characters or less."], 255); - - void ValidateSoftwareUsed(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Software used must be 255 characters or less."], 255); - - void ValidateComments(ValidatorEventArgs e) => - Validators.ValidateString(e, L["User comments must be 255 characters or less."], 255); - - void ValidateUnsignedIntegerBiggerThanZero(ValidatorEventArgs e) - { - if(e.Value is uint item && - item > 0) - e.Status = ValidationStatus.Success; - else - e.Status = ValidationStatus.Error; - } - - [SuppressMessage("ReSharper", "InconsistentNaming")] - async Task UploadFile() - { - var processExiftool = new Process + processExiftool = new Process { StartInfo = { FileName = "exiftool", CreateNoWindow = true, RedirectStandardError = true, - RedirectStandardOutput = true - } - }; - - var processIdentify = new Process - { - StartInfo = - { - FileName = "identify", - CreateNoWindow = true, - RedirectStandardError = true, - RedirectStandardOutput = true - } - }; - - var processConvert = new Process - { - StartInfo = - { - FileName = "convert", - CreateNoWindow = true, - RedirectStandardError = true, - RedirectStandardOutput = true - } - }; - - string identifyOutput; - string convertOutput; - string exiftoolOutput; - - try - { - processIdentify.Start(); - identifyOutput = await processIdentify.StandardOutput.ReadToEndAsync(); - processIdentify.WaitForExit(); - processConvert.Start(); - convertOutput = await processConvert.StandardOutput.ReadToEndAsync(); - processConvert.WaitForExit(); - processExiftool.Start(); - exiftoolOutput = await processExiftool.StandardOutput.ReadToEndAsync(); - processExiftool.WaitForExit(); - } - catch(Exception) - { - _uploadError = true; - _uploadErrorMessage = L["Cannot run ImageMagick please contact the administrator."]; - - return; - } - - IFileReference file = (await FileReaderService.CreateReference(_inputUpload).EnumerateFilesAsync()). - FirstOrDefault(); - - if(file is null) - return; - - IFileInfo fileInfo = await file.ReadFileInfoAsync(); - - if(fileInfo.Size > _maxUploadSize) - { - _uploadError = true; - _uploadErrorMessage = L["The selected file is too big."]; - - return; - } - - string tmpPath = Path.GetTempFileName(); - - FileStream outFs; - - try - { - outFs = new FileStream(tmpPath, FileMode.Open, FileAccess.ReadWrite); - } - catch(Exception) - { - _uploadError = true; - _uploadErrorMessage = L["There was an error uploading the file."]; - - return; - } - - _uploading = true; - - await using AsyncDisposableStream fs = await file.OpenReadAsync(); - byte[] buffer = new byte[20480]; - - try - { - double lastProgress = 0; - int count; - - while((count = await fs.ReadAsync(buffer, 0, buffer.Length)) != 0) - { - await outFs.WriteAsync(buffer, 0, count); - - double progress = (double)fs.Position * 100 / fs.Length; - - if(!(progress > lastProgress + 0.01)) - continue; - - _progressValue = progress; - await InvokeAsync(StateHasChanged); - await Task.Yield(); - lastProgress = progress; - } - } - catch(Exception) - { - _uploading = false; - _uploadError = true; - _uploadErrorMessage = L["There was an error uploading the file."]; - - return; - } - - outFs.Close(); - _uploading = false; - await InvokeAsync(StateHasChanged); - await Task.Yield(); - - processIdentify = new Process - { - StartInfo = - { - FileName = "identify", - CreateNoWindow = true, - RedirectStandardError = true, RedirectStandardOutput = true, ArgumentList = { + "-n", + "-json", tmpPath } } }; - processIdentify.Start(); - identifyOutput = await processIdentify.StandardOutput.ReadToEndAsync(); - processIdentify.WaitForExit(); + processExiftool.Start(); + exiftoolOutput = await processExiftool.StandardOutput.ReadToEndAsync(); + processExiftool.WaitForExit(); - if(processIdentify.ExitCode != 0 || - string.IsNullOrWhiteSpace(identifyOutput)) - { - _uploading = false; - _uploadError = true; - _uploadErrorMessage = L["The uploaded file was not recognized as an image."]; - File.Delete(tmpPath); + Exif[] exif = JsonSerializer.Deserialize(exiftoolOutput); - return; - } + if(exif?.Length >= 1) exif[0].ToViewModel(_selectedScan); - string[] pieces = identifyOutput.Substring(tmpPath.Length). - Split(" ", StringSplitOptions.RemoveEmptyEntries); - - if(pieces.Length < 2) - { - _uploading = false; - _uploadError = true; - _uploadErrorMessage = L["The uploaded file was not recognized as an image."]; - File.Delete(tmpPath); - - return; - } - - // TODO: Move this to Helpers, keep progress - - string extension = ImageMagick.GetExtension(pieces[0]); - - if(string.IsNullOrWhiteSpace(extension)) - { - _uploading = false; - _uploadError = true; - _uploadErrorMessage = L["The uploaded file was not recognized as an image."]; - File.Delete(tmpPath); - - return; - } - - _imageFormat = pieces[0]; - _uploaded = true; - - _selectedScan = new MagazineScanViewModel - { - UserId = (await UserManager.GetUserAsync(_authState.User)).Id, - MagazineId = Id, - Id = Guid.NewGuid(), - OriginalExtension = extension, - UploadDate = DateTime.UtcNow, - Page = _unknownScanPage ? null : _uploadScanPage, - Type = (DocumentScanType)_uploadScanType - }; - - try - { - processExiftool = new Process - { - StartInfo = - { - FileName = "exiftool", - CreateNoWindow = true, - RedirectStandardError = true, - RedirectStandardOutput = true, - ArgumentList = - { - "-n", - "-json", - tmpPath - } - } - }; - - processExiftool.Start(); - exiftoolOutput = await processExiftool.StandardOutput.ReadToEndAsync(); - processExiftool.WaitForExit(); - - Exif[] exif = JsonSerializer.Deserialize(exiftoolOutput); - - if(exif?.Length >= 1) - exif[0].ToViewModel(_selectedScan); - - _extractExif = true; - } - catch(Exception) - { - _extractExif = false; - } - - string originalFilePath = Path.Combine(Host.WebRootPath, "assets", "scans", "magazines", "originals", - $"{_selectedScan.Id}{_selectedScan.OriginalExtension}"); - - try - { - File.Move(tmpPath, originalFilePath); - _moveFile = true; - } - catch(Exception) - { - _moveFile = false; - File.Delete(tmpPath); - - return; - } - - await Task.Yield(); - await InvokeAsync(StateHasChanged); - - var photos = new Photos(); - photos.FinishedAll += OnFinishedAll; - photos.FinishedRenderingJpeg4k += OnFinishedRenderingJpeg4k; - photos.FinishedRenderingJpeg1440 += OnFinishedRenderingJpeg1440; - photos.FinishedRenderingJpegHd += OnFinishedRenderingJpegHd; - photos.FinishedRenderingJpeg4kThumbnail += OnFinishedRenderingJpeg4kThumbnail; - photos.FinishedRenderingJpeg1440Thumbnail += OnFinishedRenderingJpeg1440Thumbnail; - photos.FinishedRenderingJpegHdThumbnail += OnFinishedRenderingJpegHdThumbnail; - photos.FinishedRenderingJp2k4k += OnFinishedRenderingJp2k4k; - photos.FinishedRenderingJp2k1440 += OnFinishedRenderingJp2k1440; - photos.FinishedRenderingJp2kHd += OnFinishedRenderingJp2kHd; - photos.FinishedRenderingJp2k4kThumbnail += OnFinishedRenderingJp2k4kThumbnail; - photos.FinishedRenderingJp2k1440Thumbnail += OnFinishedRenderingJp2k1440Thumbnail; - photos.FinishedRenderingJp2kHdThumbnail += OnFinishedRenderingJp2kHdThumbnail; - photos.FinishedRenderingWebp4k += OnFinishedRenderingWebp4k; - photos.FinishedRenderingWebp1440 += OnFinishedRenderingWebp1440; - photos.FinishedRenderingWebpHd += OnFinishedRenderingWebpHd; - photos.FinishedRenderingWebp4kThumbnail += OnFinishedRenderingWebp4kThumbnail; - photos.FinishedRenderingWebp1440Thumbnail += OnFinishedRenderingWebp1440Thumbnail; - photos.FinishedRenderingWebpHdThumbnail += OnFinishedRenderingWebpHdThumbnail; - photos.FinishedRenderingHeif4k += OnFinishedRenderingHeif4k; - photos.FinishedRenderingHeif1440 += OnFinishedRenderingHeif1440; - photos.FinishedRenderingHeifHd += OnFinishedRenderingHeifHd; - photos.FinishedRenderingHeif4kThumbnail += OnFinishedRenderingHeif4kThumbnail; - photos.FinishedRenderingHeif1440Thumbnail += OnFinishedRenderingHeif1440Thumbnail; - photos.FinishedRenderingHeifHdThumbnail += OnFinishedRenderingHeifHdThumbnail; - photos.FinishedRenderingAvif4k += OnFinishedRenderingAvif4k; - photos.FinishedRenderingAvif1440 += OnFinishedRenderingAvif1440; - photos.FinishedRenderingAvifHd += OnFinishedRenderingAvifHd; - photos.FinishedRenderingAvif4kThumbnail += OnFinishedRenderingAvif4kThumbnail; - photos.FinishedRenderingAvif1440Thumbnail += OnFinishedRenderingAvif1440Thumbnail; - photos.FinishedRenderingAvifHdThumbnail += OnFinishedRenderingAvifHdThumbnail; - - #pragma warning disable 4014 - Task.Run(() => photos.ConversionWorker(Host.WebRootPath, _selectedScan.Id, originalFilePath, _imageFormat, - true, "magazines")); - #pragma warning restore 4014 + _extractExif = true; } - - async Task OnFinishedRenderingJpeg4k(bool result) + catch(Exception) { - _convertJpeg4k = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); + _extractExif = false; } - async Task OnFinishedRenderingJpeg1440(bool result) + string originalFilePath = Path.Combine(Host.WebRootPath, + "assets", + "scans", + "magazines", + "originals", + $"{_selectedScan.Id}{_selectedScan.OriginalExtension}"); + + try { - _convertJpeg1440 = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); + File.Move(tmpPath, originalFilePath); + _moveFile = true; } - - async Task OnFinishedRenderingJpegHd(bool result) + catch(Exception) { - _convertJpegHd = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); + _moveFile = false; + File.Delete(tmpPath); + + return; } - async Task OnFinishedRenderingJpeg4kThumbnail(bool result) + await Task.Yield(); + await InvokeAsync(StateHasChanged); + + var photos = new Photos(); + photos.FinishedAll += OnFinishedAll; + photos.FinishedRenderingJpeg4K += OnFinishedRenderingJpeg4k; + photos.FinishedRenderingJpeg1440 += OnFinishedRenderingJpeg1440; + photos.FinishedRenderingJpegHd += OnFinishedRenderingJpegHd; + photos.FinishedRenderingJpeg4kThumbnail += OnFinishedRenderingJpeg4kThumbnail; + photos.FinishedRenderingJpeg1440Thumbnail += OnFinishedRenderingJpeg1440Thumbnail; + photos.FinishedRenderingJpegHdThumbnail += OnFinishedRenderingJpegHdThumbnail; + photos.FinishedRenderingJp2k4k += OnFinishedRenderingJp2k4k; + photos.FinishedRenderingJp2k1440 += OnFinishedRenderingJp2k1440; + photos.FinishedRenderingJp2kHd += OnFinishedRenderingJp2kHd; + photos.FinishedRenderingJp2k4kThumbnail += OnFinishedRenderingJp2k4kThumbnail; + photos.FinishedRenderingJp2k1440Thumbnail += OnFinishedRenderingJp2k1440Thumbnail; + photos.FinishedRenderingJp2kHdThumbnail += OnFinishedRenderingJp2kHdThumbnail; + photos.FinishedRenderingWebp4k += OnFinishedRenderingWebp4k; + photos.FinishedRenderingWebp1440 += OnFinishedRenderingWebp1440; + photos.FinishedRenderingWebpHd += OnFinishedRenderingWebpHd; + photos.FinishedRenderingWebp4kThumbnail += OnFinishedRenderingWebp4kThumbnail; + photos.FinishedRenderingWebp1440Thumbnail += OnFinishedRenderingWebp1440Thumbnail; + photos.FinishedRenderingWebpHdThumbnail += OnFinishedRenderingWebpHdThumbnail; + photos.FinishedRenderingHeif4K += OnFinishedRenderingHeif4k; + photos.FinishedRenderingHeif1440 += OnFinishedRenderingHeif1440; + photos.FinishedRenderingHeifHd += OnFinishedRenderingHeifHd; + photos.FinishedRenderingHeif4kThumbnail += OnFinishedRenderingHeif4kThumbnail; + photos.FinishedRenderingHeif1440Thumbnail += OnFinishedRenderingHeif1440Thumbnail; + photos.FinishedRenderingHeifHdThumbnail += OnFinishedRenderingHeifHdThumbnail; + photos.FinishedRenderingAvif4K += OnFinishedRenderingAvif4k; + photos.FinishedRenderingAvif1440 += OnFinishedRenderingAvif1440; + photos.FinishedRenderingAvifHd += OnFinishedRenderingAvifHd; + photos.FinishedRenderingAvif4kThumbnail += OnFinishedRenderingAvif4kThumbnail; + photos.FinishedRenderingAvif1440Thumbnail += OnFinishedRenderingAvif1440Thumbnail; + photos.FinishedRenderingAvifHdThumbnail += OnFinishedRenderingAvifHdThumbnail; + +#pragma warning disable 4014 + Task.Run(() => photos.ConversionWorker(Host.WebRootPath, + _selectedScan.Id, + originalFilePath, + _imageFormat, + true, + "magazines")); +#pragma warning restore 4014 + } + + async Task OnFinishedRenderingJpeg4k(bool result) + { + _convertJpeg4k = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJpeg1440(bool result) + { + _convertJpeg1440 = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJpegHd(bool result) + { + _convertJpegHd = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJpeg4kThumbnail(bool result) + { + _convertJpeg4kTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJpeg1440Thumbnail(bool result) + { + _convertJpeg1440Th = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJpegHdThumbnail(bool result) + { + _convertJpegHdTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJp2k4k(bool result) + { + _convertJp2k4k = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJp2k1440(bool result) + { + _convertJp2k1440 = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJp2kHd(bool result) + { + _convertJp2kHd = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJp2k4kThumbnail(bool result) + { + _convertJp2k4kTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJp2k1440Thumbnail(bool result) + { + _convertJp2k1440Th = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingJp2kHdThumbnail(bool result) + { + _convertJp2kHdTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingWebp4k(bool result) + { + _convertWebp4k = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingWebp1440(bool result) + { + _convertWebp1440 = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingWebpHd(bool result) + { + _convertWebpHd = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingWebp4kThumbnail(bool result) + { + _convertWebp4kTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingWebp1440Thumbnail(bool result) + { + _convertWebp1440Th = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingWebpHdThumbnail(bool result) + { + _convertWebpHdTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingHeif4k(bool result) + { + _convertHeif4K = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingHeif1440(bool result) + { + _convertHeif1440 = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingHeifHd(bool result) + { + _convertHeifHd = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingHeif4kThumbnail(bool result) + { + _convertHeif4kTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingHeif1440Thumbnail(bool result) + { + _convertHeif1440Th = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingHeifHdThumbnail(bool result) + { + _convertHeifHdTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingAvif4k(bool result) + { + _convertAvif4K = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingAvif1440(bool result) + { + _convertAvif1440 = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingAvifHd(bool result) + { + _convertAvifHd = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingAvif4kThumbnail(bool result) + { + _convertAvif4kTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingAvif1440Thumbnail(bool result) + { + _convertAvif1440Th = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedRenderingAvifHdThumbnail(bool result) + { + _convertAvifHdTh = result; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task OnFinishedAll(bool result) + { + try { - _convertJpeg4kTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } + await MagazineScansService.CreateAsync(_selectedScan, (await UserManager.GetUserAsync(_authState.User)).Id); - async Task OnFinishedRenderingJpeg1440Thumbnail(bool result) + _addToDatabase = true; + } + catch(Exception e) { - _convertJpeg1440Th = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); + _addToDatabase = false; + Console.WriteLine(e); + + throw; } - async Task OnFinishedRenderingJpegHdThumbnail(bool result) - { - _convertJpegHdTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingJp2k4k(bool result) - { - _convertJp2k4k = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingJp2k1440(bool result) - { - _convertJp2k1440 = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingJp2kHd(bool result) - { - _convertJp2kHd = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingJp2k4kThumbnail(bool result) - { - _convertJp2k4kTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingJp2k1440Thumbnail(bool result) - { - _convertJp2k1440Th = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingJp2kHdThumbnail(bool result) - { - _convertJp2kHdTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingWebp4k(bool result) - { - _convertWebp4k = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingWebp1440(bool result) - { - _convertWebp1440 = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingWebpHd(bool result) - { - _convertWebpHd = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingWebp4kThumbnail(bool result) - { - _convertWebp4kTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingWebp1440Thumbnail(bool result) - { - _convertWebp1440Th = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingWebpHdThumbnail(bool result) - { - _convertWebpHdTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingHeif4k(bool result) - { - _convertHeif4k = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingHeif1440(bool result) - { - _convertHeif1440 = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingHeifHd(bool result) - { - _convertHeifHd = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingHeif4kThumbnail(bool result) - { - _convertHeif4kTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingHeif1440Thumbnail(bool result) - { - _convertHeif1440Th = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingHeifHdThumbnail(bool result) - { - _convertHeifHdTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingAvif4k(bool result) - { - _convertAvif4k = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingAvif1440(bool result) - { - _convertAvif1440 = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingAvifHd(bool result) - { - _convertAvifHd = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingAvif4kThumbnail(bool result) - { - _convertAvif4kTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingAvif1440Thumbnail(bool result) - { - _convertAvif1440Th = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedRenderingAvifHdThumbnail(bool result) - { - _convertAvifHdTh = result; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task OnFinishedAll(bool result) - { - try - { - await MagazineScansService.CreateAsync(_selectedScan, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _addToDatabase = true; - } - catch(Exception e) - { - _addToDatabase = false; - Console.WriteLine(e); - - throw; - } - - _allFinished = true; - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task AddScan() - { - _editing = false; - _editingScan = false; - _addingScan = true; - - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task EditScan(Guid scanId) - { - _selectedScan = await MagazineScansService.GetAsync(scanId); - - if(_selectedScan is null) - return; - - _scanUser = await UserManager.FindByIdAsync(_selectedScan.UserId); - _unknownScanAuthor = string.IsNullOrWhiteSpace(_selectedScan.Author); - _unknownScanScannerManufacturer = string.IsNullOrWhiteSpace(_selectedScan.ScannerModel); - _unknownScanScannerModel = string.IsNullOrWhiteSpace(_selectedScan.ScannerModel); - _unknownScanColorSpace = !_selectedScan.ColorSpace.HasValue; - _unknownScanCreationDate = !_selectedScan.CreationDate.HasValue; - _unknownScanExifVersion = string.IsNullOrWhiteSpace(_selectedScan.ExifVersion); - _unknownScanHorizontalResolution = !_selectedScan.HorizontalResolution.HasValue; - _unknownScanResolutionUnit = !_selectedScan.ResolutionUnit.HasValue; - _unknownScanSoftwareUsed = string.IsNullOrWhiteSpace(_selectedScan.SoftwareUsed); - _unknownScanVerticalResolution = !_selectedScan.VerticalResolution.HasValue; - _unknownScanComments = string.IsNullOrWhiteSpace(_selectedScan.Comments); - _unknownScanPage = !_selectedScan.Page.HasValue; - - _editing = false; - _editingScan = true; - _addingScan = false; - - await Task.Yield(); - await InvokeAsync(StateHasChanged); - } - - async Task ShowScanDeleteModal(Guid scanId) - { - _selectedScan = await MagazineScansService.GetAsync(scanId); - - if(_selectedScan is null) - return; - - _deletingScan = true; - _deleteTitle = L["Delete scan from this magazine"]; - - _deleteText = _selectedScan.Page.HasValue - ? string. - Format(L["Are you sure you want to delete the scan type {0} for page {1} from this magazine?"], - _selectedScan.Type, _selectedScan.Page) - : string. - Format(L["Are you sure you want to delete the scan type {0} from this magazine?"], - _selectedScan.Type); - - _frmDelete.Show(); - } - - async Task ConfirmDeleteScan() - { - if(_selectedScan is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - // TODO: Delete files - await MagazineScansService.DeleteAsync(_selectedScan.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _scans = await MagazineScansService.GetGuidsByMagazineAsync(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void OnCancelScanClicked() - { - _scanUser = null; - _unknownScanAuthor = true; - _unknownScanScannerManufacturer = true; - _unknownScanScannerModel = true; - _unknownScanColorSpace = true; - _unknownScanCreationDate = true; - _unknownScanExifVersion = true; - _unknownScanHorizontalResolution = true; - _unknownScanResolutionUnit = true; - _unknownScanSoftwareUsed = true; - _unknownScanVerticalResolution = true; - _unknownScanComments = true; - _unknownScanPage = true; - _selectedScan = null; - - _editing = false; - _editingScan = false; - _addingScan = false; - - StateHasChanged(); - } - - async void OnSaveScanClicked() - { - if(_unknownScanAuthor) - _selectedScan.Author = null; - else if(string.IsNullOrWhiteSpace(_selectedScan.Author)) - return; - - if(_unknownScanScannerManufacturer) - _selectedScan.ScannerModel = null; - else if(string.IsNullOrWhiteSpace(_selectedScan.ScannerModel)) - return; - - if(_unknownScanScannerModel) - _selectedScan.ScannerManufacturer = null; - else if(string.IsNullOrWhiteSpace(_selectedScan.ScannerManufacturer)) - return; - - if(_unknownScanColorSpace) - _selectedScan.ColorSpace = null; - else if(!_selectedScan.ColorSpace.HasValue) - return; - - if(_unknownScanCreationDate) - _selectedScan.CreationDate = null; - else if(_selectedScan.CreationDate > DateTime.UtcNow) - return; - - if(_unknownScanExifVersion) - _selectedScan.ExifVersion = null; - else if(string.IsNullOrWhiteSpace(_selectedScan.ExifVersion)) - return; - - if(_unknownScanHorizontalResolution) - _selectedScan.HorizontalResolution = null; - else if(!_selectedScan.HorizontalResolution.HasValue) - return; - - if(_unknownScanResolutionUnit) - _selectedScan.ResolutionUnit = null; - else if(!_selectedScan.ResolutionUnit.HasValue) - return; - - if(_unknownScanSoftwareUsed) - _selectedScan.SoftwareUsed = null; - else if(string.IsNullOrWhiteSpace(_selectedScan.SoftwareUsed)) - return; - - if(_unknownScanVerticalResolution) - _selectedScan.VerticalResolution = null; - else if(!_selectedScan.VerticalResolution.HasValue) - return; - - if(_unknownScanComments) - _selectedScan.Comments = null; - else if(string.IsNullOrWhiteSpace(_selectedScan.Comments)) - return; - - if(_unknownScanPage) - _selectedScan.Page = null; - else if(!_selectedScan.Page.HasValue || - _selectedScan.Page == 0) - return; - - await MagazineScansService.UpdateAsync(_selectedScan, (await UserManager.GetUserAsync(_authState.User)).Id); - - OnCancelScanClicked(); - StateHasChanged(); - } + _allFinished = true; + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task AddScan() + { + _editing = false; + _editingScan = false; + _addingScan = true; + + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task EditScan(Guid scanId) + { + _selectedScan = await MagazineScansService.GetAsync(scanId); + + if(_selectedScan is null) return; + + _scanUser = await UserManager.FindByIdAsync(_selectedScan.UserId); + _unknownScanAuthor = string.IsNullOrWhiteSpace(_selectedScan.Author); + _unknownScanScannerManufacturer = string.IsNullOrWhiteSpace(_selectedScan.ScannerModel); + _unknownScanScannerModel = string.IsNullOrWhiteSpace(_selectedScan.ScannerModel); + _unknownScanColorSpace = !_selectedScan.ColorSpace.HasValue; + _unknownScanCreationDate = !_selectedScan.CreationDate.HasValue; + _unknownScanExifVersion = string.IsNullOrWhiteSpace(_selectedScan.ExifVersion); + _unknownScanHorizontalResolution = !_selectedScan.HorizontalResolution.HasValue; + _unknownScanResolutionUnit = !_selectedScan.ResolutionUnit.HasValue; + _unknownScanSoftwareUsed = string.IsNullOrWhiteSpace(_selectedScan.SoftwareUsed); + _unknownScanVerticalResolution = !_selectedScan.VerticalResolution.HasValue; + _unknownScanComments = string.IsNullOrWhiteSpace(_selectedScan.Comments); + _unknownScanPage = !_selectedScan.Page.HasValue; + + _editing = false; + _editingScan = true; + _addingScan = false; + + await Task.Yield(); + await InvokeAsync(StateHasChanged); + } + + async Task ShowScanDeleteModal(Guid scanId) + { + _selectedScan = await MagazineScansService.GetAsync(scanId); + + if(_selectedScan is null) return; + + _deletingScan = true; + _deleteTitle = L["Delete scan from this magazine"]; + + _deleteText = _selectedScan.Page.HasValue + ? string.Format(L["Are you sure you want to delete the scan type {0} for page {1} from this magazine?"], + _selectedScan.Type, + _selectedScan.Page) + : string.Format(L["Are you sure you want to delete the scan type {0} from this magazine?"], + _selectedScan.Type); + + _frmDelete.Show(); + } + + async Task ConfirmDeleteScan() + { + if(_selectedScan is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + // TODO: Delete files + await MagazineScansService.DeleteAsync(_selectedScan.Id, (await UserManager.GetUserAsync(_authState.User)).Id); + + _scans = await MagazineScansService.GetGuidsByMagazineAsync(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void OnCancelScanClicked() + { + _scanUser = null; + _unknownScanAuthor = true; + _unknownScanScannerManufacturer = true; + _unknownScanScannerModel = true; + _unknownScanColorSpace = true; + _unknownScanCreationDate = true; + _unknownScanExifVersion = true; + _unknownScanHorizontalResolution = true; + _unknownScanResolutionUnit = true; + _unknownScanSoftwareUsed = true; + _unknownScanVerticalResolution = true; + _unknownScanComments = true; + _unknownScanPage = true; + _selectedScan = null; + + _editing = false; + _editingScan = false; + _addingScan = false; + + StateHasChanged(); + } + + async void OnSaveScanClicked() + { + if(_unknownScanAuthor) + _selectedScan.Author = null; + else if(string.IsNullOrWhiteSpace(_selectedScan.Author)) return; + + if(_unknownScanScannerManufacturer) + _selectedScan.ScannerModel = null; + else if(string.IsNullOrWhiteSpace(_selectedScan.ScannerModel)) return; + + if(_unknownScanScannerModel) + _selectedScan.ScannerManufacturer = null; + else if(string.IsNullOrWhiteSpace(_selectedScan.ScannerManufacturer)) return; + + if(_unknownScanColorSpace) + _selectedScan.ColorSpace = null; + else if(!_selectedScan.ColorSpace.HasValue) return; + + if(_unknownScanCreationDate) + _selectedScan.CreationDate = null; + else if(_selectedScan.CreationDate > DateTime.UtcNow) return; + + if(_unknownScanExifVersion) + _selectedScan.ExifVersion = null; + else if(string.IsNullOrWhiteSpace(_selectedScan.ExifVersion)) return; + + if(_unknownScanHorizontalResolution) + _selectedScan.HorizontalResolution = null; + else if(!_selectedScan.HorizontalResolution.HasValue) return; + + if(_unknownScanResolutionUnit) + _selectedScan.ResolutionUnit = null; + else if(!_selectedScan.ResolutionUnit.HasValue) return; + + if(_unknownScanSoftwareUsed) + _selectedScan.SoftwareUsed = null; + else if(string.IsNullOrWhiteSpace(_selectedScan.SoftwareUsed)) return; + + if(_unknownScanVerticalResolution) + _selectedScan.VerticalResolution = null; + else if(!_selectedScan.VerticalResolution.HasValue) return; + + if(_unknownScanComments) + _selectedScan.Comments = null; + else if(string.IsNullOrWhiteSpace(_selectedScan.Comments)) return; + + if(_unknownScanPage) + _selectedScan.Page = null; + else if(!_selectedScan.Page.HasValue || _selectedScan.Page == 0) return; + + await MagazineScansService.UpdateAsync(_selectedScan, (await UserManager.GetUserAsync(_authState.User)).Id); + + OnCancelScanClicked(); + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Person.razor b/Marechai/Pages/Admin/Details/Person.razor index 28f86983..667090fe 100644 --- a/Marechai/Pages/Admin/Details/Person.razor +++ b/Marechai/Pages/Admin/Details/Person.razor @@ -31,13 +31,13 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject Iso31661NumericService CountriesService -@inject NavigationManager NavigationManager -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject Iso31661NumericService CountriesService +@inject NavigationManager NavigationManager +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Person details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -52,9 +52,8 @@ @if(_editing) { @L["Unknown (name)"] -} - @if(!_editing || - !_unknownName) + } + @if(!_editing || !_unknownName) { @@ -63,9 +62,9 @@ -} + } -} + } @if(_editing || _model.Surname != null) { @@ -73,9 +72,8 @@ @if(_editing) { @L["Unknown (surname)"] -} - @if(!_editing || - !_unknownSurname) + } + @if(!_editing || !_unknownSurname) { @@ -84,9 +82,9 @@ -} + } -} + } @if(_editing || _model.Alias != null) { @@ -94,9 +92,8 @@ @if(_editing) { @L["Unknown (alias)"] -} - @if(!_editing || - !_unknownAlias) + } + @if(!_editing || !_unknownAlias) { @@ -105,9 +102,9 @@ -} + } -} + } @if(_editing || _model.DisplayName != null) { @@ -115,9 +112,8 @@ @if(_editing) { @L["Unknown (display name)"] -} - @if(!_editing || - !_unknownDisplayName) + } + @if(!_editing || !_unknownDisplayName) { @@ -126,9 +122,9 @@ -} + } -} + } @if(_editing || _model.CountryOfBirthId != null) { @@ -136,19 +132,18 @@ @if(_editing) { @L["Unknown (country of birth)"] -} - @if(!_editing || - !_unknownCountry) + } + @if(!_editing || !_unknownCountry) { -} + } -} + } @L["Birth date"] @@ -166,9 +161,8 @@ @if(_editing) { @L["Unknown (death date)"] -} - @if(!_editing || - !_unknownDeathDate) + } + @if(!_editing || !_unknownDeathDate) { @@ -177,9 +171,9 @@ -} + } -} + } @if(_editing || _model.Webpage != null) { @@ -187,9 +181,8 @@ @if(_editing) { @L["Unknown (webpage)"] -} - @if(!_editing || - !_unknownWebpage) + } + @if(!_editing || !_unknownWebpage) { @@ -198,9 +191,9 @@ -} + } -} + } @if(_editing || _model.Twitter != null) { @@ -208,9 +201,8 @@ @if(_editing) { @L["Unknown (twitter)"] -} - @if(!_editing || - !_unknownTwitter) + } + @if(!_editing || !_unknownTwitter) { @@ -219,9 +211,9 @@ -} + } -} + } @if(_editing || _model.Facebook != null) { @@ -229,9 +221,8 @@ @if(_editing) { @L["Unknown (facebook)"] -} - @if(!_editing || - !_unknownFacebook) + } + @if(!_editing || !_unknownFacebook) { @@ -240,19 +231,20 @@ -} + } -} + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Person.razor.cs b/Marechai/Pages/Admin/Details/Person.razor.cs index aefbde69..fba82168 100644 --- a/Marechai/Pages/Admin/Details/Person.razor.cs +++ b/Marechai/Pages/Admin/Details/Person.razor.cs @@ -33,310 +33,279 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class Person { - public partial class Person + AuthenticationState _authState; + List _countries; + bool _creating; + bool _editing; + bool _loaded; + PersonViewModel _model; + bool _unknownAlias; + bool _unknownCountry; + bool _unknownDeathDate; + bool _unknownDisplayName; + bool _unknownFacebook; + bool _unknownName; + bool _unknownSurname; + bool _unknownTwitter; + bool _unknownWebpage; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - AuthenticationState _authState; - List _countries; - bool _creating; - bool _editing; - bool _loaded; - PersonViewModel _model; - bool _unknownAlias; - bool _unknownCountry; - bool _unknownDeathDate; - bool _unknownDisplayName; - bool _unknownFacebook; - bool _unknownName; - bool _unknownSurname; - bool _unknownTwitter; - bool _unknownWebpage; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; + _loaded = true; - _loaded = true; + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/people/create", StringComparison.InvariantCulture); - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/people/create", StringComparison.InvariantCulture); + if(Id <= 0 && !_creating) return; - if(Id <= 0 && - !_creating) - return; + _countries = await CountriesService.GetAsync(); + _model = _creating ? new PersonViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _countries = await CountriesService.GetAsync(); - _model = _creating ? new PersonViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/people/edit/", StringComparison.InvariantCulture); - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/people/edit/", - StringComparison.InvariantCulture); + if(_editing) SetCheckboxes(); - if(_editing) - SetCheckboxes(); - - StateHasChanged(); - } - - void SetCheckboxes() - { - _unknownAlias = string.IsNullOrWhiteSpace(_model.Alias); - _unknownCountry = !_model.CountryOfBirthId.HasValue; - _unknownDeathDate = !_model.DeathDate.HasValue; - _unknownDisplayName = string.IsNullOrWhiteSpace(_model.DisplayName); - _unknownFacebook = string.IsNullOrWhiteSpace(_model.Facebook); - _unknownName = string.IsNullOrWhiteSpace(_model.Name); - _unknownSurname = string.IsNullOrWhiteSpace(_model.Surname); - _unknownTwitter = string.IsNullOrWhiteSpace(_model.Twitter); - _unknownWebpage = string.IsNullOrWhiteSpace(_model.Webpage); - } - - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } - - async void OnCancelClicked() - { - _editing = false; - - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/people"); - - return; - } - - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - async void OnSaveClicked() - { - if(_unknownAlias) - _model.Alias = null; - else if(string.IsNullOrWhiteSpace(_model.Alias)) - return; - - if(_unknownCountry) - _model.CountryOfBirthId = null; - else if(_model.CountryOfBirthId < 0) - return; - - if(_model.BirthDate.Date >= DateTime.UtcNow.Date) - return; - - if(_unknownDeathDate) - _model.DeathDate = null; - else if(_model.DeathDate?.Date >= DateTime.UtcNow.Date) - return; - else if(_model.DeathDate?.Date <= _model.BirthDate.Date) - return; - - if(_unknownAlias) - _model.Alias = null; - else if(string.IsNullOrWhiteSpace(_model.Alias)) - return; - - if(_unknownDisplayName) - _model.DisplayName = null; - else if(string.IsNullOrWhiteSpace(_model.DisplayName)) - return; - - if(_unknownFacebook) - _model.Facebook = null; - else if(string.IsNullOrWhiteSpace(_model.Facebook)) - return; - - if(_unknownName) - _model.Name = null; - else if(string.IsNullOrWhiteSpace(_model.Name)) - return; - - if(_unknownSurname) - _model.Surname = null; - else if(string.IsNullOrWhiteSpace(_model.Surname)) - return; - - if(_unknownTwitter) - _model.Twitter = null; - else if(string.IsNullOrWhiteSpace(_model.Twitter)) - return; - - if(_unknownWebpage) - _model.Webpage = null; - else if(string.IsNullOrWhiteSpace(_model.Webpage)) - return; - - if((_unknownName && !_unknownSurname) || - (!_unknownName && _unknownSurname)) - return; - - // TODO: Show error here - if(_unknownName && - _unknownSurname && - _unknownAlias && - _unknownDisplayName) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateName(ValidatorEventArgs e) - { - if(!(e.Value is string name)) - { - e.Status = ValidationStatus.Error; - - return; - } - - if(name.Length < 1 || - name.Length > 256) - { - e.ErrorText = L["Name must be smaller than 256 characters."]; - e.Status = ValidationStatus.Error; - - return; - } - - if(!string.IsNullOrWhiteSpace(_model.Surname) && - !_unknownSurname) - return; - - e.ErrorText = L["Both name and surname must be known and filled, or both unknown."]; - e.Status = ValidationStatus.Error; - } - - void ValidateSurname(ValidatorEventArgs e) - { - if(!(e.Value is string surname)) - { - e.Status = ValidationStatus.Error; - - return; - } - - if(surname.Length < 1 || - surname.Length > 256) - { - e.ErrorText = L["Surname must be smaller than 256 characters."]; - e.Status = ValidationStatus.Error; - - return; - } - - if(!string.IsNullOrWhiteSpace(_model.Surname) && - !_unknownSurname) - return; - - e.ErrorText = L["Both name and surname must be known and filled, or both unknown."]; - e.Status = ValidationStatus.Error; - } - - void ValidateAlias(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Alias must be smaller than 256 characters."], 256); - - void ValidateDisplayName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Display name must be smaller than 256 characters."], 256); - - void ValidateBirthDate(ValidatorEventArgs e) - { - if(!(e.Value is DateTime date)) - { - e.Status = ValidationStatus.Error; - - return; - } - - if(date.Date >= DateTime.UtcNow.Date) - { - e.ErrorText = L["Birth date must be before today."]; - e.Status = ValidationStatus.Error; - - return; - } - - if(_unknownDeathDate || !_model.DeathDate.HasValue) - return; - - if(date.Date < _model.DeathDate?.Date) - return; - - e.ErrorText = L["Birth date must be before death date."]; - e.Status = ValidationStatus.Error; - } - - void ValidateDeathDate(ValidatorEventArgs e) - { - if(!(e.Value is DateTime date)) - { - e.Status = ValidationStatus.Error; - - return; - } - - if(date.Date >= DateTime.UtcNow.Date) - { - e.ErrorText = L["Death date must be before today."]; - e.Status = ValidationStatus.Error; - - return; - } - - if(date.Date > _model.BirthDate.Date) - return; - - e.ErrorText = L["Death date must be after birth date."]; - e.Status = ValidationStatus.Error; - } - - void ValidateWebpage(ValidatorEventArgs e) => - Validators.ValidateUrl(e, L["Webpage must be smaller than 255 characters."], 255); - - void ValidateTwitter(ValidatorEventArgs e) - { - if(!(e.Value is string twitter)) - { - e.Status = ValidationStatus.Error; - - return; - } - - if(twitter.Length < 1 || - twitter.Length > 255) - { - e.ErrorText = L["Twitter handle must be smaller than 255 characters."]; - e.Status = ValidationStatus.Error; - - return; - } - - if(twitter[0] == '@') - return; - - e.ErrorText = L["Invalid Twitter handle."]; - e.Status = ValidationStatus.Error; - } - - void ValidateFacebook(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Facebook username must be smaller than 256 characters."], 256); + StateHasChanged(); } + + void SetCheckboxes() + { + _unknownAlias = string.IsNullOrWhiteSpace(_model.Alias); + _unknownCountry = !_model.CountryOfBirthId.HasValue; + _unknownDeathDate = !_model.DeathDate.HasValue; + _unknownDisplayName = string.IsNullOrWhiteSpace(_model.DisplayName); + _unknownFacebook = string.IsNullOrWhiteSpace(_model.Facebook); + _unknownName = string.IsNullOrWhiteSpace(_model.Name); + _unknownSurname = string.IsNullOrWhiteSpace(_model.Surname); + _unknownTwitter = string.IsNullOrWhiteSpace(_model.Twitter); + _unknownWebpage = string.IsNullOrWhiteSpace(_model.Webpage); + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) + { + NavigationManager.ToBaseRelativePath("admin/people"); + + return; + } + + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownAlias) + _model.Alias = null; + else if(string.IsNullOrWhiteSpace(_model.Alias)) return; + + if(_unknownCountry) + _model.CountryOfBirthId = null; + else if(_model.CountryOfBirthId < 0) return; + + if(_model.BirthDate.Date >= DateTime.UtcNow.Date) return; + + if(_unknownDeathDate) + _model.DeathDate = null; + else if(_model.DeathDate?.Date >= DateTime.UtcNow.Date) + return; + else if(_model.DeathDate?.Date <= _model.BirthDate.Date) return; + + if(_unknownAlias) + _model.Alias = null; + else if(string.IsNullOrWhiteSpace(_model.Alias)) return; + + if(_unknownDisplayName) + _model.DisplayName = null; + else if(string.IsNullOrWhiteSpace(_model.DisplayName)) return; + + if(_unknownFacebook) + _model.Facebook = null; + else if(string.IsNullOrWhiteSpace(_model.Facebook)) return; + + if(_unknownName) + _model.Name = null; + else if(string.IsNullOrWhiteSpace(_model.Name)) return; + + if(_unknownSurname) + _model.Surname = null; + else if(string.IsNullOrWhiteSpace(_model.Surname)) return; + + if(_unknownTwitter) + _model.Twitter = null; + else if(string.IsNullOrWhiteSpace(_model.Twitter)) return; + + if(_unknownWebpage) + _model.Webpage = null; + else if(string.IsNullOrWhiteSpace(_model.Webpage)) return; + + if(_unknownName && !_unknownSurname || !_unknownName && _unknownSurname) return; + + // TODO: Show error here + if(_unknownName && _unknownSurname && _unknownAlias && _unknownDisplayName) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) + { + if(!(e.Value is string name)) + { + e.Status = ValidationStatus.Error; + + return; + } + + if(name.Length < 1 || name.Length > 256) + { + e.ErrorText = L["Name must be smaller than 256 characters."]; + e.Status = ValidationStatus.Error; + + return; + } + + if(!string.IsNullOrWhiteSpace(_model.Surname) && !_unknownSurname) return; + + e.ErrorText = L["Both name and surname must be known and filled, or both unknown."]; + e.Status = ValidationStatus.Error; + } + + void ValidateSurname(ValidatorEventArgs e) + { + if(!(e.Value is string surname)) + { + e.Status = ValidationStatus.Error; + + return; + } + + if(surname.Length < 1 || surname.Length > 256) + { + e.ErrorText = L["Surname must be smaller than 256 characters."]; + e.Status = ValidationStatus.Error; + + return; + } + + if(!string.IsNullOrWhiteSpace(_model.Surname) && !_unknownSurname) return; + + e.ErrorText = L["Both name and surname must be known and filled, or both unknown."]; + e.Status = ValidationStatus.Error; + } + + void ValidateAlias(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Alias must be smaller than 256 characters."], 256); + + void ValidateDisplayName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Display name must be smaller than 256 characters."], 256); + + void ValidateBirthDate(ValidatorEventArgs e) + { + if(!(e.Value is DateTime date)) + { + e.Status = ValidationStatus.Error; + + return; + } + + if(date.Date >= DateTime.UtcNow.Date) + { + e.ErrorText = L["Birth date must be before today."]; + e.Status = ValidationStatus.Error; + + return; + } + + if(_unknownDeathDate || !_model.DeathDate.HasValue) return; + + if(date.Date < _model.DeathDate?.Date) return; + + e.ErrorText = L["Birth date must be before death date."]; + e.Status = ValidationStatus.Error; + } + + void ValidateDeathDate(ValidatorEventArgs e) + { + if(!(e.Value is DateTime date)) + { + e.Status = ValidationStatus.Error; + + return; + } + + if(date.Date >= DateTime.UtcNow.Date) + { + e.ErrorText = L["Death date must be before today."]; + e.Status = ValidationStatus.Error; + + return; + } + + if(date.Date > _model.BirthDate.Date) return; + + e.ErrorText = L["Death date must be after birth date."]; + e.Status = ValidationStatus.Error; + } + + void ValidateWebpage(ValidatorEventArgs e) => + Validators.ValidateUrl(e, L["Webpage must be smaller than 255 characters."], 255); + + void ValidateTwitter(ValidatorEventArgs e) + { + if(!(e.Value is string twitter)) + { + e.Status = ValidationStatus.Error; + + return; + } + + if(twitter.Length < 1 || twitter.Length > 255) + { + e.ErrorText = L["Twitter handle must be smaller than 255 characters."]; + e.Status = ValidationStatus.Error; + + return; + } + + if(twitter[0] == '@') return; + + e.ErrorText = L["Invalid Twitter handle."]; + e.Status = ValidationStatus.Error; + } + + void ValidateFacebook(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Facebook username must be smaller than 256 characters."], 256); } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Processor.razor b/Marechai/Pages/Admin/Details/Processor.razor index 0e054226..b8624552 100644 --- a/Marechai/Pages/Admin/Details/Processor.razor +++ b/Marechai/Pages/Admin/Details/Processor.razor @@ -30,17 +30,17 @@ @page "/admin/processors/create" @using Marechai.Database.Models @inherits OwningComponentBase -@inject IStringLocalizer L -@inject CompaniesService CompaniesService -@inject InstructionSetsService InstructionSetsService -@inject NavigationManager NavigationManager +@inject IStringLocalizer L +@inject CompaniesService CompaniesService +@inject InstructionSetsService InstructionSetsService +@inject NavigationManager NavigationManager @inject InstructionSetExtensionsByProcessorService InstructionSetExtensionsByProcessorService -@inject InstructionSetExtensionsService InstructionSetExtensionsService -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject InstructionSetExtensionsService InstructionSetExtensionsService +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Processor details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -48,540 +48,552 @@ return; }
-@if(_editing || _model.CompanyId != null) -{ + @if(_editing || _model.CompanyId != null) + { + + @L["Company"] + @if(_editing) + { + @L["Unknown (company)"] + } + @if(!_editing || !_unknownCompany) + { + + } + + } - @L["Company"] - @if(_editing) - { - @L["Unknown (company)"] -} - @if(!_editing || - !_unknownCompany) - { - -} - } - - @L["Name"] - - - - @L["Please enter a valid name."] - - - - -@if(_editing || _model.ModelCode != null) -{ - - @L["Model code"] - @if(_editing) - { - @L["Unknown (model code)"] -} - @if(!_editing || - !_unknownModelCode) - { - - - - @L["Please enter a valid model code."] - - - -} - } -@if(_editing || _model.Introduced.HasValue) -{ - - @L["Introduced"] - @if(_editing) - { - @L["Unknown (introduction date)"] - @L["Prototype"] -} - @if(!_editing || - !_prototype && !_unknownIntroduced) - { - - - - @L["Please enter an introduction date."] - - - -} - } -@if(_editing || _model.InstructionSetId != null) -{ - - @L["Instruction set"] - @if(_editing) - { - @L["Unknown (instruction set)"] -} - @if(!_editing || - !_unknownInstructionSet) - { - -} - } -@if(_editing || _model.Speed.HasValue) -{ - - @L["Nominal speed (MHz)"] - @if(_editing) - { - @L["Unknown (nominal speed)"] -} - @if(!_editing || - !_unknownSpeed) - { - - - - @L["Please enter a valid nominal speed."] - - - -} - } -@if(_editing || _model.Package != null) -{ - - @L["Package"] - @if(_editing) - { - @L["Unknown (package)"] -} - @if(!_editing || - !_unknownPackage) - { - - - - @L["Please enter a valid package."] - - - -} - } -@if(_editing || _model.Gprs.HasValue) -{ - - @L["General Purpose Registers"] - @if(_editing) - { - @L["Unknown (general purpose registers)"] -} - @if(!_editing || - !_unknownGprs) - { - - - - @L["Please enter a valid number of general purpose registers."] - - - -} - } -@if(_editing || _model.GprSize.HasValue) -{ - - @L["General Purpose Register size"] - @if(_editing) - { - @L["Unknown (general purpose register size)"] -} - @if(!_editing || - !_unknownGprSize) - { - - - - @L["Please enter a valid general purpose register size."] - - - -} - } -@if(_editing || _model.Fprs.HasValue) -{ - - @L["Floating Point Registers"] - @if(_editing) - { - @L["Unknown (floating point registers)"] -} - @if(!_editing || - !_unknownFprs) - { - - - - @L["Please enter a valid number of floating point registers."] - - - -} - @if(_editing) - { - @L["If set to zero, but with a size, indicates floating point instructions use the general purpose registers."] -} - } -@if(_editing || _model.FprSize.HasValue) -{ - - @L["Floating Point Register size"] - @if(_editing) - { - @L["Unknown (floating point register size)"] -} - @if(!_editing || - !_unknownFprSize) - { - - - - @L["Please enter a valid floating point register size."] - - - -} - } -@if(_editing || _model.SimdRegisters.HasValue) -{ - - @L["SIMD Registers"] - @if(_editing) - { - @L["Unknown (simd registers)"] -} - @if(!_editing || - !_unknownSimdRegisters) - { - - - - @L["Please enter a valid number of SIMD registers."] - - - -} - @if(_editing) - { - @L["If set to zero, but with a size, indicates SIMD instructions use the floating point registers. If they are also set to zero with a size, it means SIMD instructions use the general purpose registers."] -} - } -@if(_editing || _model.SimdSize.HasValue) -{ - - @L["SIMD Register size"] - @if(_editing) - { - @L["Unknown (simd register size)"] -} - @if(!_editing || - !_unknownSimdSize) - { - - - - @L["Please enter a valid SIMD register size."] - - - -} - } -@if(_editing || _model.Cores.HasValue) -{ - - @L["Cores"] - @if(_editing) - { - @L["Unknown (cores)"] -} - @if(!_editing || - !_unknownCores) - { - - - - @L["Please enter a valid number of cores."] - - - -} - } -@if(_editing || _model.ThreadsPerCore.HasValue) -{ - - @L["Threads per core"] - @if(_editing) - { - @L["Unknown (threads per core)"] -} - @if(!_editing || - !_unknownThreadsPerCore) - { - - - - @L["Please enter a valid number of threads per core."] - - - -} - } -@if(_editing || _model.Process != null) -{ - - @L["Process"] - @if(_editing) - { - @L["Unknown (process)"] -} - @if(!_editing || - !_unknownProcess) - { - - - - @L["Please enter a valid process."] - - - -} - } -@if(_editing || _model.ProcessNm.HasValue) -{ - - @L["Process (nm)"] - @if(_editing) - { - @L["Unknown (process size)"] -} - @if(!_editing || - !_unknownProcessNm) - { - - - - @L["Please enter a valid process size in nanometers."] - - - -} - } -@if(_editing || _model.DieSize.HasValue) -{ - - @L["Die size (mm²)"] - @if(_editing) - { - @L["Unknown (die size)"] -} - @if(!_editing || - !_unknownDieSize) - { - - - - @L["Please enter a valid die size in square millimeters."] - - - -} - } -@if(_editing || _model.Transistors.HasValue) -{ - - @L["Transistors"] - @if(_editing) - { - @L["Unknown (transistors)"] -} - @if(!_editing || - !_unknownTransistors) - { - - - - @L["Please enter a valid number of transistors."] - - - -} - } -@if(_editing || _model.DataBus.HasValue) -{ - - @L["Data bus size"] - @if(_editing) - { - @L["Unknown (data bus size)"] -} - @if(!_editing || - !_unknownDataBus) - { - - - - @L["Please enter a valid data bus size in bits."] - - - -} - } -@if(_editing || _model.AddrBus.HasValue) -{ - - @L["Address bus size"] - @if(_editing) - { - @L["Unknown (address bus size)"] -} - @if(!_editing || - !_unknownAddressBus) - { - - - - @L["Please enter a valid address bus size in bits."] - - - -} - } -@if(_editing || _model.L1Instruction.HasValue) -{ - - @L["L1 instruction cache (KiB)"] - @if(_editing) - { - @L["Unknown (L1 instruction cache)"] -} - @if(!_editing || - !_unknownL1Instruction) - { - - - - @L["Please enter a valid L1 instruction cache size in kibibytes."] - - - -} - } -@if(_editing || _model.L1Data.HasValue) -{ - - @L["L1 data cache (KiB)"] - @if(_editing) - { - @L["Unknown (L1 data cache)"] -} - @if(!_editing || - !_unknownL1Data) - { - - - - @L["Please enter a valid L1 data cache size in kibibytes."] - - - -} - } -@if(_editing || _model.L2.HasValue) -{ - - @L["L2 cache (KiB)"] - @if(_editing) - { - @L["Unknown (L2 cache)"] -} - @if(!_editing || - !_unknownL2) - { - - - - @L["Please enter a valid L2 cache size in kibibytes."] - - - -} - } -@if(_editing || _model.L3.HasValue) -{ - - @L["L3 cache (KiB)"] - @if(_editing) - { - @L["Unknown (L3 cache)"] -} - @if(!_editing || - !_unknownL3) - { - - - - @L["Please enter a valid L3 cache size in kibibytes."] - - - -} - } + @L["Name"] + + + + @L["Please enter a valid name."] + + + + + @if(_editing || _model.ModelCode != null) + { + + @L["Model code"] + @if(_editing) + { + @L["Unknown (model code)"] + } + @if(!_editing || !_unknownModelCode) + { + + + + @L["Please enter a valid model code."] + + + + } + + } + @if(_editing || _model.Introduced.HasValue) + { + + @L["Introduced"] + @if(_editing) + { + @L["Unknown (introduction date)"] + + @L["Prototype"] + } + @if(!_editing || !_prototype && !_unknownIntroduced) + { + + + + @L["Please enter an introduction date."] + + + + } + + } + @if(_editing || _model.InstructionSetId != null) + { + + @L["Instruction set"] + @if(_editing) + { + @L["Unknown (instruction set)"] + } + @if(!_editing || !_unknownInstructionSet) + { + + } + + } + @if(_editing || _model.Speed.HasValue) + { + + @L["Nominal speed (MHz)"] + @if(_editing) + { + @L["Unknown (nominal speed)"] + } + @if(!_editing || !_unknownSpeed) + { + + + + @L["Please enter a valid nominal speed."] + + + + } + + } + @if(_editing || _model.Package != null) + { + + @L["Package"] + @if(_editing) + { + @L["Unknown (package)"] + } + @if(!_editing || !_unknownPackage) + { + + + + @L["Please enter a valid package."] + + + + } + + } + @if(_editing || _model.Gprs.HasValue) + { + + @L["General Purpose Registers"] + @if(_editing) + { + @L["Unknown (general purpose registers)"] + } + @if(!_editing || !_unknownGprs) + { + + + + @L["Please enter a valid number of general purpose registers."] + + + + } + + } + @if(_editing || _model.GprSize.HasValue) + { + + @L["General Purpose Register size"] + @if(_editing) + { + @L["Unknown (general purpose register size)"] + } + @if(!_editing || !_unknownGprSize) + { + + + + @L["Please enter a valid general purpose register size."] + + + + } + + } + @if(_editing || _model.Fprs.HasValue) + { + + @L["Floating Point Registers"] + @if(_editing) + { + @L["Unknown (floating point registers)"] + } + @if(!_editing || !_unknownFprs) + { + + + + @L["Please enter a valid number of floating point registers."] + + + + } + @if(_editing) + { + @L["If set to zero, but with a size, indicates floating point instructions use the general purpose registers."] + } + + } + @if(_editing || _model.FprSize.HasValue) + { + + @L["Floating Point Register size"] + @if(_editing) + { + @L["Unknown (floating point register size)"] + } + @if(!_editing || !_unknownFprSize) + { + + + + @L["Please enter a valid floating point register size."] + + + + } + + } + @if(_editing || _model.SimdRegisters.HasValue) + { + + @L["SIMD Registers"] + @if(_editing) + { + @L["Unknown (simd registers)"] + } + @if(!_editing || !_unknownSimdRegisters) + { + + + + @L["Please enter a valid number of SIMD registers."] + + + + } + @if(_editing) + { + @L["If set to zero, but with a size, indicates SIMD instructions use the floating point registers. If they are also set to zero with a size, it means SIMD instructions use the general purpose registers."] + } + + } + @if(_editing || _model.SimdSize.HasValue) + { + + @L["SIMD Register size"] + @if(_editing) + { + @L["Unknown (simd register size)"] + } + @if(!_editing || !_unknownSimdSize) + { + + + + @L["Please enter a valid SIMD register size."] + + + + } + + } + @if(_editing || _model.Cores.HasValue) + { + + @L["Cores"] + @if(_editing) + { + @L["Unknown (cores)"] + } + @if(!_editing || !_unknownCores) + { + + + + @L["Please enter a valid number of cores."] + + + + } + + } + @if(_editing || _model.ThreadsPerCore.HasValue) + { + + @L["Threads per core"] + @if(_editing) + { + @L["Unknown (threads per core)"] + } + @if(!_editing || !_unknownThreadsPerCore) + { + + + + @L["Please enter a valid number of threads per core."] + + + + } + + } + @if(_editing || _model.Process != null) + { + + @L["Process"] + @if(_editing) + { + @L["Unknown (process)"] + } + @if(!_editing || !_unknownProcess) + { + + + + @L["Please enter a valid process."] + + + + } + + } + @if(_editing || _model.ProcessNm.HasValue) + { + + @L["Process (nm)"] + @if(_editing) + { + @L["Unknown (process size)"] + } + @if(!_editing || !_unknownProcessNm) + { + + + + @L["Please enter a valid process size in nanometers."] + + + + } + + } + @if(_editing || _model.DieSize.HasValue) + { + + @L["Die size (mm²)"] + @if(_editing) + { + @L["Unknown (die size)"] + } + @if(!_editing || !_unknownDieSize) + { + + + + @L["Please enter a valid die size in square millimeters."] + + + + } + + } + @if(_editing || _model.Transistors.HasValue) + { + + @L["Transistors"] + @if(_editing) + { + @L["Unknown (transistors)"] + } + @if(!_editing || !_unknownTransistors) + { + + + + @L["Please enter a valid number of transistors."] + + + + } + + } + @if(_editing || _model.DataBus.HasValue) + { + + @L["Data bus size"] + @if(_editing) + { + @L["Unknown (data bus size)"] + } + @if(!_editing || !_unknownDataBus) + { + + + + @L["Please enter a valid data bus size in bits."] + + + + } + + } + @if(_editing || _model.AddrBus.HasValue) + { + + @L["Address bus size"] + @if(_editing) + { + @L["Unknown (address bus size)"] + } + @if(!_editing || !_unknownAddressBus) + { + + + + @L["Please enter a valid address bus size in bits."] + + + + } + + } + @if(_editing || _model.L1Instruction.HasValue) + { + + @L["L1 instruction cache (KiB)"] + @if(_editing) + { + @L["Unknown (L1 instruction cache)"] + } + @if(!_editing || !_unknownL1Instruction) + { + + + + @L["Please enter a valid L1 instruction cache size in kibibytes."] + + + + } + + } + @if(_editing || _model.L1Data.HasValue) + { + + @L["L1 data cache (KiB)"] + @if(_editing) + { + @L["Unknown (L1 data cache)"] + } + @if(!_editing || !_unknownL1Data) + { + + + + @L["Please enter a valid L1 data cache size in kibibytes."] + + + + } + + } + @if(_editing || _model.L2.HasValue) + { + + @L["L2 cache (KiB)"] + @if(_editing) + { + @L["Unknown (L2 cache)"] + } + @if(!_editing || !_unknownL2) + { + + + + @L["Please enter a valid L2 cache size in kibibytes."] + + + + } + + } + @if(_editing || _model.L3.HasValue) + { + + @L["L3 cache (KiB)"] + @if(_editing) + { + @L["Unknown (L3 cache)"] + } + @if(!_editing || !_unknownL3) + { + + + + @L["Please enter a valid L3 cache size in kibibytes."] + + + + } + + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
@if(!_editing) { -
+

@L["Instruction set extensions implemented by this processor"]

- + + + @if(_addingExtension) {
@L["Instruction set extensions"] - - + +
} + @if(_processorExtensions?.Count > 0) {
@@ -595,14 +607,15 @@ - @foreach(var item in _processorExtensions) + @foreach(InstructionSetExtensionByProcessorViewModel item in _processorExtensions) { @item.Extension - + } @@ -612,18 +625,20 @@ } - + @_deleteTitle - + @_deleteText - + - } \ No newline at end of file + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Processor.razor.cs b/Marechai/Pages/Admin/Details/Processor.razor.cs index be06af5c..973dc4b3 100644 --- a/Marechai/Pages/Admin/Details/Processor.razor.cs +++ b/Marechai/Pages/Admin/Details/Processor.razor.cs @@ -33,390 +33,362 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class Processor { - public partial class Processor + bool _addingExtension; + int? _addingExtensionId; + AuthenticationState _authState; + List _companies; + bool _creating; + InstructionSetExtensionByProcessorViewModel _currentInstructionByMachine; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _editing; + Modal _frmDelete; + List _instructionSetExtensions; + List _instructionSets; + bool _loaded; + ProcessorViewModel _model; + List _processorExtensions; + bool _prototype; + bool _savingExtension; + bool _unknownAddressBus; + bool _unknownCompany; + bool _unknownCores; + bool _unknownDataBus; + bool _unknownDieSize; + bool _unknownFprs; + bool _unknownFprSize; + bool _unknownGprs; + bool _unknownGprSize; + bool _unknownInstructionSet; + bool _unknownIntroduced; + bool _unknownL1Data; + bool _unknownL1Instruction; + bool _unknownL2; + bool _unknownL3; + bool _unknownModelCode; + bool _unknownPackage; + bool _unknownProcess; + bool _unknownProcessNm; + bool _unknownSimdRegisters; + bool _unknownSimdSize; + bool _unknownSpeed; + bool _unknownThreadsPerCore; + bool _unknownTransistors; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - bool _addingExtension; - int? _addingExtensionId; - AuthenticationState _authState; - List _companies; - bool _creating; - InstructionSetExtensionByProcessorViewModel _currentInstructionByMachine; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _editing; - Modal _frmDelete; - List _instructionSetExtensions; - List _instructionSets; - bool _loaded; - ProcessorViewModel _model; - List _processorExtensions; - bool _prototype; - bool _savingExtension; - bool _unknownAddressBus; - bool _unknownCompany; - bool _unknownCores; - bool _unknownDataBus; - bool _unknownDieSize; - bool _unknownFprs; - bool _unknownFprSize; - bool _unknownGprs; - bool _unknownGprSize; - bool _unknownInstructionSet; - bool _unknownIntroduced; - bool _unknownL1Data; - bool _unknownL1Instruction; - bool _unknownL2; - bool _unknownL3; - bool _unknownModelCode; - bool _unknownPackage; - bool _unknownProcess; - bool _unknownProcessNm; - bool _unknownSimdRegisters; - bool _unknownSimdSize; - bool _unknownSpeed; - bool _unknownThreadsPerCore; - bool _unknownTransistors; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/processors/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _companies = await CompaniesService.GetAsync(); + _instructionSets = await InstructionSetsService.GetAsync(); + _model = _creating ? new ProcessorViewModel() : await Service.GetAsync(Id); + _instructionSetExtensions = await InstructionSetExtensionsService.GetAsync(); + _processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/processors/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownAddressBus = !_model.AddrBus.HasValue; + _unknownCompany = !_model.CompanyId.HasValue; + _unknownCores = !_model.Cores.HasValue; + _unknownDataBus = !_model.DataBus.HasValue; + _unknownDieSize = !_model.DieSize.HasValue; + _unknownFprs = !_model.Fprs.HasValue; + _unknownFprSize = !_model.FprSize.HasValue; + _unknownGprs = !_model.Gprs.HasValue; + _unknownGprSize = !_model.GprSize.HasValue; + _unknownInstructionSet = !_model.InstructionSetId.HasValue; + _unknownIntroduced = !_model.Introduced.HasValue; + _unknownL1Data = !_model.L1Data.HasValue; + _unknownL1Instruction = !_model.L1Instruction.HasValue; + _unknownL2 = !_model.L2.HasValue; + _unknownL3 = !_model.L3.HasValue; + _unknownModelCode = string.IsNullOrWhiteSpace(_model.ModelCode); + _unknownPackage = string.IsNullOrWhiteSpace(_model.Package); + _unknownProcess = string.IsNullOrWhiteSpace(_model.Process); + _unknownProcessNm = !_model.ProcessNm.HasValue; + _unknownSimdRegisters = !_model.SimdRegisters.HasValue; + _unknownSimdSize = !_model.SimdSize.HasValue; + _unknownSpeed = !_model.Speed.HasValue; + _unknownThreadsPerCore = !_model.ThreadsPerCore.HasValue; + _unknownTransistors = !_model.Transistors.HasValue; + _prototype = _model.Introduced?.Year == 1000; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - if(_loaded) - return; + NavigationManager.ToBaseRelativePath("admin/processors"); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/processors/create", StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _companies = await CompaniesService.GetAsync(); - _instructionSets = await InstructionSetsService.GetAsync(); - _model = _creating ? new ProcessorViewModel() : await Service.GetAsync(Id); - _instructionSetExtensions = await InstructionSetExtensionsService.GetAsync(); - _processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/processors/edit/", - StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownCompany) + _model.CompanyId = null; + else if(_model.CompanyId < 0) return; + + if(_unknownModelCode) + _model.ModelCode = null; + else if(string.IsNullOrWhiteSpace(_model.ModelCode)) return; + + if(_unknownIntroduced) + _model.Introduced = null; + else if(_prototype) + _model.Introduced = new DateTime(1000, 1, 1); + else if(_model.Introduced >= DateTime.UtcNow.Date) return; + + if(_unknownInstructionSet) + _model.InstructionSetId = null; + else if(_model.InstructionSetId < 0) return; + + if(_unknownSpeed) + _model.Speed = null; + else if(_model.Speed < 0) return; + + if(_unknownPackage) + _model.Package = null; + else if(string.IsNullOrWhiteSpace(_model.Package)) return; + + if(_unknownGprs) + _model.Gprs = null; + else if(_model.Gprs < 0) return; + + if(_unknownGprSize) + _model.GprSize = null; + else if(_model.GprSize < 0) return; + + if(_unknownFprs) + _model.Fprs = null; + else if(_model.Fprs < 0) return; + + if(_unknownFprSize) + _model.FprSize = null; + else if(_model.FprSize < 0) return; + + if(_unknownSimdRegisters) + _model.SimdRegisters = null; + else if(_model.SimdRegisters < 0) return; + + if(_unknownSimdSize) + _model.SimdSize = null; + else if(_model.SimdSize < 0) return; + + if(_unknownCores) + _model.Cores = null; + else if(_model.Cores < 1) return; + + if(_unknownThreadsPerCore) + _model.ThreadsPerCore = null; + else if(_model.ThreadsPerCore < 1) return; + + if(_unknownProcess) + _model.Process = null; + else if(string.IsNullOrWhiteSpace(_model.Process)) return; + + if(_unknownProcessNm) + _model.ProcessNm = null; + else if(_model.ProcessNm < 1) return; + + if(_unknownDieSize) + _model.DieSize = null; + else if(_model.DieSize < 1) return; + + if(_unknownTransistors) + _model.Transistors = null; + else if(_model.Transistors < 0) return; + + if(_unknownDataBus) + _model.DataBus = null; + else if(_model.DataBus < 1) return; + + if(_unknownAddressBus) + _model.AddrBus = null; + else if(_model.AddrBus < 1) return; + + if(_unknownL1Instruction) + _model.L1Instruction = null; + else if(_model.L1Instruction < 0) return; + + if(_unknownL1Data) + _model.L1Data = null; + else if(_model.L1Data < 0) return; + + if(_unknownL2) + _model.L2 = null; + else if(_model.L2 < 0) return; + + if(_unknownL3) + _model.FprSize = null; + else if(_model.L3 < 0) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Name must be 50 characters or less."], 50); + + void ValidateModelCode(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Model code must be 45 characters or less."], 45); + + void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); + + void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e); + + void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e); + + void ValidatePackage(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Package must be 45 characters or less."], 45); + + void ValidateFloatBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateFloat(e); + + void ValidateIntegerBiggerThanOne(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1); + + void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e); + + void ValidateFloatBiggerThanOne(ValidatorEventArgs e) => Validators.ValidateFloat(e, 1); + + void ValidateProcess(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Process must be 45 characters or less."], 45); + + void ShowExtensionDeleteModal(long itemId) + { + _currentInstructionByMachine = _processorExtensions.FirstOrDefault(n => n.Id == itemId); + _deleteTitle = L["Delete instruction set extension from this processor"]; + + _deleteText = + string.Format(L["Are you sure you want to delete the instruction set extension {0} from this processor?"], + _currentInstructionByMachine?.Extension); + + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentInstructionByMachine is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await InstructionSetExtensionsByProcessorService.DeleteAsync(_currentInstructionByMachine.Id, + (await UserManager.GetUserAsync(_authState.User)) + .Id); + + _processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _currentInstructionByMachine = null; + } + + void OnAddExtensionClick() + { + _addingExtension = true; + _savingExtension = false; + _addingExtensionId = _instructionSetExtensions.First().Id; + } + + void CancelAddExtension() + { + _addingExtension = false; + _savingExtension = false; + _addingExtensionId = null; + } + + async Task ConfirmAddExtension() + { + if(_addingExtensionId is null || _addingExtensionId <= 0) { - _unknownAddressBus = !_model.AddrBus.HasValue; - _unknownCompany = !_model.CompanyId.HasValue; - _unknownCores = !_model.Cores.HasValue; - _unknownDataBus = !_model.DataBus.HasValue; - _unknownDieSize = !_model.DieSize.HasValue; - _unknownFprs = !_model.Fprs.HasValue; - _unknownFprSize = !_model.FprSize.HasValue; - _unknownGprs = !_model.Gprs.HasValue; - _unknownGprSize = !_model.GprSize.HasValue; - _unknownInstructionSet = !_model.InstructionSetId.HasValue; - _unknownIntroduced = !_model.Introduced.HasValue; - _unknownL1Data = !_model.L1Data.HasValue; - _unknownL1Instruction = !_model.L1Instruction.HasValue; - _unknownL2 = !_model.L2.HasValue; - _unknownL3 = !_model.L3.HasValue; - _unknownModelCode = string.IsNullOrWhiteSpace(_model.ModelCode); - _unknownPackage = string.IsNullOrWhiteSpace(_model.Package); - _unknownProcess = string.IsNullOrWhiteSpace(_model.Process); - _unknownProcessNm = !_model.ProcessNm.HasValue; - _unknownSimdRegisters = !_model.SimdRegisters.HasValue; - _unknownSimdSize = !_model.SimdSize.HasValue; - _unknownSpeed = !_model.Speed.HasValue; - _unknownThreadsPerCore = !_model.ThreadsPerCore.HasValue; - _unknownTransistors = !_model.Transistors.HasValue; - _prototype = _model.Introduced?.Year == 1000; + CancelAddExtension(); + + return; } - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } + _savingExtension = true; - async void OnCancelClicked() - { - _editing = false; + // Yield thread to let UI to update + await Task.Yield(); - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/processors"); + await InstructionSetExtensionsByProcessorService.CreateAsync(Id, + _addingExtensionId.Value, + (await UserManager.GetUserAsync(_authState.User)) + .Id); - return; - } + _processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id); - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + _addingExtension = false; + _savingExtension = false; + _addingExtensionId = null; - async void OnSaveClicked() - { - if(_unknownCompany) - _model.CompanyId = null; - else if(_model.CompanyId < 0) - return; + // Yield thread to let UI to update + await Task.Yield(); - if(_unknownModelCode) - _model.ModelCode = null; - else if(string.IsNullOrWhiteSpace(_model.ModelCode)) - return; - - if(_unknownIntroduced) - _model.Introduced = null; - else if(_prototype) - _model.Introduced = new DateTime(1000, 1, 1); - else if(_model.Introduced >= DateTime.UtcNow.Date) - return; - - if(_unknownInstructionSet) - _model.InstructionSetId = null; - else if(_model.InstructionSetId < 0) - return; - - if(_unknownSpeed) - _model.Speed = null; - else if(_model.Speed < 0) - return; - - if(_unknownPackage) - _model.Package = null; - else if(string.IsNullOrWhiteSpace(_model.Package)) - return; - - if(_unknownGprs) - _model.Gprs = null; - else if(_model.Gprs < 0) - return; - - if(_unknownGprSize) - _model.GprSize = null; - else if(_model.GprSize < 0) - return; - - if(_unknownFprs) - _model.Fprs = null; - else if(_model.Fprs < 0) - return; - - if(_unknownFprSize) - _model.FprSize = null; - else if(_model.FprSize < 0) - return; - - if(_unknownSimdRegisters) - _model.SimdRegisters = null; - else if(_model.SimdRegisters < 0) - return; - - if(_unknownSimdSize) - _model.SimdSize = null; - else if(_model.SimdSize < 0) - return; - - if(_unknownCores) - _model.Cores = null; - else if(_model.Cores < 1) - return; - - if(_unknownThreadsPerCore) - _model.ThreadsPerCore = null; - else if(_model.ThreadsPerCore < 1) - return; - - if(_unknownProcess) - _model.Process = null; - else if(string.IsNullOrWhiteSpace(_model.Process)) - return; - - if(_unknownProcessNm) - _model.ProcessNm = null; - else if(_model.ProcessNm < 1) - return; - - if(_unknownDieSize) - _model.DieSize = null; - else if(_model.DieSize < 1) - return; - - if(_unknownTransistors) - _model.Transistors = null; - else if(_model.Transistors < 0) - return; - - if(_unknownDataBus) - _model.DataBus = null; - else if(_model.DataBus < 1) - return; - - if(_unknownAddressBus) - _model.AddrBus = null; - else if(_model.AddrBus < 1) - return; - - if(_unknownL1Instruction) - _model.L1Instruction = null; - else if(_model.L1Instruction < 0) - return; - - if(_unknownL1Data) - _model.L1Data = null; - else if(_model.L1Data < 0) - return; - - if(_unknownL2) - _model.L2 = null; - else if(_model.L2 < 0) - return; - - if(_unknownL3) - _model.FprSize = null; - else if(_model.L3 < 0) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Name must be 50 characters or less."], 50); - - void ValidateModelCode(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Model code must be 45 characters or less."], 45); - - void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); - - void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e); - - void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e); - - void ValidatePackage(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Package must be 45 characters or less."], 45); - - void ValidateFloatBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateFloat(e); - - void ValidateIntegerBiggerThanOne(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1); - - void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e); - - void ValidateFloatBiggerThanOne(ValidatorEventArgs e) => Validators.ValidateFloat(e, 1); - - void ValidateProcess(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Process must be 45 characters or less."], 45); - - void ShowExtensionDeleteModal(long itemId) - { - _currentInstructionByMachine = _processorExtensions.FirstOrDefault(n => n.Id == itemId); - _deleteTitle = L["Delete instruction set extension from this processor"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the instruction set extension {0} from this processor?"], - _currentInstructionByMachine?.Extension); - - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentInstructionByMachine is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await InstructionSetExtensionsByProcessorService.DeleteAsync(_currentInstructionByMachine.Id, - (await UserManager. - GetUserAsync(_authState.User)).Id); - - _processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _currentInstructionByMachine = null; - } - - void OnAddExtensionClick() - { - _addingExtension = true; - _savingExtension = false; - _addingExtensionId = _instructionSetExtensions.First().Id; - } - - void CancelAddExtension() - { - _addingExtension = false; - _savingExtension = false; - _addingExtensionId = null; - } - - async Task ConfirmAddExtension() - { - if(_addingExtensionId is null || - _addingExtensionId <= 0) - { - CancelAddExtension(); - - return; - } - - _savingExtension = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await InstructionSetExtensionsByProcessorService.CreateAsync(Id, _addingExtensionId.Value, - (await UserManager. - GetUserAsync(_authState.User)).Id); - - _processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id); - - _addingExtension = false; - _savingExtension = false; - _addingExtensionId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Resolution.razor b/Marechai/Pages/Admin/Details/Resolution.razor index c7c44b8d..079b2c79 100644 --- a/Marechai/Pages/Admin/Details/Resolution.razor +++ b/Marechai/Pages/Admin/Details/Resolution.razor @@ -31,12 +31,12 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject NavigationManager NavigationManager -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject NavigationManager NavigationManager +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Resolution details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -71,9 +71,8 @@ @if(_editing) { @L["Unknown (colors)"] -} - @if(!_editing || - !_unknownColors) + } + @if(!_editing || !_unknownColors) { @@ -82,9 +81,9 @@ -} + } -} + } @if(_editing || _model.Palette.HasValue) { @@ -92,9 +91,8 @@ @if(_editing) { @L["Unknown (colors in palette)"] -} - @if(!_editing || - !_unknownPalette) + } + @if(!_editing || !_unknownPalette) { @@ -103,25 +101,28 @@ -} + } -} + } - @L["Resolution is character based (text only)."] + @L["Resolution is character based (text only)."] - @L["Resolution only has gray colors."] + @L["Resolution only has gray colors."]
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Resolution.razor.cs b/Marechai/Pages/Admin/Details/Resolution.razor.cs index 6f655ccc..547c53cb 100644 --- a/Marechai/Pages/Admin/Details/Resolution.razor.cs +++ b/Marechai/Pages/Admin/Details/Resolution.razor.cs @@ -31,102 +31,97 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class Resolution { - public partial class Resolution + AuthenticationState _authState; + bool _creating; + bool _editing; + bool _loaded; + ResolutionViewModel _model; + bool _unknownColors; + bool _unknownPalette; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - AuthenticationState _authState; - bool _creating; - bool _editing; - bool _loaded; - ResolutionViewModel _model; - bool _unknownColors; - bool _unknownPalette; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; + _loaded = true; - _loaded = true; + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/resolutions/create", StringComparison.InvariantCulture); - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/resolutions/create", StringComparison.InvariantCulture); + if(Id <= 0 && !_creating) return; - if(Id <= 0 && - !_creating) - return; + _model = _creating ? new ResolutionViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _model = _creating ? new ResolutionViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/resolutions/edit/", StringComparison.InvariantCulture); - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/resolutions/edit/", - StringComparison.InvariantCulture); + if(_editing) SetCheckboxes(); - if(_editing) - SetCheckboxes(); - - StateHasChanged(); - } - - void SetCheckboxes() - { - _unknownColors = !_model.Colors.HasValue; - _unknownPalette = !_model.Colors.HasValue; - } - - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } - - async void OnCancelClicked() - { - _editing = false; - - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/resolutions"); - - return; - } - - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - async void OnSaveClicked() - { - if(_unknownColors) - _model.Colors = null; - else if(_model.Colors <= 0) - return; - - if(_unknownPalette) - _model.Palette = null; - else if(_model.Palette <= 0) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1); - - void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e, 2); + StateHasChanged(); } + + void SetCheckboxes() + { + _unknownColors = !_model.Colors.HasValue; + _unknownPalette = !_model.Colors.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) + { + NavigationManager.ToBaseRelativePath("admin/resolutions"); + + return; + } + + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownColors) + _model.Colors = null; + else if(_model.Colors <= 0) return; + + if(_unknownPalette) + _model.Palette = null; + else if(_model.Palette <= 0) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1); + + void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e, 2); } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Screen.razor b/Marechai/Pages/Admin/Details/Screen.razor index e5320dfa..1e01ee1b 100644 --- a/Marechai/Pages/Admin/Details/Screen.razor +++ b/Marechai/Pages/Admin/Details/Screen.razor @@ -31,14 +31,14 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject ResolutionsService ResolutionsService -@inject NavigationManager NavigationManager -@inject ResolutionsByScreenService ResolutionsByScreenService -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject ResolutionsService ResolutionsService +@inject NavigationManager NavigationManager +@inject ResolutionsByScreenService ResolutionsByScreenService +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Screen details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -53,9 +53,8 @@ @if(_editing) { @L["Unknown (width)"] -} - @if(!_editing || - !_unknownWidth) + } + @if(!_editing || !_unknownWidth) { @@ -64,9 +63,9 @@ -} + } -} + } @if(_editing || _model.Height.HasValue) { @@ -74,9 +73,8 @@ @if(_editing) { @L["Unknown (height)"] -} - @if(!_editing || - !_unknownHeight) + } + @if(!_editing || !_unknownHeight) { @@ -85,9 +83,9 @@ -} + } -} + } @L["Diagonal (inches)"] @@ -105,20 +103,20 @@ @if(_editing) { @L["Unknown (effective colors)"] -} - @if(!_editing || - !_unknownColors) + } + @if(!_editing || !_unknownColors) { - + @L["Please enter a number of effective colors."] -} + } -} + } @if(_editing || _model.Type != null) { @@ -126,9 +124,8 @@ @if(_editing) { @L["Unknown (type)"] -} - @if(!_editing || - !_unknownType) + } + @if(!_editing || !_unknownType) { @@ -137,16 +134,16 @@ -} + } -} + } @L["Native resolution"]
@@ -154,39 +151,45 @@ @if(!_editing) { -} + } else { + -} + } @L["Back to list"]
@if(!_editing) { -
+

@L["Resolutions supported by this screen"]

- + + + @if(_addingResolution) {
@L["Resolutions"] - - + +
} + @if(_screenResolutions?.Count > 0) {
@@ -215,7 +218,7 @@ - @foreach(var item in _screenResolutions) + @foreach(ResolutionByScreenViewModel item in _screenResolutions) { @@ -237,7 +240,8 @@ @item.Resolution.Grayscale - + } @@ -247,18 +251,20 @@ } - + @_deleteTitle - + @_deleteText - + - } \ No newline at end of file + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Screen.razor.cs b/Marechai/Pages/Admin/Details/Screen.razor.cs index 5c185dd6..9c0f9632 100644 --- a/Marechai/Pages/Admin/Details/Screen.razor.cs +++ b/Marechai/Pages/Admin/Details/Screen.razor.cs @@ -33,220 +33,212 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class Screen { - public partial class Screen + bool _addingResolution; + int? _addingResolutionId; + AuthenticationState _authState; + bool _creating; + ResolutionByScreenViewModel _currentResolution; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _editing; + Modal _frmDelete; + bool _loaded; + ScreenViewModel _model; + List _resolutions; + bool _savingResolution; + List _screenResolutions; + bool _unknownColors; + bool _unknownHeight; + bool _unknownType; + bool _unknownWidth; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - bool _addingResolution; - int? _addingResolutionId; - AuthenticationState _authState; - bool _creating; - ResolutionByScreenViewModel _currentResolution; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _editing; - Modal _frmDelete; - bool _loaded; - ScreenViewModel _model; - List _resolutions; - bool _savingResolution; - List _screenResolutions; - bool _unknownColors; - bool _unknownHeight; - bool _unknownType; - bool _unknownWidth; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/screens/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _resolutions = await ResolutionsService.GetAsync(); + _model = _creating ? new ScreenViewModel() : await Service.GetAsync(Id); + _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/screens/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownWidth = !_model.Width.HasValue; + _unknownType = string.IsNullOrWhiteSpace(_model.Type); + _unknownHeight = !_model.Height.HasValue; + _unknownColors = !_model.Colors.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - if(_loaded) - return; + NavigationManager.ToBaseRelativePath("admin/screens"); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/screens/create", StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _resolutions = await ResolutionsService.GetAsync(); - _model = _creating ? new ScreenViewModel() : await Service.GetAsync(Id); - _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/screens/edit/", - StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownWidth) + _model.Width = null; + else if(_model.Width < 0) return; + + if(_unknownHeight) + _model.Height = null; + else if(_model.Height < 0) return; + + if(_unknownType) + _model.Type = null; + else if(string.IsNullOrWhiteSpace(_model.Type)) return; + + if(_unknownColors) + _model.EffectiveColors = null; + else if(_model.EffectiveColors < 0) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e, 1, 131072); + + void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e, 2); + + void ValidateType(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Screen type cannot be bigger than 256 characters."], 256); + + void ShowResolutionDeleteModal(long itemId) + { + _currentResolution = _screenResolutions.FirstOrDefault(n => n.Id == itemId); + _deleteTitle = L["Delete resolution from this screen"]; + + _deleteText = string.Format(L["Are you sure you want to delete the resolution {0} from this screen?"], + _currentResolution); + + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentResolution is null) return; + + _deleteInProgress = true; + + // Yield thread to let UI to update + await Task.Yield(); + + await ResolutionsByScreenService.DeleteAsync(_currentResolution.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); + + _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _currentResolution = null; + } + + void OnAddResolutionClick() + { + _addingResolution = true; + _savingResolution = false; + _addingResolutionId = _resolutions.First().Id; + } + + void CancelAddResolution() + { + _addingResolution = false; + _savingResolution = false; + _addingResolutionId = null; + } + + async Task ConfirmAddResolution() + { + if(_addingResolutionId is null || _addingResolutionId <= 0) { - _unknownWidth = !_model.Width.HasValue; - _unknownType = string.IsNullOrWhiteSpace(_model.Type); - _unknownHeight = !_model.Height.HasValue; - _unknownColors = !_model.Colors.HasValue; + CancelAddResolution(); + + return; } - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } + _savingResolution = true; - async void OnCancelClicked() - { - _editing = false; + // Yield thread to let UI to update + await Task.Yield(); - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/screens"); + await ResolutionsByScreenService.CreateAsync(_addingResolutionId.Value, + Id, + (await UserManager.GetUserAsync(_authState.User)).Id); - return; - } + _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + _addingResolution = false; + _savingResolution = false; + _addingResolutionId = null; - async void OnSaveClicked() - { - if(_unknownWidth) - _model.Width = null; - else if(_model.Width < 0) - return; + // Yield thread to let UI to update + await Task.Yield(); - if(_unknownHeight) - _model.Height = null; - else if(_model.Height < 0) - return; - - if(_unknownType) - _model.Type = null; - else if(string.IsNullOrWhiteSpace(_model.Type)) - return; - - if(_unknownColors) - _model.EffectiveColors = null; - else if(_model.EffectiveColors < 0) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e, 1, 131072); - - void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e, 2); - - void ValidateType(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Screen type cannot be bigger than 256 characters."], 256); - - void ShowResolutionDeleteModal(long itemId) - { - _currentResolution = _screenResolutions.FirstOrDefault(n => n.Id == itemId); - _deleteTitle = L["Delete resolution from this screen"]; - - _deleteText = string.Format(L["Are you sure you want to delete the resolution {0} from this screen?"], - _currentResolution); - - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentResolution is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await ResolutionsByScreenService.DeleteAsync(_currentResolution.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _currentResolution = null; - } - - void OnAddResolutionClick() - { - _addingResolution = true; - _savingResolution = false; - _addingResolutionId = _resolutions.First().Id; - } - - void CancelAddResolution() - { - _addingResolution = false; - _savingResolution = false; - _addingResolutionId = null; - } - - async Task ConfirmAddResolution() - { - if(_addingResolutionId is null || - _addingResolutionId <= 0) - { - CancelAddResolution(); - - return; - } - - _savingResolution = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await ResolutionsByScreenService.CreateAsync(_addingResolutionId.Value, Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id); - - _addingResolution = false; - _savingResolution = false; - _addingResolutionId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoftwareFamily.razor b/Marechai/Pages/Admin/Details/SoftwareFamily.razor index 53e28ecf..daeb279f 100644 --- a/Marechai/Pages/Admin/Details/SoftwareFamily.razor +++ b/Marechai/Pages/Admin/Details/SoftwareFamily.razor @@ -31,17 +31,17 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject CompaniesService CompaniesService -@inject DocumentRolesService DocumentRolesService -@inject CompaniesBySoftwareFamilyService CompaniesBySoftwareFamilyService -@inject NavigationManager NavigationManager -@inject IWebHostEnvironment Host -@inject IJSRuntime JSRuntime -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject CompaniesService CompaniesService +@inject DocumentRolesService DocumentRolesService +@inject CompaniesBySoftwareFamilyService CompaniesBySoftwareFamilyService +@inject NavigationManager NavigationManager +@inject IWebHostEnvironment Host +@inject IJSRuntime JSRuntime +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Software family details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -66,9 +66,8 @@ @if(_editing) { @L["Unknown (introduction date)"] -} - @if(!_editing || - !_unknownIntroduced) + } + @if(!_editing || !_unknownIntroduced) { @@ -77,72 +76,76 @@ -} + } -} + } @if(_editing || _model.ParentId != null) { @L["Parent software family"] @if(_editing) { - @L["Unknown or none (parent software family)"] -} - @if(!_editing || - !_unknownParent) + @L["Unknown or none (parent software family)"] + } + @if(!_editing || !_unknownParent) { -} + } -} + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
@if(!_editing) { -
+

@L["Companies involved in this software family"]

+ + @if(_addingCompany) {
@L["Company"] @L["Role"]
} + @if(_softwareFamilyCompanies?.Count > 0) {
@@ -159,7 +162,7 @@ - @foreach(var item in _softwareFamilyCompanies) + @foreach(CompanyBySoftwareFamilyViewModel item in _softwareFamilyCompanies) { @@ -169,7 +172,8 @@ @item.Role - + } @@ -179,18 +183,20 @@ } - + @_deleteTitle - + @_deleteText - + - } \ No newline at end of file + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoftwareFamily.razor.cs b/Marechai/Pages/Admin/Details/SoftwareFamily.razor.cs index 8cc00a55..e41fb8ab 100644 --- a/Marechai/Pages/Admin/Details/SoftwareFamily.razor.cs +++ b/Marechai/Pages/Admin/Details/SoftwareFamily.razor.cs @@ -33,225 +33,218 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class SoftwareFamily { - public partial class SoftwareFamily + bool _addingCompany; + int? _addingCompanyId; + string _addingCompanyRoleId; + AuthenticationState _authState; + List _companies; + bool _creating; + CompanyBySoftwareFamilyViewModel _currentCompanyBySoftwareFamily; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _deletingCompanyBySoftwareFamily; + bool _editing; + Modal _frmDelete; + bool _loaded; + SoftwareFamilyViewModel _model; + List _roles; + bool _savingCompany; + List _softwareFamilies; + List _softwareFamilyCompanies; + bool _unknownIntroduced; + bool _unknownParent; + + [Parameter] + public ulong Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - bool _addingCompany; - int? _addingCompanyId; - string _addingCompanyRoleId; - AuthenticationState _authState; - List _companies; - bool _creating; - CompanyBySoftwareFamilyViewModel _currentCompanyBySoftwareFamily; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _deletingCompanyBySoftwareFamily; - bool _editing; - Modal _frmDelete; - bool _loaded; - SoftwareFamilyViewModel _model; - List _roles; - bool _savingCompany; - List _softwareFamilies; - List _softwareFamilyCompanies; - bool _unknownIntroduced; - bool _unknownParent; + if(_loaded) return; - [Parameter] - public ulong Id { get; set; } + _loaded = true; - protected override async Task OnAfterRenderAsync(bool firstRender) + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/software_families/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _softwareFamilies = await Service.GetAsync(); + _companies = await CompaniesService.GetAsync(); + _roles = await DocumentRolesService.GetEnabledAsync(); + _model = _creating ? new SoftwareFamilyViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _addingCompanyRoleId = _roles.First().Id; + _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/software_families/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownParent = !_model.ParentId.HasValue; + _unknownIntroduced = !_model.Introduced.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - if(_loaded) - return; + NavigationManager.ToBaseRelativePath("admin/software_families"); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/software_families/create", - StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _softwareFamilies = await Service.GetAsync(); - _companies = await CompaniesService.GetAsync(); - _roles = await DocumentRolesService.GetEnabledAsync(); - _model = _creating ? new SoftwareFamilyViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _addingCompanyRoleId = _roles.First().Id; - _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/software_families/edit/", - StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownParent) + _model.ParentId = null; + else if(_model.ParentId < 1) return; + + if(_unknownIntroduced) + _model.Introduced = null; + else if(_model.Introduced?.Date >= DateTime.UtcNow.Date) return; + + if(string.IsNullOrWhiteSpace(_model.Name)) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Name must be smaller than 256 characters."], 256); + + void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateDate(e); + + void OnAddCompanyClick() + { + _addingCompany = true; + _savingCompany = false; + _addingCompanyId = _companies.First().Id; + } + + void CancelAddCompany() + { + _addingCompany = false; + _savingCompany = false; + _addingCompanyId = null; + } + + async Task ConfirmAddCompany() + { + if(_addingCompanyId is null || _addingCompanyId <= 0) { - _unknownParent = !_model.ParentId.HasValue; - _unknownIntroduced = !_model.Introduced.HasValue; + CancelAddCompany(); + + return; } - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } + _savingCompany = true; - async void OnCancelClicked() - { - _editing = false; + // Yield thread to let UI to update + await Task.Yield(); - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/software_families"); + await CompaniesBySoftwareFamilyService.CreateAsync(_addingCompanyId.Value, + Id, + _addingCompanyRoleId, + (await UserManager.GetUserAsync(_authState.User)).Id); - return; - } + _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id); - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + _addingCompany = false; + _savingCompany = false; + _addingCompanyId = null; - async void OnSaveClicked() - { - if(_unknownParent) - _model.ParentId = null; - else if(_model.ParentId < 1) - return; + // Yield thread to let UI to update + await Task.Yield(); - if(_unknownIntroduced) - _model.Introduced = null; - else if(_model.Introduced?.Date >= DateTime.UtcNow.Date) - return; + // Tell we finished loading + StateHasChanged(); + } - if(string.IsNullOrWhiteSpace(_model.Name)) - return; + void ShowCompanyDeleteModal(ulong itemId) + { + _currentCompanyBySoftwareFamily = _softwareFamilyCompanies.FirstOrDefault(n => n.Id == itemId); + _deletingCompanyBySoftwareFamily = true; + _deleteTitle = L["Delete company from this software family"]; - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + _deleteText = + string.Format(L["Are you sure you want to delete the company {0} with role {1} from this software family?"], + _currentCompanyBySoftwareFamily?.Company, + _currentCompanyBySoftwareFamily?.Role); - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + _frmDelete.Show(); + } - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Name must be smaller than 256 characters."], 256); + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _deletingCompanyBySoftwareFamily = false; + _currentCompanyBySoftwareFamily = null; + } - void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateDate(e); + void HideModal() => _frmDelete.Hide(); - void OnAddCompanyClick() - { - _addingCompany = true; - _savingCompany = false; - _addingCompanyId = _companies.First().Id; - } + async void ConfirmDelete() + { + if(_deletingCompanyBySoftwareFamily) await ConfirmDeleteCompanyByMachine(); + } - void CancelAddCompany() - { - _addingCompany = false; - _savingCompany = false; - _addingCompanyId = null; - } + async Task ConfirmDeleteCompanyByMachine() + { + if(_currentCompanyBySoftwareFamily is null) return; - async Task ConfirmAddCompany() - { - if(_addingCompanyId is null || - _addingCompanyId <= 0) - { - CancelAddCompany(); + _deleteInProgress = true; - return; - } + // Yield thread to let UI to update + await Task.Yield(); - _savingCompany = true; + await CompaniesBySoftwareFamilyService.DeleteAsync(_currentCompanyBySoftwareFamily.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); - // Yield thread to let UI to update - await Task.Yield(); + _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id); - await CompaniesBySoftwareFamilyService.CreateAsync(_addingCompanyId.Value, Id, _addingCompanyRoleId, - (await UserManager.GetUserAsync(_authState.User)).Id); + _deleteInProgress = false; + _frmDelete.Hide(); - _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id); + // Yield thread to let UI to update + await Task.Yield(); - _addingCompany = false; - _savingCompany = false; - _addingCompanyId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ShowCompanyDeleteModal(ulong itemId) - { - _currentCompanyBySoftwareFamily = _softwareFamilyCompanies.FirstOrDefault(n => n.Id == itemId); - _deletingCompanyBySoftwareFamily = true; - _deleteTitle = L["Delete company from this software family"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the company {0} with role {1} from this software family?"], - _currentCompanyBySoftwareFamily?.Company, _currentCompanyBySoftwareFamily?.Role); - - _frmDelete.Show(); - } - - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _deletingCompanyBySoftwareFamily = false; - _currentCompanyBySoftwareFamily = null; - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_deletingCompanyBySoftwareFamily) - await ConfirmDeleteCompanyByMachine(); - } - - async Task ConfirmDeleteCompanyByMachine() - { - if(_currentCompanyBySoftwareFamily is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await CompaniesBySoftwareFamilyService.DeleteAsync(_currentCompanyBySoftwareFamily.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoftwareVariant.razor b/Marechai/Pages/Admin/Details/SoftwareVariant.razor index 69299b94..dfea9536 100644 --- a/Marechai/Pages/Admin/Details/SoftwareVariant.razor +++ b/Marechai/Pages/Admin/Details/SoftwareVariant.razor @@ -28,23 +28,23 @@ @page "/admin/software_variants/details/{Id:long}" @page "/admin/software_variants/edit/{Id:long}" @page "/admin/software_variants/create" -@using Marechai.Database.Models @using Marechai.Database +@using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject SoftwareVersionsService SoftwareVersionsService -@inject LicensesService LicensesService -@inject CompaniesService CompaniesService -@inject DocumentRolesService DocumentRolesService -@inject CompaniesBySoftwareVariantService CompaniesBySoftwareVariantService -@inject NavigationManager NavigationManager -@inject IWebHostEnvironment Host -@inject IJSRuntime JSRuntime -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject SoftwareVersionsService SoftwareVersionsService +@inject LicensesService LicensesService +@inject CompaniesService CompaniesService +@inject DocumentRolesService DocumentRolesService +@inject CompaniesBySoftwareVariantService CompaniesBySoftwareVariantService +@inject NavigationManager NavigationManager +@inject IWebHostEnvironment Host +@inject IJSRuntime JSRuntime +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Software variant details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -52,290 +52,297 @@ return; }
- - @L["Software version"] - - -@if(_editing || _model.Name != null) -{ - @L["Name, if different from software version name"] - @if(_editing) - { - @L["Unknown (name)"] -} - @if(!_editing || - !_unknownName) - { - - - - @L["Please enter a valid name."] - - - -} - } -@if(_editing || _model.Version != null) -{ + @L["Software version"] + + + @if(_editing || _model.Name != null) + { + + @L["Name, if different from software version name"] + @if(_editing) + { + @L["Unknown (name)"] + } + @if(!_editing || !_unknownName) + { + + + + @L["Please enter a valid name."] + + + + } + + } + @if(_editing || _model.Version != null) + { + + @L["Version, if different from software version's"] + @if(_editing) + { + @L["Unknown (version)"] + } + @if(!_editing || !_unknownVersion) + { + + + + @L["Please enter a valid version."] + + + + } + + } + @if(_editing || _model.Introduced != null) + { + + @L["Introduced"] + @if(_editing) + { + @L["Unknown (introduction date)"] + } + @if(!_editing || !_unknownIntroduced) + { + + + + @L["Please enter a valid introduction date."] + + + + } + + } + @if(_editing || _model.ParentId != null) + { + + @L["Parent"] + @if(_editing) + { + @L["Unknown or none (parent variant)"] + } + @if(!_editing || !_unknownParent) + { + + } + + } + @if(_editing || _model.MinimumMemory.HasValue) + { + + @L["Minimum memory (bytes)"] + @if(_editing) + { + @L["Unknown (minimum memory)"] + } + @if(!_editing || !_unknownMinimumMemory) + { + + + + @L["Please enter the minimum memory size in bytes."] + + + + } + + } + @if(_editing || _model.RecommendedMemory.HasValue) + { + + @L["Recommended memory (bytes)"] + @if(_editing) + { + @L["Unknown (recommended memory)"] + } + @if(!_editing || !_unknownRecommendedMemory) + { + + + + @L["Please enter the recommended memory size in bytes."] + + + + } + + } + @if(_editing || _model.RequiredStorage.HasValue) + { + + @L["Required storage (bytes)"] + @if(_editing) + { + @L["Unknown (required storage)"] + } + @if(!_editing || !_unknownRequiredStorage) + { + + + + @L["Please enter the required storage size in bytes."] + + + + } + + } + @if(_editing || _model.PartNumber != null) + { + + @L["Part number"] + @if(_editing) + { + @L["Unknown (part number)"] + } + @if(!_editing || !_unknownPartNumber) + { + + + + @L["Please enter a valid part number."] + + + + } + + } + @if(_editing || _model.SerialNumber != null) + { + + @L["Serial number"] + @if(_editing) + { + @L["Unknown (serial number)"] + } + @if(_editing) + { + @L["Serial number is NOT the serial number used to install the software, but a serial number some software manufacturers use as SKU."] + } + @if(!_editing || !_unknownSerialNumber) + { + + + + @L["Please enter a valid serial number."] + + + + } + + } + @if(_editing || _model.ProductCode != null) + { + + @L["Product code"] + @if(_editing) + { + @L["Unknown (product code)"] + } + @if(!_editing || !_unknownProductCode) + { + + + + @L["Please enter a valid product code."] + + + + } + + } + @if(_editing || _model.CatalogueNumber != null) + { + + @L["Catalogue number"] + @if(_editing) + { + @L["Unknown (catalogue number)"] + } + @if(!_editing || !_unknownCatalogueNumber) + { + + + + @L["Please enter a valid catalogue number."] + + + + } + + } - @L["Version, if different from software version's"] - @if(_editing) - { - @L["Unknown (version)"] -} - @if(!_editing || - !_unknownVersion) - { - - - - @L["Please enter a valid version."] - - - -} - } -@if(_editing || _model.Introduced != null) -{ - - @L["Introduced"] - @if(_editing) - { - @L["Unknown (introduction date)"] -} - @if(!_editing || - !_unknownIntroduced) - { - - - - @L["Please enter a valid introduction date."] - - - -} - } -@if(_editing || _model.ParentId != null) -{ - - @L["Parent"] - @if(_editing) - { - @L["Unknown or none (parent variant)"] -} - @if(!_editing || - !_unknownParent) - { - -} - } -@if(_editing || _model.MinimumMemory.HasValue) -{ - - @L["Minimum memory (bytes)"] - @if(_editing) - { - @L["Unknown (minimum memory)"] -} - @if(!_editing || - !_unknownMinimumMemory) - { - - - - @L["Please enter the minimum memory size in bytes."] - - - -} - } -@if(_editing || _model.RecommendedMemory.HasValue) -{ - - @L["Recommended memory (bytes)"] - @if(_editing) - { - @L["Unknown (recommended memory)"] -} - @if(!_editing || - !_unknownRecommendedMemory) - { - - - - @L["Please enter the recommended memory size in bytes."] - - - -} - } -@if(_editing || _model.RequiredStorage.HasValue) -{ - - @L["Required storage (bytes)"] - @if(_editing) - { - @L["Unknown (required storage)"] -} - @if(!_editing || - !_unknownRequiredStorage) - { - - - - @L["Please enter the required storage size in bytes."] - - - -} - } -@if(_editing || _model.PartNumber != null) -{ - - @L["Part number"] - @if(_editing) - { - @L["Unknown (part number)"] -} - @if(!_editing || - !_unknownPartNumber) - { - - - - @L["Please enter a valid part number."] - - - -} - } -@if(_editing || _model.SerialNumber != null) -{ - - @L["Serial number"] - @if(_editing) - { - @L["Unknown (serial number)"] -} - @if(_editing) - { - @L["Serial number is NOT the serial number used to install the software, but a serial number some software manufacturers use as SKU."] - } - @if(!_editing || - !_unknownSerialNumber) - { - - - - @L["Please enter a valid serial number."] - - - -} - } -@if(_editing || _model.ProductCode != null) -{ - - @L["Product code"] - @if(_editing) - { - @L["Unknown (product code)"] -} - @if(!_editing || - !_unknownProductCode) - { - - - - @L["Please enter a valid product code."] - - - -} - } -@if(_editing || _model.CatalogueNumber != null) -{ - - @L["Catalogue number"] - @if(_editing) - { - @L["Unknown (catalogue number)"] -} - @if(!_editing || - !_unknownCatalogueNumber) - { - - - - @L["Please enter a valid catalogue number."] - - - -} - } - - @L["Distribution mode"] - - + @L["Distribution mode"] + +
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
@if(!_editing) { -
+

@L["Companies involved in this software variant"]

+ + @if(_addingCompany) {
@L["Company"] @L["Role"]
} + @if(_softwareVariantCompanies?.Count > 0) {
@@ -352,7 +359,7 @@ - @foreach(var item in _softwareVariantCompanies) + @foreach(CompanyBySoftwareVariantViewModel item in _softwareVariantCompanies) { @@ -362,7 +369,8 @@ @item.Role - + } @@ -372,18 +380,20 @@ } - + @_deleteTitle - + @_deleteText - + - } \ No newline at end of file + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoftwareVariant.razor.cs b/Marechai/Pages/Admin/Details/SoftwareVariant.razor.cs index af92acfc..5545df66 100644 --- a/Marechai/Pages/Admin/Details/SoftwareVariant.razor.cs +++ b/Marechai/Pages/Admin/Details/SoftwareVariant.razor.cs @@ -34,295 +34,283 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class SoftwareVariant { - public partial class SoftwareVariant + bool _addingCompany; + int? _addingCompanyId; + string _addingCompanyRoleId; + AuthenticationState _authState; + List _companies; + bool _creating; + CompanyBySoftwareVariantViewModel _currentCompanyBySoftwareVariant; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _deletingCompanyBySoftwareVariant; + bool _editing; + Modal _frmDelete; + bool _loaded; + SoftwareVariantViewModel _model; + List _roles; + bool _savingCompany; + List _softwareVariantCompanies; + List _softwareVariants; + List _softwareVersions; + bool _unknownCatalogueNumber; + bool _unknownIntroduced; + bool _unknownMinimumMemory; + bool _unknownName; + bool _unknownParent; + bool _unknownPartNumber; + bool _unknownProductCode; + bool _unknownRecommendedMemory; + bool _unknownRequiredStorage; + bool _unknownSerialNumber; + bool _unknownVersion; + + [Parameter] + public ulong Id { get; set; } + + uint Distribution { - bool _addingCompany; - int? _addingCompanyId; - string _addingCompanyRoleId; - AuthenticationState _authState; - List _companies; - bool _creating; - CompanyBySoftwareVariantViewModel _currentCompanyBySoftwareVariant; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _deletingCompanyBySoftwareVariant; - bool _editing; - Modal _frmDelete; - bool _loaded; - SoftwareVariantViewModel _model; - List _roles; - bool _savingCompany; - List _softwareVariantCompanies; - List _softwareVariants; - List _softwareVersions; - bool _unknownCatalogueNumber; - bool _unknownIntroduced; - bool _unknownMinimumMemory; - bool _unknownName; - bool _unknownParent; - bool _unknownPartNumber; - bool _unknownProductCode; - bool _unknownRecommendedMemory; - bool _unknownRequiredStorage; - bool _unknownSerialNumber; - bool _unknownVersion; + get => (uint)_model.DistributionMode; + set => _model.DistributionMode = (DistributionMode)value; + } - [Parameter] - public ulong Id { get; set; } + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - uint Distribution + _loaded = true; + + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/software_variants/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _softwareVariants = await Service.GetAsync(); + _softwareVersions = await SoftwareVersionsService.GetAsync(); + _companies = await CompaniesService.GetAsync(); + _roles = await DocumentRolesService.GetEnabledAsync(); + _model = _creating ? new SoftwareVariantViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _addingCompanyRoleId = _roles.First().Id; + _softwareVariantCompanies = await CompaniesBySoftwareVariantService.GetBySoftwareVariant(Id); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/software_variants/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownName = string.IsNullOrWhiteSpace(_model.Name); + _unknownVersion = string.IsNullOrWhiteSpace(_model.Version); + _unknownParent = !_model.ParentId.HasValue; + _unknownMinimumMemory = !_model.MinimumMemory.HasValue; + _unknownRecommendedMemory = !_model.RecommendedMemory.HasValue; + _unknownRequiredStorage = !_model.RequiredStorage.HasValue; + _unknownPartNumber = string.IsNullOrWhiteSpace(_model.PartNumber); + _unknownSerialNumber = string.IsNullOrWhiteSpace(_model.SerialNumber); + _unknownProductCode = string.IsNullOrWhiteSpace(_model.ProductCode); + _unknownCatalogueNumber = string.IsNullOrWhiteSpace(_model.CatalogueNumber); + _unknownIntroduced = !_model.Introduced.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - get => (uint)_model.DistributionMode; - set => _model.DistributionMode = (DistributionMode)value; + NavigationManager.ToBaseRelativePath("admin/software_variants"); + + return; } - protected override async Task OnAfterRenderAsync(bool firstRender) + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownName) + _model.Name = null; + else if(string.IsNullOrWhiteSpace(_model.Name)) return; + + if(_unknownVersion) + _model.Version = null; + else if(string.IsNullOrWhiteSpace(_model.Version)) return; + + if(_unknownPartNumber) + _model.PartNumber = null; + else if(string.IsNullOrWhiteSpace(_model.PartNumber)) return; + + if(_unknownSerialNumber) + _model.SerialNumber = null; + else if(string.IsNullOrWhiteSpace(_model.SerialNumber)) return; + + if(_unknownProductCode) + _model.ProductCode = null; + else if(string.IsNullOrWhiteSpace(_model.ProductCode)) return; + + if(_unknownCatalogueNumber) + _model.CatalogueNumber = null; + else if(string.IsNullOrWhiteSpace(_model.CatalogueNumber)) return; + + if(_unknownParent) + _model.ParentId = null; + else if(_model.ParentId < 1) return; + + if(_unknownIntroduced) + _model.Introduced = null; + else if(_model.Introduced?.Date >= DateTime.UtcNow.Date) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Name must be smaller than 256 characters."], 256); + + void ValidateVersion(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Version must be smaller than 256 characters."], 256); + + void ValidatePartNumber(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Part number must be smaller than 256 characters."], 256); + + void ValidateSerialNumber(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Serial number must be smaller than 256 characters."], 256); + + void ValidateProductCode(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Product number must be smaller than 256 characters."], 256); + + void ValidateCatalogueNumber(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Catalogue number must be smaller than 256 characters."], 256); + + void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateDate(e); + + void ValidateUnsignedLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateUnsignedLong(e); + + void OnAddCompanyClick() + { + _addingCompany = true; + _savingCompany = false; + _addingCompanyId = _companies.First().Id; + } + + void CancelAddCompany() + { + _addingCompany = false; + _savingCompany = false; + _addingCompanyId = null; + } + + async Task ConfirmAddCompany() + { + if(_addingCompanyId is null || _addingCompanyId <= 0) { - if(_loaded) - return; + CancelAddCompany(); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/software_variants/create", - StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _softwareVariants = await Service.GetAsync(); - _softwareVersions = await SoftwareVersionsService.GetAsync(); - _companies = await CompaniesService.GetAsync(); - _roles = await DocumentRolesService.GetEnabledAsync(); - _model = _creating ? new SoftwareVariantViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _addingCompanyRoleId = _roles.First().Id; - _softwareVariantCompanies = await CompaniesBySoftwareVariantService.GetBySoftwareVariant(Id); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/software_variants/edit/", - StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() - { - _unknownName = string.IsNullOrWhiteSpace(_model.Name); - _unknownVersion = string.IsNullOrWhiteSpace(_model.Version); - _unknownParent = !_model.ParentId.HasValue; - _unknownMinimumMemory = !_model.MinimumMemory.HasValue; - _unknownRecommendedMemory = !_model.RecommendedMemory.HasValue; - _unknownRequiredStorage = !_model.RequiredStorage.HasValue; - _unknownPartNumber = string.IsNullOrWhiteSpace(_model.PartNumber); - _unknownSerialNumber = string.IsNullOrWhiteSpace(_model.SerialNumber); - _unknownProductCode = string.IsNullOrWhiteSpace(_model.ProductCode); - _unknownCatalogueNumber = string.IsNullOrWhiteSpace(_model.CatalogueNumber); - _unknownIntroduced = !_model.Introduced.HasValue; - } + _savingCompany = true; - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } + // Yield thread to let UI to update + await Task.Yield(); - async void OnCancelClicked() - { - _editing = false; + await CompaniesBySoftwareVariantService.CreateAsync(_addingCompanyId.Value, + Id, + _addingCompanyRoleId, + (await UserManager.GetUserAsync(_authState.User)).Id); - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/software_variants"); + _softwareVariantCompanies = await CompaniesBySoftwareVariantService.GetBySoftwareVariant(Id); - return; - } + _addingCompany = false; + _savingCompany = false; + _addingCompanyId = null; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + // Yield thread to let UI to update + await Task.Yield(); - async void OnSaveClicked() - { - if(_unknownName) - _model.Name = null; - else if(string.IsNullOrWhiteSpace(_model.Name)) - return; + // Tell we finished loading + StateHasChanged(); + } - if(_unknownVersion) - _model.Version = null; - else if(string.IsNullOrWhiteSpace(_model.Version)) - return; + void ShowCompanyDeleteModal(ulong itemId) + { + _currentCompanyBySoftwareVariant = _softwareVariantCompanies.FirstOrDefault(n => n.Id == itemId); + _deletingCompanyBySoftwareVariant = true; + _deleteTitle = L["Delete company from this software variant"]; - if(_unknownPartNumber) - _model.PartNumber = null; - else if(string.IsNullOrWhiteSpace(_model.PartNumber)) - return; + _deleteText = + string.Format(L["Are you sure you want to delete the company {0} with role {1} from this software variant?"], + _currentCompanyBySoftwareVariant?.Company, + _currentCompanyBySoftwareVariant?.Role); - if(_unknownSerialNumber) - _model.SerialNumber = null; - else if(string.IsNullOrWhiteSpace(_model.SerialNumber)) - return; + _frmDelete.Show(); + } - if(_unknownProductCode) - _model.ProductCode = null; - else if(string.IsNullOrWhiteSpace(_model.ProductCode)) - return; + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _deletingCompanyBySoftwareVariant = false; + _currentCompanyBySoftwareVariant = null; + } - if(_unknownCatalogueNumber) - _model.CatalogueNumber = null; - else if(string.IsNullOrWhiteSpace(_model.CatalogueNumber)) - return; + void HideModal() => _frmDelete.Hide(); - if(_unknownParent) - _model.ParentId = null; - else if(_model.ParentId < 1) - return; + async void ConfirmDelete() + { + if(_deletingCompanyBySoftwareVariant) await ConfirmDeleteCompanyByMachine(); + } - if(_unknownIntroduced) - _model.Introduced = null; - else if(_model.Introduced?.Date >= DateTime.UtcNow.Date) - return; + async Task ConfirmDeleteCompanyByMachine() + { + if(_currentCompanyBySoftwareVariant is null) return; - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + _deleteInProgress = true; - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + // Yield thread to let UI to update + await Task.Yield(); - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Name must be smaller than 256 characters."], 256); + await CompaniesBySoftwareVariantService.DeleteAsync(_currentCompanyBySoftwareVariant.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); - void ValidateVersion(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Version must be smaller than 256 characters."], 256); + _softwareVariantCompanies = await CompaniesBySoftwareVariantService.GetBySoftwareVariant(Id); - void ValidatePartNumber(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Part number must be smaller than 256 characters."], 256); + _deleteInProgress = false; + _frmDelete.Hide(); - void ValidateSerialNumber(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Serial number must be smaller than 256 characters."], 256); + // Yield thread to let UI to update + await Task.Yield(); - void ValidateProductCode(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Product number must be smaller than 256 characters."], 256); - - void ValidateCatalogueNumber(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Catalogue number must be smaller than 256 characters."], 256); - - void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateDate(e); - - void ValidateUnsignedLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateUnsignedLong(e); - - void OnAddCompanyClick() - { - _addingCompany = true; - _savingCompany = false; - _addingCompanyId = _companies.First().Id; - } - - void CancelAddCompany() - { - _addingCompany = false; - _savingCompany = false; - _addingCompanyId = null; - } - - async Task ConfirmAddCompany() - { - if(_addingCompanyId is null || - _addingCompanyId <= 0) - { - CancelAddCompany(); - - return; - } - - _savingCompany = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await CompaniesBySoftwareVariantService.CreateAsync(_addingCompanyId.Value, Id, _addingCompanyRoleId, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _softwareVariantCompanies = await CompaniesBySoftwareVariantService.GetBySoftwareVariant(Id); - - _addingCompany = false; - _savingCompany = false; - _addingCompanyId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ShowCompanyDeleteModal(ulong itemId) - { - _currentCompanyBySoftwareVariant = _softwareVariantCompanies.FirstOrDefault(n => n.Id == itemId); - _deletingCompanyBySoftwareVariant = true; - _deleteTitle = L["Delete company from this software variant"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the company {0} with role {1} from this software variant?"], - _currentCompanyBySoftwareVariant?.Company, _currentCompanyBySoftwareVariant?.Role); - - _frmDelete.Show(); - } - - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _deletingCompanyBySoftwareVariant = false; - _currentCompanyBySoftwareVariant = null; - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_deletingCompanyBySoftwareVariant) - await ConfirmDeleteCompanyByMachine(); - } - - async Task ConfirmDeleteCompanyByMachine() - { - if(_currentCompanyBySoftwareVariant is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await CompaniesBySoftwareVariantService.DeleteAsync(_currentCompanyBySoftwareVariant.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _softwareVariantCompanies = await CompaniesBySoftwareVariantService.GetBySoftwareVariant(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoftwareVersion.razor b/Marechai/Pages/Admin/Details/SoftwareVersion.razor index b41ad237..3c8b1745 100644 --- a/Marechai/Pages/Admin/Details/SoftwareVersion.razor +++ b/Marechai/Pages/Admin/Details/SoftwareVersion.razor @@ -31,19 +31,19 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject SoftwareFamiliesService SoftwareFamiliesService -@inject LicensesService LicensesService -@inject CompaniesService CompaniesService -@inject DocumentRolesService DocumentRolesService -@inject CompaniesBySoftwareVersionService CompaniesBySoftwareVersionService -@inject NavigationManager NavigationManager -@inject IWebHostEnvironment Host -@inject IJSRuntime JSRuntime -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject SoftwareFamiliesService SoftwareFamiliesService +@inject LicensesService LicensesService +@inject CompaniesService CompaniesService +@inject DocumentRolesService DocumentRolesService +@inject CompaniesBySoftwareVersionService CompaniesBySoftwareVersionService +@inject NavigationManager NavigationManager +@inject IWebHostEnvironment Host +@inject IJSRuntime JSRuntime +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Software version details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -54,10 +54,10 @@ @L["Software family"] @@ -77,9 +77,8 @@ @if(_editing) { @L["Unknown (name)"] -} - @if(!_editing || - !_unknownName) + } + @if(!_editing || !_unknownName) { @@ -88,9 +87,9 @@ -} + } -} + } @if(_editing || _model.Codename != null) { @@ -98,9 +97,8 @@ @if(_editing) { @L["Unknown (codename)"] -} - @if(!_editing || - !_unknownCodename) + } + @if(!_editing || !_unknownCodename) { @@ -109,9 +107,9 @@ -} + } -} + } @if(_editing || _model.Introduced != null) { @@ -119,9 +117,8 @@ @if(_editing) { @L["Unknown (introduction date)"] -} - @if(!_editing || - !_unknownIntroduced) + } + @if(!_editing || !_unknownIntroduced) { @@ -130,9 +127,9 @@ -} + } -} + } @if(_editing || _model.LicenseId != null) { @@ -140,19 +137,18 @@ @if(_editing) { @L["Unknown (license)"] -} - @if(!_editing || - !_unknownLicense) + } + @if(!_editing || !_unknownLicense) { -} + } -} + } @if(_editing || _model.PreviousId != null) { @@ -160,62 +156,65 @@ @if(_editing) { @L["Unknown or none (previous version)"] -} - @if(!_editing || - !_unknownPrevious) + } + @if(!_editing || !_unknownPrevious) { -} + } -} + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
@if(!_editing) { -
+

@L["Companies involved in this software version"]

+ + @if(_addingCompany) {
@L["Company"] @L["Role"]
} + @if(_softwareVersionCompanies?.Count > 0) {
@@ -232,7 +231,7 @@ - @foreach(var item in _softwareVersionCompanies) + @foreach(CompanyBySoftwareVersionViewModel item in _softwareVersionCompanies) { @@ -242,7 +241,8 @@ @item.Role - + } @@ -252,18 +252,20 @@ } - + @_deleteTitle - + @_deleteText - + - } \ No newline at end of file + +} \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoftwareVersion.razor.cs b/Marechai/Pages/Admin/Details/SoftwareVersion.razor.cs index dc5cff56..4cf44cae 100644 --- a/Marechai/Pages/Admin/Details/SoftwareVersion.razor.cs +++ b/Marechai/Pages/Admin/Details/SoftwareVersion.razor.cs @@ -33,256 +33,246 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class SoftwareVersion { - public partial class SoftwareVersion + bool _addingCompany; + int? _addingCompanyId; + string _addingCompanyRoleId; + AuthenticationState _authState; + List _companies; + bool _creating; + CompanyBySoftwareVersionViewModel _currentCompanyBySoftwareVersion; + bool _deleteInProgress; + string _deleteText; + string _deleteTitle; + bool _deletingCompanyBySoftwareVersion; + bool _editing; + Modal _frmDelete; + List _licenses; + bool _loaded; + SoftwareVersionViewModel _model; + List _roles; + bool _savingCompany; + List _softwareFamilies; + List _softwareVersionCompanies; + List _softwareVersions; + bool _unknownCodename; + bool _unknownIntroduced; + bool _unknownLicense; + bool _unknownName; + bool _unknownPrevious; + + [Parameter] + public ulong Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - bool _addingCompany; - int? _addingCompanyId; - string _addingCompanyRoleId; - AuthenticationState _authState; - List _companies; - bool _creating; - CompanyBySoftwareVersionViewModel _currentCompanyBySoftwareVersion; - bool _deleteInProgress; - string _deleteText; - string _deleteTitle; - bool _deletingCompanyBySoftwareVersion; - bool _editing; - Modal _frmDelete; - List _licenses; - bool _loaded; - SoftwareVersionViewModel _model; - List _roles; - bool _savingCompany; - List _softwareFamilies; - List _softwareVersionCompanies; - List _softwareVersions; - bool _unknownCodename; - bool _unknownIntroduced; - bool _unknownLicense; - bool _unknownName; - bool _unknownPrevious; + if(_loaded) return; - [Parameter] - public ulong Id { get; set; } + _loaded = true; - protected override async Task OnAfterRenderAsync(bool firstRender) + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/software_versions/create", StringComparison.InvariantCulture); + + if(Id <= 0 && !_creating) return; + + _softwareVersions = await Service.GetAsync(); + _softwareFamilies = await SoftwareFamiliesService.GetAsync(); + _licenses = await LicensesService.GetAsync(); + _companies = await CompaniesService.GetAsync(); + _roles = await DocumentRolesService.GetEnabledAsync(); + _model = _creating ? new SoftwareVersionViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _addingCompanyRoleId = _roles.First().Id; + _softwareVersionCompanies = await CompaniesBySoftwareVersionService.GetBySoftwareVersion(Id); + + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/software_versions/edit/", StringComparison.InvariantCulture); + + if(_editing) SetCheckboxes(); + + StateHasChanged(); + } + + void SetCheckboxes() + { + _unknownName = string.IsNullOrWhiteSpace(_model.Name); + _unknownCodename = string.IsNullOrWhiteSpace(_model.Codename); + _unknownLicense = !_model.LicenseId.HasValue; + _unknownIntroduced = !_model.Introduced.HasValue; + _unknownPrevious = !_model.PreviousId.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) { - if(_loaded) - return; + NavigationManager.ToBaseRelativePath("admin/software_versions"); - _loaded = true; - - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/software_versions/create", - StringComparison.InvariantCulture); - - if(Id <= 0 && - !_creating) - return; - - _softwareVersions = await Service.GetAsync(); - _softwareFamilies = await SoftwareFamiliesService.GetAsync(); - _licenses = await LicensesService.GetAsync(); - _companies = await CompaniesService.GetAsync(); - _roles = await DocumentRolesService.GetEnabledAsync(); - _model = _creating ? new SoftwareVersionViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _addingCompanyRoleId = _roles.First().Id; - _softwareVersionCompanies = await CompaniesBySoftwareVersionService.GetBySoftwareVersion(Id); - - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/software_versions/edit/", - StringComparison.InvariantCulture); - - if(_editing) - SetCheckboxes(); - - StateHasChanged(); + return; } - void SetCheckboxes() + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownName) + _model.Name = null; + else if(string.IsNullOrWhiteSpace(_model.Name)) return; + + if(_unknownCodename) + _model.Codename = null; + else if(string.IsNullOrWhiteSpace(_model.Codename)) return; + + if(_unknownLicense) + _model.LicenseId = null; + else if(_model.LicenseId < 1) return; + + if(_unknownPrevious) + _model.PreviousId = null; + else if(_model.PreviousId < 1) return; + + if(_unknownIntroduced) + _model.Introduced = null; + else if(_model.Introduced?.Date >= DateTime.UtcNow.Date) return; + + if(string.IsNullOrWhiteSpace(_model.Version)) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Name must be smaller than 256 characters."], 256); + + void ValidateCodename(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Codename must be smaller than 256 characters."], 256); + + void ValidateVersion(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Version must be smaller than 256 characters."], 256); + + void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateDate(e); + + void OnAddCompanyClick() + { + _addingCompany = true; + _savingCompany = false; + _addingCompanyId = _companies.First().Id; + } + + void CancelAddCompany() + { + _addingCompany = false; + _savingCompany = false; + _addingCompanyId = null; + } + + async Task ConfirmAddCompany() + { + if(_addingCompanyId is null || _addingCompanyId <= 0) { - _unknownName = string.IsNullOrWhiteSpace(_model.Name); - _unknownCodename = string.IsNullOrWhiteSpace(_model.Codename); - _unknownLicense = !_model.LicenseId.HasValue; - _unknownIntroduced = !_model.Introduced.HasValue; - _unknownPrevious = !_model.PreviousId.HasValue; + CancelAddCompany(); + + return; } - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } + _savingCompany = true; - async void OnCancelClicked() - { - _editing = false; + // Yield thread to let UI to update + await Task.Yield(); - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/software_versions"); + await CompaniesBySoftwareVersionService.CreateAsync(_addingCompanyId.Value, + Id, + _addingCompanyRoleId, + (await UserManager.GetUserAsync(_authState.User)).Id); - return; - } + _softwareVersionCompanies = await CompaniesBySoftwareVersionService.GetBySoftwareVersion(Id); - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + _addingCompany = false; + _savingCompany = false; + _addingCompanyId = null; - async void OnSaveClicked() - { - if(_unknownName) - _model.Name = null; - else if(string.IsNullOrWhiteSpace(_model.Name)) - return; + // Yield thread to let UI to update + await Task.Yield(); - if(_unknownCodename) - _model.Codename = null; - else if(string.IsNullOrWhiteSpace(_model.Codename)) - return; + // Tell we finished loading + StateHasChanged(); + } - if(_unknownLicense) - _model.LicenseId = null; - else if(_model.LicenseId < 1) - return; + void ShowCompanyDeleteModal(ulong itemId) + { + _currentCompanyBySoftwareVersion = _softwareVersionCompanies.FirstOrDefault(n => n.Id == itemId); + _deletingCompanyBySoftwareVersion = true; + _deleteTitle = L["Delete company from this software version"]; - if(_unknownPrevious) - _model.PreviousId = null; - else if(_model.PreviousId < 1) - return; + _deleteText = + string.Format(L["Are you sure you want to delete the company {0} with role {1} from this software version?"], + _currentCompanyBySoftwareVersion?.Company, + _currentCompanyBySoftwareVersion?.Role); - if(_unknownIntroduced) - _model.Introduced = null; - else if(_model.Introduced?.Date >= DateTime.UtcNow.Date) - return; + _frmDelete.Show(); + } - if(string.IsNullOrWhiteSpace(_model.Version)) - return; + void ModalClosing(ModalClosingEventArgs obj) + { + _deleteInProgress = false; + _deletingCompanyBySoftwareVersion = false; + _currentCompanyBySoftwareVersion = null; + } - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + void HideModal() => _frmDelete.Hide(); - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } + async void ConfirmDelete() + { + if(_deletingCompanyBySoftwareVersion) await ConfirmDeleteCompanyByMachine(); + } - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Name must be smaller than 256 characters."], 256); + async Task ConfirmDeleteCompanyByMachine() + { + if(_currentCompanyBySoftwareVersion is null) return; - void ValidateCodename(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Codename must be smaller than 256 characters."], 256); + _deleteInProgress = true; - void ValidateVersion(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Version must be smaller than 256 characters."], 256); + // Yield thread to let UI to update + await Task.Yield(); - void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateDate(e); + await CompaniesBySoftwareVersionService.DeleteAsync(_currentCompanyBySoftwareVersion.Id, + (await UserManager.GetUserAsync(_authState.User)).Id); - void OnAddCompanyClick() - { - _addingCompany = true; - _savingCompany = false; - _addingCompanyId = _companies.First().Id; - } + _softwareVersionCompanies = await CompaniesBySoftwareVersionService.GetBySoftwareVersion(Id); - void CancelAddCompany() - { - _addingCompany = false; - _savingCompany = false; - _addingCompanyId = null; - } + _deleteInProgress = false; + _frmDelete.Hide(); - async Task ConfirmAddCompany() - { - if(_addingCompanyId is null || - _addingCompanyId <= 0) - { - CancelAddCompany(); + // Yield thread to let UI to update + await Task.Yield(); - return; - } - - _savingCompany = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await CompaniesBySoftwareVersionService.CreateAsync(_addingCompanyId.Value, Id, _addingCompanyRoleId, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _softwareVersionCompanies = await CompaniesBySoftwareVersionService.GetBySoftwareVersion(Id); - - _addingCompany = false; - _savingCompany = false; - _addingCompanyId = null; - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ShowCompanyDeleteModal(ulong itemId) - { - _currentCompanyBySoftwareVersion = _softwareVersionCompanies.FirstOrDefault(n => n.Id == itemId); - _deletingCompanyBySoftwareVersion = true; - _deleteTitle = L["Delete company from this software version"]; - - _deleteText = - string.Format(L["Are you sure you want to delete the company {0} with role {1} from this software version?"], - _currentCompanyBySoftwareVersion?.Company, _currentCompanyBySoftwareVersion?.Role); - - _frmDelete.Show(); - } - - void ModalClosing(ModalClosingEventArgs obj) - { - _deleteInProgress = false; - _deletingCompanyBySoftwareVersion = false; - _currentCompanyBySoftwareVersion = null; - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_deletingCompanyBySoftwareVersion) - await ConfirmDeleteCompanyByMachine(); - } - - async Task ConfirmDeleteCompanyByMachine() - { - if(_currentCompanyBySoftwareVersion is null) - return; - - _deleteInProgress = true; - - // Yield thread to let UI to update - await Task.Yield(); - - await CompaniesBySoftwareVersionService.DeleteAsync(_currentCompanyBySoftwareVersion.Id, - (await UserManager.GetUserAsync(_authState.User)).Id); - - _softwareVersionCompanies = await CompaniesBySoftwareVersionService.GetBySoftwareVersion(Id); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } + // Tell we finished loading + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoundSynth.razor b/Marechai/Pages/Admin/Details/SoundSynth.razor index 51eaaa0b..3bd532d2 100644 --- a/Marechai/Pages/Admin/Details/SoundSynth.razor +++ b/Marechai/Pages/Admin/Details/SoundSynth.razor @@ -31,13 +31,13 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject CompaniesService CompaniesService -@inject NavigationManager NavigationManager -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject CompaniesService CompaniesService +@inject NavigationManager NavigationManager +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Sound synthesizer details"]

-
+
@if(!_loaded) {

@L["Loading..."]

@@ -52,19 +52,18 @@ @if(_editing) { @L["Unknown (company)"] -} - @if(!_editing || - !_unknownCompany) + } + @if(!_editing || !_unknownCompany) { -} + } -} + } @L["Name"] @@ -82,9 +81,8 @@ @if(_editing) { @L["Unknown (model code)"] -} - @if(!_editing || - !_unknownModelCode) + } + @if(!_editing || !_unknownModelCode) { @@ -93,20 +91,21 @@ -} + } -} + } @if(_editing || _model.Introduced.HasValue) { @L["Introduced"] @if(_editing) { - @L["Unknown (introduction date)"] + @L["Unknown (introduction date)"] + @L["Prototype"] -} - @if(!_editing || - !_prototype && !_unknownIntroduced) + } + @if(!_editing || !_prototype && !_unknownIntroduced) { @@ -115,9 +114,9 @@ -} + } -} + } @if(_editing || _model.Voices.HasValue) { @@ -125,9 +124,8 @@ @if(_editing) { @L["Unknown (voices)"] -} - @if(!_editing || - !_unknownVoices) + } + @if(!_editing || !_unknownVoices) { @@ -136,9 +134,9 @@ -} + } -} + } @if(_editing || _model.Frequency.HasValue) { @@ -146,9 +144,8 @@ @if(_editing) { @L["Unknown (sample rate)"] -} - @if(!_editing || - !_unknownSampleRate) + } + @if(!_editing || !_unknownSampleRate) { @@ -157,19 +154,19 @@ -} + } -} + } @if(_editing || _model.Depth.HasValue) { @L["Sample resolution (bits)"] @if(_editing) { - @L["Unknown (sample resolution)"] -} - @if(!_editing || - !_unknownSampleResolution) + @L["Unknown (sample resolution)"] + } + @if(!_editing || !_unknownSampleResolution) { @@ -178,19 +175,19 @@ -} + } -} + } @if(_editing || _model.SquareWave.HasValue) { @L["Square wave channels"] @if(_editing) { - @L["Unknown (square wave channels)"] -} - @if(!_editing || - !_unknownSquareWaveChannels) + @L["Unknown (square wave channels)"] + } + @if(!_editing || !_unknownSquareWaveChannels) { @@ -199,19 +196,19 @@ -} + } -} + } @if(_editing || _model.WhiteNoise.HasValue) { @L["White noise channels"] @if(_editing) { - @L["Unknown (white noise channels)"] -} - @if(!_editing || - !_unknownWhiteNoiseChannels) + @L["Unknown (white noise channels)"] + } + @if(!_editing || !_unknownWhiteNoiseChannels) { @@ -220,9 +217,9 @@ -} + } -} + } @if(_editing || _model.Type.HasValue) { @@ -230,9 +227,8 @@ @if(_editing) { @L["Unknown (type)"] -} - @if(!_editing || - !_unknownType) + } + @if(!_editing || !_unknownType) { @@ -241,19 +237,20 @@ -} + } -} + }
@if(!_editing) { -} + } else { + -} + } @L["Back to list"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoundSynth.razor.cs b/Marechai/Pages/Admin/Details/SoundSynth.razor.cs index 2658af50..3422e3e5 100644 --- a/Marechai/Pages/Admin/Details/SoundSynth.razor.cs +++ b/Marechai/Pages/Admin/Details/SoundSynth.razor.cs @@ -32,165 +32,153 @@ using Marechai.ViewModels; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin.Details +namespace Marechai.Pages.Admin.Details; + +public partial class SoundSynth { - public partial class SoundSynth + AuthenticationState _authState; + List _companies; + bool _creating; + bool _editing; + bool _loaded; + SoundSynthViewModel _model; + bool _prototype; + bool _unknownCompany; + bool _unknownIntroduced; + bool _unknownModelCode; + bool _unknownSampleRate; + bool _unknownSampleResolution; + bool _unknownSquareWaveChannels; + bool _unknownType; + bool _unknownVoices; + bool _unknownWhiteNoiseChannels; + [Parameter] + public int Id { get; set; } + + protected override async Task OnAfterRenderAsync(bool firstRender) { - AuthenticationState _authState; - List _companies; - bool _creating; - bool _editing; - bool _loaded; - SoundSynthViewModel _model; - bool _prototype; - bool _unknownCompany; - bool _unknownIntroduced; - bool _unknownModelCode; - bool _unknownSampleRate; - bool _unknownSampleResolution; - bool _unknownSquareWaveChannels; - bool _unknownType; - bool _unknownVoices; - bool _unknownWhiteNoiseChannels; - [Parameter] - public int Id { get; set; } + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; + _loaded = true; - _loaded = true; + _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/sound_synths/create", StringComparison.InvariantCulture); - _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/sound_synths/create", StringComparison.InvariantCulture); + if(Id <= 0 && !_creating) return; - if(Id <= 0 && - !_creating) - return; + _companies = await CompaniesService.GetAsync(); + _model = _creating ? new SoundSynthViewModel() : await Service.GetAsync(Id); + _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _companies = await CompaniesService.GetAsync(); - _model = _creating ? new SoundSynthViewModel() : await Service.GetAsync(Id); - _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + _editing = _creating || + NavigationManager.ToBaseRelativePath(NavigationManager.Uri) + .ToLowerInvariant() + .StartsWith("admin/sound_synths/edit/", StringComparison.InvariantCulture); - _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). - StartsWith("admin/sound_synths/edit/", - StringComparison.InvariantCulture); + if(_editing) SetCheckboxes(); - if(_editing) - SetCheckboxes(); - - StateHasChanged(); - } - - void SetCheckboxes() - { - _unknownCompany = !_model.CompanyId.HasValue; - _unknownModelCode = string.IsNullOrWhiteSpace(_model.ModelCode); - _unknownIntroduced = !_model.Introduced.HasValue; - _prototype = _model.Introduced?.Year == 1000; - _unknownVoices = !_model.Voices.HasValue; - _unknownSampleRate = !_model.Frequency.HasValue; - _unknownSampleResolution = !_model.Depth.HasValue; - _unknownSquareWaveChannels = !_model.SquareWave.HasValue; - _unknownWhiteNoiseChannels = !_model.WhiteNoise.HasValue; - _unknownType = !_model.Type.HasValue; - } - - void OnEditClicked() - { - _editing = true; - SetCheckboxes(); - StateHasChanged(); - } - - async void OnCancelClicked() - { - _editing = false; - - if(_creating) - { - NavigationManager.ToBaseRelativePath("admin/sound_synths"); - - return; - } - - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - async void OnSaveClicked() - { - if(_unknownCompany) - _model.CompanyId = null; - else if(_model.CompanyId < 0) - return; - - if(_unknownModelCode) - _model.ModelCode = null; - else if(string.IsNullOrWhiteSpace(_model.ModelCode)) - return; - - if(_unknownIntroduced) - _model.Introduced = null; - else if(_prototype) - _model.Introduced = new DateTime(1000, 1, 1); - else if(_model.Introduced >= DateTime.UtcNow.Date) - return; - - if(_unknownVoices) - _model.Voices = null; - else if(_model.Voices < 0) - return; - - if(_unknownSampleRate) - _model.Frequency = null; - else if(_model.Frequency < 0) - return; - - if(_unknownSampleResolution) - _model.Depth = null; - else if(_model.Depth < 0) - return; - - if(_unknownSquareWaveChannels) - _model.SquareWave = null; - else if(_model.SquareWave < 0) - return; - - if(_unknownWhiteNoiseChannels) - _model.WhiteNoise = null; - else if(_model.WhiteNoise < 0) - return; - - if(_unknownType) - _model.Type = null; - else if(_model.Type < 0) - return; - - if(_creating) - Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - else - await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); - - _editing = false; - _creating = false; - _model = await Service.GetAsync(Id); - SetCheckboxes(); - StateHasChanged(); - } - - void ValidateModelCode(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Model code must be 45 characters or less."], 45); - - void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); - - void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e); - - void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e); - - void ValidateName(ValidatorEventArgs e) => - Validators.ValidateString(e, L["Name must be 50 characters or less."], 50); + StateHasChanged(); } + + void SetCheckboxes() + { + _unknownCompany = !_model.CompanyId.HasValue; + _unknownModelCode = string.IsNullOrWhiteSpace(_model.ModelCode); + _unknownIntroduced = !_model.Introduced.HasValue; + _prototype = _model.Introduced?.Year == 1000; + _unknownVoices = !_model.Voices.HasValue; + _unknownSampleRate = !_model.Frequency.HasValue; + _unknownSampleResolution = !_model.Depth.HasValue; + _unknownSquareWaveChannels = !_model.SquareWave.HasValue; + _unknownWhiteNoiseChannels = !_model.WhiteNoise.HasValue; + _unknownType = !_model.Type.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + + if(_creating) + { + NavigationManager.ToBaseRelativePath("admin/sound_synths"); + + return; + } + + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownCompany) + _model.CompanyId = null; + else if(_model.CompanyId < 0) return; + + if(_unknownModelCode) + _model.ModelCode = null; + else if(string.IsNullOrWhiteSpace(_model.ModelCode)) return; + + if(_unknownIntroduced) + _model.Introduced = null; + else if(_prototype) + _model.Introduced = new DateTime(1000, 1, 1); + else if(_model.Introduced >= DateTime.UtcNow.Date) return; + + if(_unknownVoices) + _model.Voices = null; + else if(_model.Voices < 0) return; + + if(_unknownSampleRate) + _model.Frequency = null; + else if(_model.Frequency < 0) return; + + if(_unknownSampleResolution) + _model.Depth = null; + else if(_model.Depth < 0) return; + + if(_unknownSquareWaveChannels) + _model.SquareWave = null; + else if(_model.SquareWave < 0) return; + + if(_unknownWhiteNoiseChannels) + _model.WhiteNoise = null; + else if(_model.WhiteNoise < 0) return; + + if(_unknownType) + _model.Type = null; + else if(_model.Type < 0) return; + + if(_creating) + Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + else + await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); + + _editing = false; + _creating = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateModelCode(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Model code must be 45 characters or less."], 45); + + void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); + + void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e); + + void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e); + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Name must be 50 characters or less."], 50); } \ No newline at end of file diff --git a/Marechai/Pages/Admin/DocumentCompanies.razor b/Marechai/Pages/Admin/DocumentCompanies.razor index e2bdbc31..29067c54 100644 --- a/Marechai/Pages/Admin/DocumentCompanies.razor +++ b/Marechai/Pages/Admin/DocumentCompanies.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Document companies"]

@if(_companies is null) @@ -55,7 +55,7 @@ - @foreach(var item in _companies) + @foreach(DocumentCompanyViewModel item in _companies) { @@ -76,11 +76,11 @@ - + @L["Delete company"] - + @string.Format(L["Are you sure you want to delete the company {0}?"], _currentCompany?.Name) diff --git a/Marechai/Pages/Admin/DocumentCompanies.razor.cs b/Marechai/Pages/Admin/DocumentCompanies.razor.cs index a3afa0f8..c1d018f4 100644 --- a/Marechai/Pages/Admin/DocumentCompanies.razor.cs +++ b/Marechai/Pages/Admin/DocumentCompanies.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class DocumentCompanies { - public partial class DocumentCompanies + List _companies; + DocumentCompanyViewModel _currentCompany; + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - List _companies; - DocumentCompanyViewModel _currentCompany; - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _companies = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(int itemId) - { - _currentCompany = _companies.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentCompany is null) - return; - - _deleteInProgress = true; - _companies = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentCompany.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _companies = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentCompany = null; + _companies = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(int itemId) + { + _currentCompany = _companies.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentCompany is null) return; + + _deleteInProgress = true; + _companies = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentCompany.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _companies = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentCompany = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/DocumentPeople.razor b/Marechai/Pages/Admin/DocumentPeople.razor index 3db502a5..8307ac02 100644 --- a/Marechai/Pages/Admin/DocumentPeople.razor +++ b/Marechai/Pages/Admin/DocumentPeople.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Document companies"]

@if(_people is null) @@ -55,7 +55,7 @@ - @foreach(var item in _people) + @foreach(DocumentPersonViewModel item in _people) { @@ -76,11 +76,11 @@ - + @L["Delete person"] - + @string.Format(L["Are you sure you want to delete {0}?"], _person?.Name) diff --git a/Marechai/Pages/Admin/DocumentPeople.razor.cs b/Marechai/Pages/Admin/DocumentPeople.razor.cs index 649c8b0b..84b7fee5 100644 --- a/Marechai/Pages/Admin/DocumentPeople.razor.cs +++ b/Marechai/Pages/Admin/DocumentPeople.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class DocumentPeople { - public partial class DocumentPeople + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _people; + DocumentPersonViewModel _person; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _people; - DocumentPersonViewModel _person; + _person = _people.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _person = _people.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_person is null) return; - async void ConfirmDelete() - { - if(_person is null) - return; + _deleteInProgress = true; + _people = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _people = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_person.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _people = await Service.GetAsync(); - await Service.DeleteAsync(_person.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _people = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _person = null; - void ModalClosing(ModalClosingEventArgs obj) => _person = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _people = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _people = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Documents.razor b/Marechai/Pages/Admin/Documents.razor index cf27975a..d45d075f 100644 --- a/Marechai/Pages/Admin/Documents.razor +++ b/Marechai/Pages/Admin/Documents.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Documents"]

@if(_documents is null) @@ -61,7 +61,7 @@ - @foreach(var item in _documents) + @foreach(DocumentViewModel item in _documents) { @@ -86,11 +86,11 @@ - + @L["Delete document"] - + @string.Format(L["Are you sure you want to delete the document {0}?"], _currentDocument?.Title) diff --git a/Marechai/Pages/Admin/Documents.razor.cs b/Marechai/Pages/Admin/Documents.razor.cs index 3f2d76c2..a590e3d8 100644 --- a/Marechai/Pages/Admin/Documents.razor.cs +++ b/Marechai/Pages/Admin/Documents.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Documents { - public partial class Documents + DocumentViewModel _currentDocument; + bool _deleteInProgress; + List _documents; + Modal _frmDelete; + bool _loaded; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - DocumentViewModel _currentDocument; - bool _deleteInProgress; - List _documents; - Modal _frmDelete; - bool _loaded; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _documents = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(long itemId) - { - _currentDocument = _documents.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentDocument is null) - return; - - _deleteInProgress = true; - _documents = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentDocument.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _documents = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentDocument = null; + _documents = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(long itemId) + { + _currentDocument = _documents.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentDocument is null) return; + + _deleteInProgress = true; + _documents = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentDocument.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _documents = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentDocument = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Dumps.razor b/Marechai/Pages/Admin/Dumps.razor index 92d1428a..958abd3c 100644 --- a/Marechai/Pages/Admin/Dumps.razor +++ b/Marechai/Pages/Admin/Dumps.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Dumps"]

@if(_dumps is null) @@ -64,7 +64,7 @@ - @foreach(var item in _dumps) + @foreach(DumpViewModel item in _dumps) { @@ -92,11 +92,11 @@ - + @L["Delete dump"] - + @string.Format(L["Are you sure you want to delete the dump made by {0} on {1} for media titled {2}?"], _currentDump?.Dumper, _currentDump?.DumpDate.ToString() ?? L["Unknown (dump date)"], _currentDump?.MediaTitle) diff --git a/Marechai/Pages/Admin/Dumps.razor.cs b/Marechai/Pages/Admin/Dumps.razor.cs index 7de4ad6a..5e357c50 100644 --- a/Marechai/Pages/Admin/Dumps.razor.cs +++ b/Marechai/Pages/Admin/Dumps.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Dumps { - public partial class Dumps + DumpViewModel _currentDump; + bool _deleteInProgress; + List _dumps; + Modal _frmDelete; + bool _loaded; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - DumpViewModel _currentDump; - bool _deleteInProgress; - List _dumps; - Modal _frmDelete; - bool _loaded; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _dumps = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(ulong itemId) - { - _currentDump = _dumps.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentDump is null) - return; - - _deleteInProgress = true; - _dumps = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentDump.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _dumps = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentDump = null; + _dumps = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(ulong itemId) + { + _currentDump = _dumps.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentDump is null) return; + + _deleteInProgress = true; + _dumps = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentDump.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _dumps = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentDump = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Gpus.razor b/Marechai/Pages/Admin/Gpus.razor index b8dfb3ec..b6503eb2 100644 --- a/Marechai/Pages/Admin/Gpus.razor +++ b/Marechai/Pages/Admin/Gpus.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Graphics Processing Units"]

@if(_gpus is null) @@ -61,7 +61,7 @@ - @foreach(var item in _gpus) + @foreach(GpuViewModel item in _gpus) { @@ -86,11 +86,11 @@ - + @L["Delete GPU"] - + @string.Format(L["Are you sure you want to delete {0} {1}?"], _gpu?.Company, _gpu?.Name) diff --git a/Marechai/Pages/Admin/Gpus.razor.cs b/Marechai/Pages/Admin/Gpus.razor.cs index 625f5820..e4d4177b 100644 --- a/Marechai/Pages/Admin/Gpus.razor.cs +++ b/Marechai/Pages/Admin/Gpus.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Gpus { - public partial class Gpus + bool _deleteInProgress; + Modal _frmDelete; + GpuViewModel _gpu; + List _gpus; + bool _loaded; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - GpuViewModel _gpu; - List _gpus; - bool _loaded; + _gpu = _gpus.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _gpu = _gpus.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_gpu is null) return; - async void ConfirmDelete() - { - if(_gpu is null) - return; + _deleteInProgress = true; + _gpus = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _gpus = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_gpu.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _gpus = await Service.GetAsync(); - await Service.DeleteAsync(_gpu.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _gpus = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _gpu = null; - void ModalClosing(ModalClosingEventArgs obj) => _gpu = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _gpus = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _gpus = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/InstructionSetExtensions.razor b/Marechai/Pages/Admin/InstructionSetExtensions.razor index c028e03e..1867e996 100644 --- a/Marechai/Pages/Admin/InstructionSetExtensions.razor +++ b/Marechai/Pages/Admin/InstructionSetExtensions.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Instruction set extensions"]

@if(_extensions is null) @@ -52,7 +52,7 @@ - @foreach(var item in _extensions) + @foreach(InstructionSetExtension item in _extensions) { @@ -68,11 +68,11 @@ - + @L["Delete extension"] - + @string.Format(L["Are you sure you want to delete {0}?"], _extension?.Extension) diff --git a/Marechai/Pages/Admin/InstructionSetExtensions.razor.cs b/Marechai/Pages/Admin/InstructionSetExtensions.razor.cs index 074e413b..11257fe1 100644 --- a/Marechai/Pages/Admin/InstructionSetExtensions.razor.cs +++ b/Marechai/Pages/Admin/InstructionSetExtensions.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.Database.Models; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class InstructionSetExtensions { - public partial class InstructionSetExtensions + bool _deleteInProgress; + InstructionSetExtension _extension; + List _extensions; + Modal _frmDelete; + bool _loaded; + + void ShowModal(int itemId) { - bool _deleteInProgress; - InstructionSetExtension _extension; - List _extensions; - Modal _frmDelete; - bool _loaded; + _extension = _extensions.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _extension = _extensions.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_extension is null) return; - async void ConfirmDelete() - { - if(_extension is null) - return; + _deleteInProgress = true; + _extensions = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _extensions = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_extension.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _extensions = await Service.GetAsync(); - await Service.DeleteAsync(_extension.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _extensions = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _extension = null; - void ModalClosing(ModalClosingEventArgs obj) => _extension = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _extensions = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _extensions = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/InstructionSets.razor b/Marechai/Pages/Admin/InstructionSets.razor index f257f85b..887bb51e 100644 --- a/Marechai/Pages/Admin/InstructionSets.razor +++ b/Marechai/Pages/Admin/InstructionSets.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Instruction sets"]

@if(_instructionSets is null) @@ -52,7 +52,7 @@ - @foreach(var item in _instructionSets) + @foreach(InstructionSet item in _instructionSets) { @@ -68,11 +68,11 @@ - + @L["Delete instruction set"] - + @string.Format(L["Are you sure you want to delete {0}?"], _instructionSet?.Name) diff --git a/Marechai/Pages/Admin/InstructionSets.razor.cs b/Marechai/Pages/Admin/InstructionSets.razor.cs index 2ddbc6aa..778d3439 100644 --- a/Marechai/Pages/Admin/InstructionSets.razor.cs +++ b/Marechai/Pages/Admin/InstructionSets.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.Database.Models; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class InstructionSets { - public partial class InstructionSets + bool _deleteInProgress; + Modal _frmDelete; + InstructionSet _instructionSet; + List _instructionSets; + bool _loaded; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - InstructionSet _instructionSet; - List _instructionSets; - bool _loaded; + _instructionSet = _instructionSets.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _instructionSet = _instructionSets.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_instructionSet is null) return; - async void ConfirmDelete() - { - if(_instructionSet is null) - return; + _deleteInProgress = true; + _instructionSets = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _instructionSets = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_instructionSet.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _instructionSets = await Service.GetAsync(); - await Service.DeleteAsync(_instructionSet.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _instructionSets = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _instructionSet = null; - void ModalClosing(ModalClosingEventArgs obj) => _instructionSet = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _instructionSets = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _instructionSets = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Licenses.razor b/Marechai/Pages/Admin/Licenses.razor index 38c5d70e..2efeb30e 100644 --- a/Marechai/Pages/Admin/Licenses.razor +++ b/Marechai/Pages/Admin/Licenses.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Licenses"]

@if(_licenses is null) @@ -64,7 +64,7 @@ - @foreach(var item in _licenses) + @foreach(License item in _licenses) { @@ -97,11 +97,11 @@ - + @L["Delete license"] - + @string.Format(L["Are you sure you want to delete {0}?"], _license?.Name) diff --git a/Marechai/Pages/Admin/Licenses.razor.cs b/Marechai/Pages/Admin/Licenses.razor.cs index cf59a288..a284d970 100644 --- a/Marechai/Pages/Admin/Licenses.razor.cs +++ b/Marechai/Pages/Admin/Licenses.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.Database.Models; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Licenses { - public partial class Licenses + bool _deleteInProgress; + Modal _frmDelete; + License _license; + List _licenses; + bool _loaded; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - License _license; - List _licenses; - bool _loaded; + _license = _licenses.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _license = _licenses.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_license is null) return; - async void ConfirmDelete() - { - if(_license is null) - return; + _deleteInProgress = true; + _licenses = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _licenses = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_license.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _licenses = await Service.GetAsync(); - await Service.DeleteAsync(_license.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _licenses = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _license = null; - void ModalClosing(ModalClosingEventArgs obj) => _license = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _licenses = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _licenses = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/MachineFamilies.razor b/Marechai/Pages/Admin/MachineFamilies.razor index ca1ad5b0..44a7d61b 100644 --- a/Marechai/Pages/Admin/MachineFamilies.razor +++ b/Marechai/Pages/Admin/MachineFamilies.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Machine families"]

@if(_machineFamilies is null) @@ -55,7 +55,7 @@ - @foreach(var item in _machineFamilies) + @foreach(MachineFamilyViewModel item in _machineFamilies) { @@ -74,11 +74,11 @@ - + @L["Delete machine family"] - + @string.Format(L["Are you sure you want to delete {0} {1}?"], _machineFamily?.Company, _machineFamily?.Name) diff --git a/Marechai/Pages/Admin/MachineFamilies.razor.cs b/Marechai/Pages/Admin/MachineFamilies.razor.cs index cf1cf545..e86e9602 100644 --- a/Marechai/Pages/Admin/MachineFamilies.razor.cs +++ b/Marechai/Pages/Admin/MachineFamilies.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class MachineFamilies { - public partial class MachineFamilies + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _machineFamilies; + MachineFamilyViewModel _machineFamily; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _machineFamilies; - MachineFamilyViewModel _machineFamily; + _machineFamily = _machineFamilies.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _machineFamily = _machineFamilies.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_machineFamily is null) return; - async void ConfirmDelete() - { - if(_machineFamily is null) - return; + _deleteInProgress = true; + _machineFamilies = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _machineFamilies = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_machineFamily.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _machineFamilies = await Service.GetAsync(); - await Service.DeleteAsync(_machineFamily.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _machineFamilies = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _machineFamily = null; - void ModalClosing(ModalClosingEventArgs obj) => _machineFamily = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _machineFamilies = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _machineFamilies = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Machines.razor b/Marechai/Pages/Admin/Machines.razor index e396dd81..e2fa9ef0 100644 --- a/Marechai/Pages/Admin/Machines.razor +++ b/Marechai/Pages/Admin/Machines.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Machines"]

@if(_machines is null) @@ -67,7 +67,7 @@ - @foreach(var item in _machines) + @foreach(MachineViewModel item in _machines) { @@ -98,11 +98,11 @@ - + @L["Delete machine"] - + @string.Format(L["Are you sure you want to delete {0} {1}?"], _machine?.Company, _machine?.Name) diff --git a/Marechai/Pages/Admin/Machines.razor.cs b/Marechai/Pages/Admin/Machines.razor.cs index 5e67fe42..679341b2 100644 --- a/Marechai/Pages/Admin/Machines.razor.cs +++ b/Marechai/Pages/Admin/Machines.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Machines { - public partial class Machines + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + MachineViewModel _machine; + List _machines; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - MachineViewModel _machine; - List _machines; + _machine = _machines.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _machine = _machines.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_machine is null) return; - async void ConfirmDelete() - { - if(_machine is null) - return; + _deleteInProgress = true; + _machines = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _machines = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_machine.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _machines = await Service.GetAsync(); - await Service.DeleteAsync(_machine.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _machines = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _machine = null; - void ModalClosing(ModalClosingEventArgs obj) => _machine = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _machines = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _machines = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/MagazineIssues.razor b/Marechai/Pages/Admin/MagazineIssues.razor index 025c06a1..1df2cd07 100644 --- a/Marechai/Pages/Admin/MagazineIssues.razor +++ b/Marechai/Pages/Admin/MagazineIssues.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Magazine issues"]

@if(_magazineIssues is null) @@ -58,7 +58,7 @@ - @foreach(var item in _magazineIssues) + @foreach(MagazineIssueViewModel item in _magazineIssues) { @@ -80,11 +80,11 @@ - + @L["Delete magazine issue"] - + @string.Format(L["Are you sure you want to delete the magazine issue published on {0} for magazine {1} with caption {2}?"], _currentMagazineIssue?.Published, _currentMagazineIssue?.MagazineTitle, _currentMagazineIssue?.Caption) diff --git a/Marechai/Pages/Admin/MagazineIssues.razor.cs b/Marechai/Pages/Admin/MagazineIssues.razor.cs index 935cfc59..da824303 100644 --- a/Marechai/Pages/Admin/MagazineIssues.razor.cs +++ b/Marechai/Pages/Admin/MagazineIssues.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class MagazineIssues { - public partial class MagazineIssues + MagazineIssueViewModel _currentMagazineIssue; + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _magazineIssues; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - MagazineIssueViewModel _currentMagazineIssue; - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _magazineIssues; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _magazineIssues = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(long itemId) - { - _currentMagazineIssue = _magazineIssues.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentMagazineIssue is null) - return; - - _deleteInProgress = true; - _magazineIssues = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentMagazineIssue.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _magazineIssues = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentMagazineIssue = null; + _magazineIssues = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(long itemId) + { + _currentMagazineIssue = _magazineIssues.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentMagazineIssue is null) return; + + _deleteInProgress = true; + _magazineIssues = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentMagazineIssue.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _magazineIssues = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentMagazineIssue = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Magazines.razor b/Marechai/Pages/Admin/Magazines.razor index 08db329e..2ad13ca0 100644 --- a/Marechai/Pages/Admin/Magazines.razor +++ b/Marechai/Pages/Admin/Magazines.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Magazines"]

@if(_magazines is null) @@ -64,7 +64,7 @@ - @foreach(var item in _magazines) + @foreach(MagazineViewModel item in _magazines) { @@ -92,11 +92,11 @@ - + @L["Delete magazine"] - + @string.Format(L["Are you sure you want to delete the magazine {0}?"], _currentMagazine?.Title) diff --git a/Marechai/Pages/Admin/Magazines.razor.cs b/Marechai/Pages/Admin/Magazines.razor.cs index 52578854..2ec701a0 100644 --- a/Marechai/Pages/Admin/Magazines.razor.cs +++ b/Marechai/Pages/Admin/Magazines.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Magazines { - public partial class Magazines + MagazineViewModel _currentMagazine; + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _magazines; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - MagazineViewModel _currentMagazine; - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _magazines; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _magazines = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(long itemId) - { - _currentMagazine = _magazines.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentMagazine is null) - return; - - _deleteInProgress = true; - _magazines = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentMagazine.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _magazines = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentMagazine = null; + _magazines = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(long itemId) + { + _currentMagazine = _magazines.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentMagazine is null) return; + + _deleteInProgress = true; + _magazines = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentMagazine.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _magazines = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentMagazine = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/News.razor b/Marechai/Pages/Admin/News.razor index f1c55ffe..84e808d9 100644 --- a/Marechai/Pages/Admin/News.razor +++ b/Marechai/Pages/Admin/News.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["News"]

@if(_news is null) @@ -55,7 +55,7 @@ - @foreach(var item in _news) + @foreach(NewsViewModel item in _news) { @@ -75,11 +75,11 @@ - + @L["Delete news"] - + @string.Format(L["Are you sure you want to delete the news type {0} from {1} that affect artifact ID {2}?"], _currentNews?.Type, _currentNews?.Timestamp, _currentNews?.AffectedId) diff --git a/Marechai/Pages/Admin/News.razor.cs b/Marechai/Pages/Admin/News.razor.cs index 52c22b1f..125db1a2 100644 --- a/Marechai/Pages/Admin/News.razor.cs +++ b/Marechai/Pages/Admin/News.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class News { - public partial class News + NewsViewModel _currentNews; + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _news; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - NewsViewModel _currentNews; - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _news; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _news = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(int itemId) - { - _currentNews = _news.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentNews is null) - return; - - _deleteInProgress = true; - _news = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentNews.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _news = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentNews = null; + _news = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(int itemId) + { + _currentNews = _news.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentNews is null) return; + + _deleteInProgress = true; + _news = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentNews.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _news = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentNews = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/People.razor b/Marechai/Pages/Admin/People.razor index 146c41eb..939f825c 100644 --- a/Marechai/Pages/Admin/People.razor +++ b/Marechai/Pages/Admin/People.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["People"]

@if(_people is null) @@ -70,7 +70,7 @@ - @foreach(var item in _people) + @foreach(PersonViewModel item in _people) { @@ -110,11 +110,11 @@ - + @L["Delete person"] - + @string.Format(L["Are you sure you want to delete {0}?"], _person?.FullName) diff --git a/Marechai/Pages/Admin/People.razor.cs b/Marechai/Pages/Admin/People.razor.cs index 58148180..eb65b608 100644 --- a/Marechai/Pages/Admin/People.razor.cs +++ b/Marechai/Pages/Admin/People.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class People { - public partial class People + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _people; + PersonViewModel _person; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _people; - PersonViewModel _person; + _person = _people.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _person = _people.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_person is null) return; - async void ConfirmDelete() - { - if(_person is null) - return; + _deleteInProgress = true; + _people = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _people = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_person.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _people = await Service.GetAsync(); - await Service.DeleteAsync(_person.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _people = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _person = null; - void ModalClosing(ModalClosingEventArgs obj) => _person = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _people = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _people = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Processors.razor b/Marechai/Pages/Admin/Processors.razor index 6ac8bc5c..c372fcac 100644 --- a/Marechai/Pages/Admin/Processors.razor +++ b/Marechai/Pages/Admin/Processors.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Processors"]

@if(_processors is null) @@ -64,7 +64,7 @@ - @foreach(var item in _processors) + @foreach(ProcessorViewModel item in _processors) { @@ -92,11 +92,11 @@ - + @L["Delete processor"] - + @string.Format(L["Are you sure you want to delete {0}?"], _processor?.Name) diff --git a/Marechai/Pages/Admin/Processors.razor.cs b/Marechai/Pages/Admin/Processors.razor.cs index 22224bfb..c0faa292 100644 --- a/Marechai/Pages/Admin/Processors.razor.cs +++ b/Marechai/Pages/Admin/Processors.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Processors { - public partial class Processors + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + ProcessorViewModel _processor; + List _processors; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - ProcessorViewModel _processor; - List _processors; + _processor = _processors.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _processor = _processors.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_processor is null) return; - async void ConfirmDelete() - { - if(_processor is null) - return; + _deleteInProgress = true; + _processors = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _processors = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_processor.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _processors = await Service.GetAsync(); - await Service.DeleteAsync(_processor.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _processors = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _processor = null; - void ModalClosing(ModalClosingEventArgs obj) => _processor = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _processors = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _processors = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Resolutions.razor b/Marechai/Pages/Admin/Resolutions.razor index f1b13d8f..385eb6c3 100644 --- a/Marechai/Pages/Admin/Resolutions.razor +++ b/Marechai/Pages/Admin/Resolutions.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Resolutions"]

@if(_resolutions is null) @@ -67,7 +67,7 @@ - @foreach(var item in _resolutions) + @foreach(ResolutionViewModel item in _resolutions) { @@ -98,11 +98,11 @@ - + @L["Delete resolution"] - + @string.Format(L["Are you sure you want to delete resolution {0}?"], _resolution) diff --git a/Marechai/Pages/Admin/Resolutions.razor.cs b/Marechai/Pages/Admin/Resolutions.razor.cs index 06bafc93..e782c317 100644 --- a/Marechai/Pages/Admin/Resolutions.razor.cs +++ b/Marechai/Pages/Admin/Resolutions.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Resolutions { - public partial class Resolutions + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + ResolutionViewModel _resolution; + List _resolutions; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - ResolutionViewModel _resolution; - List _resolutions; + _resolution = _resolutions.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _resolution = _resolutions.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_resolution is null) return; - async void ConfirmDelete() - { - if(_resolution is null) - return; + _deleteInProgress = true; + _resolutions = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _resolutions = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_resolution.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _resolutions = await Service.GetAsync(); - await Service.DeleteAsync(_resolution.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _resolutions = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _resolution = null; - void ModalClosing(ModalClosingEventArgs obj) => _resolution = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _resolutions = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _resolutions = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Screens.razor b/Marechai/Pages/Admin/Screens.razor index 9c3bf167..c7d86f51 100644 --- a/Marechai/Pages/Admin/Screens.razor +++ b/Marechai/Pages/Admin/Screens.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Screens"]

@if(_screens is null) @@ -61,7 +61,7 @@ - @foreach(var item in _screens) + @foreach(ScreenViewModel item in _screens) { @@ -86,11 +86,11 @@ - + @L["Delete screen"] - + @string.Format(L["Are you sure you want to delete screen of {0}\" size with a resolution of {1} and type {2}?"], _screen?.Diagonal, _screen?.NativeResolution, _screen?.Type) diff --git a/Marechai/Pages/Admin/Screens.razor.cs b/Marechai/Pages/Admin/Screens.razor.cs index 114020e6..51541673 100644 --- a/Marechai/Pages/Admin/Screens.razor.cs +++ b/Marechai/Pages/Admin/Screens.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class Screens { - public partial class Screens + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + ScreenViewModel _screen; + List _screens; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - ScreenViewModel _screen; - List _screens; + _screen = _screens.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _screen = _screens.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_screen is null) return; - async void ConfirmDelete() - { - if(_screen is null) - return; + _deleteInProgress = true; + _screens = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _screens = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_screen.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _screens = await Service.GetAsync(); - await Service.DeleteAsync(_screen.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _screens = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _screen = null; - void ModalClosing(ModalClosingEventArgs obj) => _screen = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _screens = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _screens = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/SoftwareFamilies.razor b/Marechai/Pages/Admin/SoftwareFamilies.razor index 2b3a344e..182d0b99 100644 --- a/Marechai/Pages/Admin/SoftwareFamilies.razor +++ b/Marechai/Pages/Admin/SoftwareFamilies.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Software families"]

@if(_softwareFamilies is null) @@ -58,7 +58,7 @@ - @foreach(var item in _softwareFamilies) + @foreach(SoftwareFamilyViewModel item in _softwareFamilies) { @@ -80,11 +80,11 @@ - + @L["Delete software family"] - + @string.Format(L["Are you sure you want to delete the software family {0}?"], _currentSoftwareFamily?.Name) diff --git a/Marechai/Pages/Admin/SoftwareFamilies.razor.cs b/Marechai/Pages/Admin/SoftwareFamilies.razor.cs index 40894f60..0ff7db4a 100644 --- a/Marechai/Pages/Admin/SoftwareFamilies.razor.cs +++ b/Marechai/Pages/Admin/SoftwareFamilies.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class SoftwareFamilies { - public partial class SoftwareFamilies + SoftwareFamilyViewModel _currentSoftwareFamily; + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _softwareFamilies; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - SoftwareFamilyViewModel _currentSoftwareFamily; - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _softwareFamilies; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _softwareFamilies = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(ulong itemId) - { - _currentSoftwareFamily = _softwareFamilies.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentSoftwareFamily is null) - return; - - _deleteInProgress = true; - _softwareFamilies = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentSoftwareFamily.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _softwareFamilies = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentSoftwareFamily = null; + _softwareFamilies = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(ulong itemId) + { + _currentSoftwareFamily = _softwareFamilies.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentSoftwareFamily is null) return; + + _deleteInProgress = true; + _softwareFamilies = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentSoftwareFamily.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _softwareFamilies = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentSoftwareFamily = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/SoftwareVariants.razor b/Marechai/Pages/Admin/SoftwareVariants.razor index 4701d17e..c8f0188c 100644 --- a/Marechai/Pages/Admin/SoftwareVariants.razor +++ b/Marechai/Pages/Admin/SoftwareVariants.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Software variants"]

@if(_softwareVariants is null) @@ -64,7 +64,7 @@ - @foreach(var item in _softwareVariants) + @foreach(SoftwareVariantViewModel item in _softwareVariants) { @@ -92,11 +92,11 @@ - + @L["Delete software variant"] - + @string.Format(L["Are you sure you want to delete the software variant {0}?"], _currentSoftwareVariant?.Name ?? _currentSoftwareVariant?.Version) diff --git a/Marechai/Pages/Admin/SoftwareVariants.razor.cs b/Marechai/Pages/Admin/SoftwareVariants.razor.cs index 862ba206..18508164 100644 --- a/Marechai/Pages/Admin/SoftwareVariants.razor.cs +++ b/Marechai/Pages/Admin/SoftwareVariants.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class SoftwareVariants { - public partial class SoftwareVariants + SoftwareVariantViewModel _currentSoftwareVariant; + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _softwareVariants; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - SoftwareVariantViewModel _currentSoftwareVariant; - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _softwareVariants; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _softwareVariants = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(ulong itemId) - { - _currentSoftwareVariant = _softwareVariants.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentSoftwareVariant is null) - return; - - _deleteInProgress = true; - _softwareVariants = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentSoftwareVariant.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _softwareVariants = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentSoftwareVariant = null; + _softwareVariants = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(ulong itemId) + { + _currentSoftwareVariant = _softwareVariants.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentSoftwareVariant is null) return; + + _deleteInProgress = true; + _softwareVariants = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentSoftwareVariant.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _softwareVariants = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentSoftwareVariant = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/SoftwareVersions.razor b/Marechai/Pages/Admin/SoftwareVersions.razor index 6da31fdd..2da5a622 100644 --- a/Marechai/Pages/Admin/SoftwareVersions.razor +++ b/Marechai/Pages/Admin/SoftwareVersions.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Software versions"]

@if(_softwareVersions is null) @@ -64,7 +64,7 @@ - @foreach(var item in _softwareVersions) + @foreach(SoftwareVersionViewModel item in _softwareVersions) { @@ -92,11 +92,11 @@ - + @L["Delete software version"] - + @string.Format(L["Are you sure you want to delete the software version {0}?"], _currentSoftwareVersion?.Name ?? _currentSoftwareVersion?.Version) diff --git a/Marechai/Pages/Admin/SoftwareVersions.razor.cs b/Marechai/Pages/Admin/SoftwareVersions.razor.cs index 2f9f271f..a26307f3 100644 --- a/Marechai/Pages/Admin/SoftwareVersions.razor.cs +++ b/Marechai/Pages/Admin/SoftwareVersions.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class SoftwareVersions { - public partial class SoftwareVersions + SoftwareVersionViewModel _currentSoftwareVersion; + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + List _softwareVersions; + + protected override async Task OnAfterRenderAsync(bool firstRender) { - SoftwareVersionViewModel _currentSoftwareVersion; - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - List _softwareVersions; + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _softwareVersions = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } - - void ShowModal(ulong itemId) - { - _currentSoftwareVersion = _softwareVersions.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } - - void HideModal() => _frmDelete.Hide(); - - async void ConfirmDelete() - { - if(_currentSoftwareVersion is null) - return; - - _deleteInProgress = true; - _softwareVersions = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - // Yield thread to let UI to update - await Task.Yield(); - - await Service.DeleteAsync(_currentSoftwareVersion.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _softwareVersions = await Service.GetAsync(); - - _deleteInProgress = false; - _frmDelete.Hide(); - - // Yield thread to let UI to update - await Task.Yield(); - - // Tell we finished loading - StateHasChanged(); - } - - void ModalClosing(ModalClosingEventArgs obj) => _currentSoftwareVersion = null; + _softwareVersions = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } + + void ShowModal(ulong itemId) + { + _currentSoftwareVersion = _softwareVersions.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } + + void HideModal() => _frmDelete.Hide(); + + async void ConfirmDelete() + { + if(_currentSoftwareVersion is null) return; + + _deleteInProgress = true; + _softwareVersions = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + // Yield thread to let UI to update + await Task.Yield(); + + await Service.DeleteAsync(_currentSoftwareVersion.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _softwareVersions = await Service.GetAsync(); + + _deleteInProgress = false; + _frmDelete.Hide(); + + // Yield thread to let UI to update + await Task.Yield(); + + // Tell we finished loading + StateHasChanged(); + } + + void ModalClosing(ModalClosingEventArgs obj) => _currentSoftwareVersion = null; } \ No newline at end of file diff --git a/Marechai/Pages/Admin/SoundSynths.razor b/Marechai/Pages/Admin/SoundSynths.razor index 26146525..30e35cf9 100644 --- a/Marechai/Pages/Admin/SoundSynths.razor +++ b/Marechai/Pages/Admin/SoundSynths.razor @@ -29,8 +29,8 @@ @using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject UserManager UserManager -@inject AuthenticationStateProvider AuthenticationStateProvider +@inject UserManager UserManager +@inject AuthenticationStateProvider AuthenticationStateProvider @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Sound synthesizers"]

@if(_soundSynths is null) @@ -64,7 +64,7 @@ - @foreach(var item in _soundSynths) + @foreach(SoundSynthViewModel item in _soundSynths) { @@ -92,11 +92,11 @@ - + @L["Delete sound synthesizer"] - + @string.Format(L["Are you sure you want to delete {0} {1}?"], _soundSynth?.CompanyName, _soundSynth?.Name) diff --git a/Marechai/Pages/Admin/SoundSynths.razor.cs b/Marechai/Pages/Admin/SoundSynths.razor.cs index 4cf134cc..9d0856a6 100644 --- a/Marechai/Pages/Admin/SoundSynths.razor.cs +++ b/Marechai/Pages/Admin/SoundSynths.razor.cs @@ -30,59 +30,56 @@ using Blazorise; using Marechai.ViewModels; using Microsoft.AspNetCore.Components.Authorization; -namespace Marechai.Pages.Admin +namespace Marechai.Pages.Admin; + +public partial class SoundSynths { - public partial class SoundSynths + bool _deleteInProgress; + Modal _frmDelete; + bool _loaded; + SoundSynthViewModel _soundSynth; + List _soundSynths; + + void ShowModal(int itemId) { - bool _deleteInProgress; - Modal _frmDelete; - bool _loaded; - SoundSynthViewModel _soundSynth; - List _soundSynths; + _soundSynth = _soundSynths.FirstOrDefault(n => n.Id == itemId); + _frmDelete.Show(); + } - void ShowModal(int itemId) - { - _soundSynth = _soundSynths.FirstOrDefault(n => n.Id == itemId); - _frmDelete.Show(); - } + void HideModal() => _frmDelete.Hide(); - void HideModal() => _frmDelete.Hide(); + async void ConfirmDelete() + { + if(_soundSynth is null) return; - async void ConfirmDelete() - { - if(_soundSynth is null) - return; + _deleteInProgress = true; + _soundSynths = null; + AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - _deleteInProgress = true; - _soundSynths = null; - AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + await Service.DeleteAsync(_soundSynth.Id, (await UserManager.GetUserAsync(authState.User)).Id); + _soundSynths = await Service.GetAsync(); - await Service.DeleteAsync(_soundSynth.Id, (await UserManager.GetUserAsync(authState.User)).Id); - _soundSynths = await Service.GetAsync(); + _deleteInProgress = false; + _frmDelete.Hide(); - _deleteInProgress = false; - _frmDelete.Hide(); + // Yield thread to let UI to update + await Task.Yield(); - // Yield thread to let UI to update - await Task.Yield(); + // Tell we finished loading + StateHasChanged(); + } - // Tell we finished loading - StateHasChanged(); - } + void ModalClosing(ModalClosingEventArgs obj) => _soundSynth = null; - void ModalClosing(ModalClosingEventArgs obj) => _soundSynth = null; + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _soundSynths = await Service.GetAsync(); - _loaded = true; - StateHasChanged(); - } + _soundSynths = await Service.GetAsync(); + _loaded = true; + StateHasChanged(); } } \ No newline at end of file diff --git a/Marechai/Pages/Companies/Index.razor b/Marechai/Pages/Companies/Index.razor index be70de47..5c70dc03 100644 --- a/Marechai/Pages/Companies/Index.razor +++ b/Marechai/Pages/Companies/Index.razor @@ -30,7 +30,7 @@ @page "/companies/{StartingCharacter}" @inherits OwningComponentBase @inject IStringLocalizer L -@inject IWebHostEnvironment Host +@inject IWebHostEnvironment Host @if(_companies is null) { @@ -50,9 +50,10 @@ - + /assets/flags/countries/png/1x/@($"{CountryId:D3}").webp 3x"/> }

@@ -68,25 +69,27 @@ @if(_companies.Any()) {
- @string.Format(L["{0} companies found in the database."], _companies.Count()) -
+ @string.Format(L["{0} companies found in the database."], _companies.Count()) +
- @foreach(var company in _companies) + @foreach(CompanyViewModel company in _companies) {
- @if(company.LastLogo != null && - File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", company.LastLogo + ".svg"))) + @if(company.LastLogo != null && File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", company.LastLogo + ".svg"))) { - + /assets/logos/thumbs/png/3x/@(company.LastLogo).png 3x" style="max-height: 32px; max-width: 128px" + width="auto"/> } diff --git a/Marechai/Pages/Companies/Index.razor.cs b/Marechai/Pages/Companies/Index.razor.cs index 2ce5abc4..d0356f89 100644 --- a/Marechai/Pages/Companies/Index.razor.cs +++ b/Marechai/Pages/Companies/Index.razor.cs @@ -28,88 +28,74 @@ using System.Threading.Tasks; using Marechai.ViewModels; using Microsoft.AspNetCore.Components; -namespace Marechai.Pages.Companies +namespace Marechai.Pages.Companies; + +public partial class Index { - public partial class Index + char? _character; + List _companies; + int? _countryId; + string _countryName; + bool _loaded; + string _startingCharacter; + + [Parameter] + public int? CountryId { - char? _character; - List _companies; - int? _countryId; - string _countryName; - bool _loaded; - string _startingCharacter; - - [Parameter] - public int? CountryId + get => _countryId; + set { - get => _countryId; - set - { - if(_countryId == value) - return; + if(_countryId == value) return; - _countryId = value; - _loaded = false; - } - } - - [Parameter] - public string StartingCharacter - { - get => _startingCharacter; - set - { - if(_startingCharacter == value) - return; - - _startingCharacter = value; - _loaded = false; - } - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _character = null; - - if(!string.IsNullOrWhiteSpace(StartingCharacter) && - StartingCharacter.Length == 1) - { - _character = StartingCharacter[0]; - - // ToUpper() - if(_character >= 'a' && - _character <= 'z') - _character -= (char)32; - - // Check if not letter or number - if(_character < '0' || - (_character > '9' && _character < 'A') || - _character > 'Z') - _character = null; - } - - if(_character.HasValue) - _companies = await Service.GetCompaniesByLetterAsync(_character.Value); - - if(CountryId.HasValue && - _companies is null) - { - _countryName = await Service.GetCountryNameAsync(CountryId.Value); - - if(_countryName != null) - { - _companies = await Service.GetCompaniesByCountryAsync(CountryId.Value); - } - else - CountryId = null; - } - - _companies ??= await Service.GetAsync(); - _loaded = true; - StateHasChanged(); + _countryId = value; + _loaded = false; } } + + [Parameter] + public string StartingCharacter + { + get => _startingCharacter; + set + { + if(_startingCharacter == value) return; + + _startingCharacter = value; + _loaded = false; + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; + + _character = null; + + if(!string.IsNullOrWhiteSpace(StartingCharacter) && StartingCharacter.Length == 1) + { + _character = StartingCharacter[0]; + + // ToUpper() + if(_character >= 'a' && _character <= 'z') _character -= (char)32; + + // Check if not letter or number + if(_character < '0' || _character > '9' && _character < 'A' || _character > 'Z') _character = null; + } + + if(_character.HasValue) _companies = await Service.GetCompaniesByLetterAsync(_character.Value); + + if(CountryId.HasValue && _companies is null) + { + _countryName = await Service.GetCountryNameAsync(CountryId.Value); + + if(_countryName != null) + _companies = await Service.GetCompaniesByCountryAsync(CountryId.Value); + else + CountryId = null; + } + + _companies ??= await Service.GetAsync(); + _loaded = true; + StateHasChanged(); + } } \ No newline at end of file diff --git a/Marechai/Pages/Companies/View.razor b/Marechai/Pages/Companies/View.razor index 128e50cd..b5131470 100644 --- a/Marechai/Pages/Companies/View.razor +++ b/Marechai/Pages/Companies/View.razor @@ -28,10 +28,11 @@ @page "/company/{Id:int}" @using Marechai.Database +@using Marechai.Database.Models @inherits OwningComponentBase @inject IStringLocalizer L -@inject CompanyLogosService CompanyLogosService -@inject IWebHostEnvironment Host +@inject CompanyLogosService CompanyLogosService +@inject IWebHostEnvironment Host @if(!_loaded) { @@ -47,350 +48,413 @@ return; }
-

- @if(_company.LastLogo != null && - File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", _company.LastLogo + ".svg"))) - { - - - + @if(_company.LastLogo != null && File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", _company.LastLogo + ".svg"))) + { + + + - - - } -

-
-@if(_logos != null && - _logos.Count > 1) -{ -
- - @foreach(var logo in _logos.Where(logo => File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", logo.Guid + ".svg")))) - { - -
- - - + + } +

+
+ @if(_logos != null && _logos.Count > 1) + { +
+ + @foreach(CompanyLogo logo in _logos.Where(logo => File.Exists(Path.Combine(Host.WebRootPath, "assets/logos", logo.Guid + ".svg")))) + { + +
+ + + - - -
- @if(logo.Year.HasValue) - { -
@(string.Format(L["in use since {0}"], logo.Year))
+ /assets/logos/png/1x/@(logo.Guid).webp 3x" style="max-height: 256px; max-width: 256px" + width="auto"/> + +
+ @if(logo.Year.HasValue) + { +
@(string.Format(L["in use since {0}"], logo.Year))
+ } + } - -} - -
-} -
- - - - -@if(_company.Founded.HasValue) -{ - - - @if(_company.FoundedMonthIsUnknown) - { - + + } - else if(_company.FoundedDayIsUnknown) - { - - } - else - { - - } - -} -@if(!string.IsNullOrEmpty(_company.LegalName)) -{ - - - - -} - - - - - - - -@if(!string.IsNullOrEmpty(_company.Website) || - !string.IsNullOrEmpty(_company.Twitter) || - !string.IsNullOrEmpty(_company.Facebook)) -{ - - - - -} -
- @_company.Name -
@L["Founded"]@_company.Founded.Value.Year.@($"{_company.Founded.Value:Y}").@_company.Founded.Value.ToLongDateString().
@L["Legal name"]@_company.LegalName
@L["Country"] - @if(_company.Country != null) - { - - @if(File.Exists(Path.Combine(Host.WebRootPath, "assets/flags/countries", $"{_company.CountryId:D3}.svg"))) +
+ + + + + @if(_company.Founded.HasValue) { - - - + + @if(_company.FoundedMonthIsUnknown) + { + + } + else if(_company.FoundedDayIsUnknown) + { + + } + else + { + + } + + } + @if(!string.IsNullOrEmpty(_company.LegalName)) + { + + + + + } + + + - - - - @switch(_company.Status) - { - case CompanyStatus.Unknown: - - break; - case CompanyStatus.Active: - - break; - case CompanyStatus.Sold: - if(_company.Sold != null) - { - if(_soldTo != null) - { - - } - else - { - - } - } - else - { - if(_soldTo != null) - { + + + + @switch(_company.Status) + { + case CompanyStatus.Unknown: + + + break; + case CompanyStatus.Active: + + + break; + case CompanyStatus.Sold: + if(_company.Sold != null) + { + if(_soldTo != null) + { + + } + else + { + + } + } + else + { + if(_soldTo != null) + { + + } + else + { + + } + } + + break; + case CompanyStatus.Merged: + if(_company.Sold != null) + { + if(_soldTo != null) + { + + } + else + { + + } + } + else + { + if(_soldTo != null) + { + + } + else + { + + } + } + + break; + case CompanyStatus.Bankrupt: + if(_company.Sold != null) + { + + } + else + { + + } + + break; + case CompanyStatus.Defunct: + if(_company.Sold != null) + { + + } + else + { + + } + + break; + case CompanyStatus.Renamed: + if(_company.Sold != null) + { + if(_soldTo != null) + { + + } + else + { + + } + } + else + { + if(_soldTo != null) + { + + } + else + { + + } + } + + break; + default: + throw new ArgumentOutOfRangeException(); + } + + + - } - else + + @if(!string.IsNullOrEmpty(_company.Website) || !string.IsNullOrEmpty(_company.Twitter) || !string.IsNullOrEmpty(_company.Facebook)) { - + + + + } - } - break; - case CompanyStatus.Merged: - if(_company.Sold != null) - { - if(_soldTo != null) - { - - } - else - { - - } - } - else - { - if(_soldTo != null) - { - - } - else - { - - } - } - break; - case CompanyStatus.Bankrupt: - if(_company.Sold != null) - { - - } - else - { - - } - break; - case CompanyStatus.Defunct: - if(_company.Sold != null) - { - - } - else - { - - } - break; - case CompanyStatus.Renamed: - if(_company.Sold != null) - { - if(_soldTo != null) - { - - } - else - { - - } - } - else - { - if(_soldTo != null) - { - - } - else - { - - } - } - break; - default: - throw new ArgumentOutOfRangeException(); +
+ @_company.Name +
@L["Founded"]@_company.Founded.Value.Year.@($"{_company.Founded.Value:Y}").@_company.Founded.Value.ToLongDateString().
@L["Legal name"]@_company.LegalName
@L["Country"] + @if(_company.Country != null) + { + + @if(File.Exists(Path.Combine(Host.WebRootPath, "assets/flags/countries", $"{_company.CountryId:D3}.svg"))) + { + + + - - - } - @L[_company.Country] - - } - else - { - @L["Unknown (country)"] - } -
@L["Status"]@L["Current company status is unknown."]@L["Company is active."] - - @string.Format(L["Company sold to {0} on {1}."], _soldTo.Name, _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.Sold.Value.ToLongDateString()) - + /assets/flags/countries/png/1x/@($"{_company.CountryId:D3}").webp 3x"/> + + } + @L[_company.Country] + + } + else + { + @L["Unknown (country)"] + } @string.Format(L["Company sold on {0} to an unknown company."], _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.Sold.Value.ToLongDateString())
@L["Status"]@L["Current company status is unknown."]@L["Company is active."] + + @string.Format(L["Company sold to {0} on {1}."], + _soldTo.Name, + _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.Sold.Value.ToLongDateString()) + + @string.Format(L["Company sold on {0} to an unknown company."], + _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.Sold.Value.ToLongDateString()) + + @string.Format(L["Company sold to {0} on an unknown date."], _soldTo.Name) + + @L["Company was sold to an unknown company on an unknown date."] + @string.Format(L["Company merged on {0} to form {1}."], + _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.Sold.Value.ToLongDateString(), + _soldTo.Name) + @string.Format(L["Company merged on {0} to form an unknown company."], + _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.Sold.Value.ToLongDateString()) + @string.Format(L["Company merged on an unknown date to form {0}."], _soldTo.Name) + @L["Company merged to form an unknown company on an unknown date."]@string.Format(L["Company declared bankruptcy on {0}."], + _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.Sold.Value.ToLongDateString())@L["Company declared bankruptcy on an unknown date."]@string.Format(L["Company ceased operations on {0}."], + _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.Sold.Value.ToLongDateString())@L["Company ceased operations on an unknown date."] + @string.Format(L["Company renamed to {0} on {1}."], + _soldTo.Name, + _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.Sold.Value.ToLongDateString()) + @string.Format(L["Company was renamed on {0} to an unknown name."], + _company.SoldMonthIsUnknown + ? $"{_company.Sold.Value.Year}" + : _company.SoldDayIsUnknown + ? $"{_company.Sold.Value:Y}" + : _company.Sold.Value.ToLongDateString()) + + @string.Format(L["Company renamed to {0} on an unknown date."], _soldTo.Name) + + @L["Company renamed to an unknown name on an unknown date."]
@L["Address"] - - @string.Format(L["Company sold to {0} on an unknown date."], _soldTo.Name) - + @_company.Address +
+ @if(_company.City != _company.Province) + { + @_company.City +
+ } + @_company.PostalCode @_company.Province
@L["Company was sold to an unknown company on an unknown date."]
@L["Links"] + @if(!string.IsNullOrEmpty(_company.Website)) + { + @L["Website"] +
+ } + @if(!string.IsNullOrEmpty(_company.Twitter)) + { + Twitter +
+ } + @if(!string.IsNullOrEmpty(_company.Facebook)) + { + Facebook +
+ } +
- @string.Format(L["Company merged on {0} to form {1}."], _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.Sold.Value.ToLongDateString(), _soldTo.Name) - @string.Format(L["Company merged on {0} to form an unknown company."], _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.Sold.Value.ToLongDateString()) - @string.Format(L["Company merged on an unknown date to form {0}."], _soldTo.Name) - @L["Company merged to form an unknown company on an unknown date."]@string.Format(L["Company declared bankruptcy on {0}."], _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.Sold.Value.ToLongDateString())@L["Company declared bankruptcy on an unknown date."]@string.Format(L["Company ceased operations on {0}."], _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.Sold.Value.ToLongDateString())@L["Company ceased operations on an unknown date."] - @string.Format(L["Company renamed to {0} on {1}."], _soldTo.Name, _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.Sold.Value.ToLongDateString()) - @string.Format(L["Company was renamed on {0} to an unknown name."], _company.SoldMonthIsUnknown ? $"{_company.Sold.Value.Year}" : _company.SoldDayIsUnknown ? $"{_company.Sold.Value:Y}" : _company.Sold.Value.ToLongDateString()) - - @string.Format(L["Company renamed to {0} on an unknown date."], _soldTo.Name) - - @L["Company renamed to an unknown name on an unknown date."]
+
+ + @{ + // TODO: Accordion } -
@L["Address"] - @_company.Address -
- @if(_company.City != _company.Province) - { - @_company.City -
- } - @_company.PostalCode @_company.Province -
@L["Links"] - @if(!string.IsNullOrEmpty(_company.Website)) +
+
+ @if(_computers.Count > 0) { - @L["Website"] -
- } - @if(!string.IsNullOrEmpty(_company.Twitter)) - { - Twitter -
- } - @if(!string.IsNullOrEmpty(_company.Facebook)) - { - Facebook -
- } -
-
-
-@{ - // TODO: Accordion -} -
-
- @if(_computers.Count > 0) - { -
-
- -
-
-
-
- @foreach(var computer in _computers) - { - - @computer.Name - -
- } +
+
+ +
-
- } - else - { -
-
- -
-
- } - @if(_consoles.Count > 0) - { -
-
- -
-
-
-
- @foreach(var console in _consoles) - { - - @console.Name - -
- } +
+
+ @foreach(Machine computer in _computers) + { + + @computer.Name + +
+ } +
-
- } - else - { -
-
- -
-
- } + } + else + { +
+
+ +
+
+ } + @if(_consoles.Count > 0) + { +
+
+ +
+
+
+
+ @foreach(Machine console in _consoles) + { + + @console.Name + +
+ } +
+
+ } + else + { +
+
+ +
+
+ } +
-
-@if(_description != null) -{ -
-
- @((MarkupString)_description) -
-} + @if(_description != null) + { +
+
+ @((MarkupString)_description) +
+ }
\ No newline at end of file diff --git a/Marechai/Pages/Machines/View.razor.cs b/Marechai/Pages/Machines/View.razor.cs index 5037d13a..dd56255f 100644 --- a/Marechai/Pages/Machines/View.razor.cs +++ b/Marechai/Pages/Machines/View.razor.cs @@ -29,46 +29,43 @@ using System.Threading.Tasks; using Marechai.ViewModels; using Microsoft.AspNetCore.Components; -namespace Marechai.Pages.Machines +namespace Marechai.Pages.Machines; + +public partial class View { - public partial class View + bool[] _gpuVisible; + int _id; + bool _loaded; + MachineViewModel _machine; + List _photos; + bool[] _processorVisible; + bool[] _soundVisible; + + [Parameter] + public int Id { - bool[] _gpuVisible; - int _id; - bool _loaded; - MachineViewModel _machine; - List _photos; - bool[] _processorVisible; - bool[] _soundVisible; - - [Parameter] - public int Id + get => _id; + set { - get => _id; - set - { - if(_id == value) - return; + if(_id == value) return; - _id = value; - _loaded = false; - } - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if(_loaded) - return; - - _machine = await Service.GetMachine(Id); - - _processorVisible = new bool[_machine.Processors.Count]; - _gpuVisible = new bool[_machine.Gpus.Count]; - _soundVisible = new bool[_machine.SoundSynthesizers.Count]; - _photos = await MachinePhotosService.GetGuidsByMachineAsync(Id); - - _loaded = true; - StateHasChanged(); + _id = value; + _loaded = false; } } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if(_loaded) return; + + _machine = await Service.GetMachine(Id); + + _processorVisible = new bool[_machine.Processors.Count]; + _gpuVisible = new bool[_machine.Gpus.Count]; + _soundVisible = new bool[_machine.SoundSynthesizers.Count]; + _photos = await MachinePhotosService.GetGuidsByMachineAsync(Id); + + _loaded = true; + StateHasChanged(); + } } \ No newline at end of file diff --git a/Marechai/Pages/Shared/_Layout.cshtml b/Marechai/Pages/Shared/_Layout.cshtml index 5383be99..a04f11ac 100644 --- a/Marechai/Pages/Shared/_Layout.cshtml +++ b/Marechai/Pages/Shared/_Layout.cshtml @@ -26,28 +26,29 @@ // Copyright © 2003-2021 Natalia Portillo *******************************************************************************/ } -@inject IWebHostEnvironment Environment +@inject IWebHostEnvironment Environment @inject ICompositeViewEngine Engine - - + + @ViewData["Title"] - Marechai - - + +