Refactor and reorganize code.

This commit is contained in:
2020-02-10 22:44:18 +00:00
parent ed5aacd34e
commit da352de481
345 changed files with 15117 additions and 20198 deletions

View File

@@ -29,6 +29,7 @@
*******************************************************************************/
using System.ComponentModel.DataAnnotations;
// ReSharper disable UnusedMember.Global
// ReSharper disable InconsistentNaming
@@ -36,26 +37,17 @@ namespace Marechai.Database
{
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")]
Unknown = 0, [Display(Name = "Tested good")]
TestedGood = 1, [Display(Name = "Not tested")]
NotTested = 2, [Display(Name = "Tested bad")]
TestedBad = 3
}
@@ -243,22 +235,15 @@ namespace Marechai.Database
/// <summary>Pioneer LaserDisc</summary>
LD = 21,
/// <summary>Pioneer LaserDisc data</summary>
LDROM = 22,
LDROM2 = 23,
LVROM = 24,
MegaLD = 254,
LDROM = 22, LDROM2 = 23, LVROM = 24, MegaLD = 254,
/// <summary>Sony Hi-MD</summary>
HiMD = 26,
/// <summary>Sony MiniDisc</summary>
MD = 27,
MDData = 28,
MDData2 = 29,
MD = 27, MDData = 28, MDData2 = 29,
/// <summary>5.25", Phase-Change, 1834348 sectors, 8192 bytes/sector, Ultra Density Optical, ECMA-350, ISO 17345</summary>
UDO = 30,
/// <summary>5.25", Phase-Change, 3669724 sectors, 8192 bytes/sector, Ultra Density Optical 2, ECMA-380, ISO 11976</summary>
UDO2 = 31,
PlayStationMemoryCard = 32,
PlayStationMemoryCard2 = 33,
UDO2 = 31, PlayStationMemoryCard = 32, PlayStationMemoryCard2 = 33,
/// <summary>Sony PlayStation game CD</summary>
PS1CD = 34,
/// <summary>Sony PlayStation 2 game CD</summary>
@@ -286,8 +271,7 @@ namespace Marechai.Database
/// <summary>Sega Saturn disc</summary>
SATURNCD = 46,
/// <summary>Sega/Yamaha Gigabyte Disc</summary>
GDROM = 47,
SegaCard = 48,
GDROM = 47, SegaCard = 48,
/// <summary>PC-Engine / TurboGrafx cartridge</summary>
HuCard = 49,
/// <summary>PC-Engine / TurboGrafx CD</summary>
@@ -307,383 +291,212 @@ namespace Marechai.Database
/// <summary>3.5" floppy</summary>
Microfloppy = 57,
/// <summary>5.25", DS, ?D, ?? tracks, ?? spt, 512 bytes/sector, GCR, opposite side heads, aka Twiggy</summary>
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,
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,
/// <summary>3.5", 652 tracks, 2 sides, 512 bytes/sector, Floptical, ECMA-207, ISO 14169</summary>
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
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
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")]
Srgb = 1, [Display(Name = "Adobe RGB")]
AdobeRgb = 2, [Display(Name = "Wide Gamut RGB")]
WideGamutRgb = 4093, [Display(Name = "ICC Profile")]
IccProfile = 65534, [Display(Name = "Uncalibrated")]
Uncalibreated = 65535
}
public enum Contrast : ushort
{
Normal = 0,
Low = 1,
Hig = 2
Normal = 0, Low = 1, Hig = 2
}
public enum ExposureMode : ushort
{
Auto = 0,
Manual = 1,
[Display(Name = "Auto bracket")]
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")]
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")]
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")]
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")]
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")]
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
None = 1, Inches = 2, Centimeters = 3
}
public enum Saturation : ushort
{
Normal = 0,
Low = 1,
Hig = 2
Normal = 0, Low = 1, Hig = 2
}
public enum SceneCaptureType : ushort
{
Standard = 0,
Landscape = 1,
Portrait = 2,
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")]
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,
Unknown = 0, Macro = 1, Close = 2,
Distant = 3
}
public enum WhiteBalance : ushort
{
Auto = 0,
Manual = 1
Auto = 0, Manual = 1
}
public enum Sharpness : ushort
{
Normal = 0,
Low = 1,
Hig = 2
Normal = 0, Low = 1, Hig = 2
}
}

View File

@@ -41,9 +41,7 @@ namespace Marechai.Database
/// <summary>Last inserted row's ID</summary>
long LastInsertRowId { get; }
/// <summary>
/// Opens an existing database
/// </summary>
/// <summary>Opens an existing database</summary>
/// <param name="server">Server</param>
/// <param name="user">User</param>
/// <param name="database">Database name</param>
@@ -52,14 +50,10 @@ namespace Marechai.Database
/// <returns><c>true</c> if database opened correctly, <c>false</c> otherwise</returns>
bool OpenDb(string server, string user, string database, string password, ushort port);
/// <summary>
/// Closes the database
/// </summary>
/// <summary>Closes the database</summary>
void CloseDb();
/// <summary>
/// Gets a data adapter for the opened database
/// </summary>
/// <summary>Gets a data adapter for the opened database</summary>
/// <returns>Data adapter</returns>
IDbDataAdapter GetNewDataAdapter();

View File

@@ -38,287 +38,193 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("admins",
table => new
migrationBuilder.CreateTable("admins", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
user =
table.Column<string>("char(50)", nullable: false,
defaultValueSql: "''"),
password = table.Column<string>("char(50)", nullable: false,
defaultValueSql: "''")
}, constraints: table => { table.PrimaryKey("PK_admins", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
user = table.Column<string>("char(50)", nullable: false, defaultValueSql: "''"),
password = table.Column<string>("char(50)", nullable: false, defaultValueSql: "''")
}, constraints: table =>
{
table.PrimaryKey("PK_admins", x => x.id);
});
migrationBuilder.CreateTable("browser_tests",
table => new
migrationBuilder.CreateTable("browser_tests", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
user_agent =
table.Column<string>("varchar(128)", nullable: false,
defaultValueSql: "''"),
browser =
table.Column<string>("varchar(64)", nullable: false,
defaultValueSql: "''"),
version =
table.Column<string>("varchar(16)", nullable: false,
defaultValueSql: "''"),
os =
table.Column<string>("varchar(32)", nullable: false,
defaultValueSql: "''"),
platform =
table.Column<string>("varchar(8)", nullable: false,
defaultValueSql: "''"),
gif87 =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
gif89 =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
jpeg =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
png =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
pngt =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
agif =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
table =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
colors =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
js =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
frames =
table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'"),
flash = table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'")
}, constraints: table => { table.PrimaryKey("PK_browser_tests", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
user_agent = table.Column<string>("varchar(128)", nullable: false, defaultValueSql: "''"),
browser = table.Column<string>("varchar(64)", nullable: false, defaultValueSql: "''"),
version = table.Column<string>("varchar(16)", nullable: false, defaultValueSql: "''"),
os = table.Column<string>("varchar(32)", nullable: false, defaultValueSql: "''"),
platform = table.Column<string>("varchar(8)", nullable: false, defaultValueSql: "''"),
gif87 = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
gif89 = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
jpeg = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
png = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
pngt = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
agif = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
table = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
colors = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
js = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
frames = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'"),
flash = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'")
}, constraints: table =>
{
table.PrimaryKey("PK_browser_tests", x => x.id);
});
migrationBuilder.CreateTable("marechai_db",
table => new
migrationBuilder.CreateTable("marechai_db", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
version = table.Column<int>("int(11)", nullable: false),
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
version = table.Column<int>("int(11)"),
updated = table.Column<DateTimeOffset?>("timestamp", nullable: true,
defaultValueSql: "CURRENT_TIMESTAMP")
}, constraints: table => { table.PrimaryKey("PK_marechai_db", x => x.id); });
migrationBuilder.CreateTable("forbidden",
table => new
}, constraints: table =>
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
browser =
table.Column<string>("char(128)", nullable: false,
defaultValueSql: "''"),
date =
table.Column<string>("char(20)", nullable: false,
defaultValueSql: "''"),
ip = table.Column<string>("char(16)", nullable: false,
defaultValueSql: "''"),
referer = table.Column<string>("char(255)", nullable: false,
defaultValueSql: "''")
}, constraints: table => { table.PrimaryKey("PK_forbidden", x => x.id); });
table.PrimaryKey("PK_marechai_db", x => x.id);
});
migrationBuilder.CreateTable("instruction_set_extensions",
table => new
migrationBuilder.CreateTable("forbidden", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
extension = table.Column<string>("varchar(45)", nullable: false)
},
constraints: table =>
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
browser = table.Column<string>("char(128)", nullable: false, defaultValueSql: "''"),
date = table.Column<string>("char(20)", nullable: false, defaultValueSql: "''"),
ip = table.Column<string>("char(16)", nullable: false, defaultValueSql: "''"),
referer = table.Column<string>("char(255)", nullable: false, defaultValueSql: "''")
}, constraints: table =>
{
table.PrimaryKey("PK_forbidden", x => x.id);
});
migrationBuilder.CreateTable("instruction_set_extensions", table => new
{
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
extension = table.Column<string>("varchar(45)")
}, constraints: table =>
{
table.PrimaryKey("PK_instruction_set_extensions", x => x.id);
});
migrationBuilder.CreateTable("instruction_sets",
table => new
migrationBuilder.CreateTable("instruction_sets", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
instruction_set = table.Column<string>("varchar(45)", nullable: false)
},
constraints: table => { table.PrimaryKey("PK_instruction_sets", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
instruction_set = table.Column<string>("varchar(45)")
}, constraints: table =>
{
table.PrimaryKey("PK_instruction_sets", x => x.id);
});
migrationBuilder.CreateTable("iso3166_1_numeric",
table => new
migrationBuilder.CreateTable("iso3166_1_numeric", table => new
{
id = table.Column<short>("smallint(3)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
name = table.Column<string>("varchar(64)", nullable: false)
},
constraints: table =>
id = table.Column<short>("smallint(3)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
name = table.Column<string>("varchar(64)")
}, constraints: table =>
{
table.PrimaryKey("PK_iso3166_1_numeric", x => x.id);
});
migrationBuilder.CreateTable("log",
table => new
migrationBuilder.CreateTable("log", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
browser =
table.Column<string>("char(128)", nullable: false,
defaultValueSql: "''"),
ip =
table.Column<string>("char(16)", nullable: false,
defaultValueSql: "''"),
date =
table.Column<string>("char(20)", nullable: false,
defaultValueSql: "''"),
referer = table.Column<string>("char(255)", nullable: false,
defaultValueSql: "''")
}, constraints: table => { table.PrimaryKey("PK_log", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
browser = table.Column<string>("char(128)", nullable: false, defaultValueSql: "''"),
ip = table.Column<string>("char(16)", nullable: false, defaultValueSql: "''"),
date = table.Column<string>("char(20)", nullable: false, defaultValueSql: "''"),
referer = table.Column<string>("char(255)", nullable: false, defaultValueSql: "''")
}, constraints: table =>
{
table.PrimaryKey("PK_log", x => x.id);
});
migrationBuilder.CreateTable("money_donations",
table => new
migrationBuilder.CreateTable("money_donations", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
donator =
table.Column<string>("char(128)", nullable: false,
defaultValueSql: "''"),
quantity = table.Column<decimal>("decimal(11,2)", nullable: false,
defaultValueSql: "'0.00'")
},
constraints: table => { table.PrimaryKey("PK_money_donations", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
donator = table.Column<string>("char(128)", nullable: false, defaultValueSql: "''"),
quantity = table.Column<decimal>("decimal(11,2)", nullable: false, defaultValueSql: "'0.00'")
}, constraints: table =>
{
table.PrimaryKey("PK_money_donations", x => x.id);
});
migrationBuilder.CreateTable("news",
table => new
migrationBuilder.CreateTable("news", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
date =
table.Column<string>("char(20)", nullable: false,
defaultValueSql: "''"),
type =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
added_id = table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'")
}, constraints: table => { table.PrimaryKey("PK_news", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
date = table.Column<string>("char(20)", nullable: false, defaultValueSql: "''"),
type = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
added_id = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'")
}, constraints: table =>
{
table.PrimaryKey("PK_news", x => x.id);
});
migrationBuilder.CreateTable("owned_computers",
table => new
migrationBuilder.CreateTable("owned_computers", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
db_id =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
date =
table.Column<string>("varchar(20)", nullable: false,
defaultValueSql: "''"),
status =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
trade =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
boxed =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
manuals =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cpu1 =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
mhz1 =
table.Column<decimal>("decimal(10,0)", nullable: false,
defaultValueSql: "'0'"),
cpu2 =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
mhz2 =
table.Column<decimal>("decimal(10,0)", nullable: false,
defaultValueSql: "'0'"),
ram =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
vram =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
rigid =
table.Column<string>("varchar(64)", nullable: false,
defaultValueSql: "''"),
disk1 =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cap1 =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
disk2 =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cap2 = table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'")
},
constraints: table => { table.PrimaryKey("PK_owned_computers", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
db_id = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
date = table.Column<string>("varchar(20)", nullable: false, defaultValueSql: "''"),
status = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
trade = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
boxed = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
manuals = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cpu1 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
mhz1 = table.Column<decimal>("decimal(10,0)", nullable: false, defaultValueSql: "'0'"),
cpu2 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
mhz2 = table.Column<decimal>("decimal(10,0)", nullable: false, defaultValueSql: "'0'"),
ram = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
vram = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
rigid = table.Column<string>("varchar(64)", nullable: false, defaultValueSql: "''"),
disk1 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cap1 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
disk2 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cap2 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'")
}, constraints: table =>
{
table.PrimaryKey("PK_owned_computers", x => x.id);
});
migrationBuilder.CreateTable("owned_consoles",
table => new
migrationBuilder.CreateTable("owned_consoles", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
db_id =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
date =
table.Column<string>("char(20)", nullable: false,
defaultValueSql: "''"),
status =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
trade =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
boxed =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
manuals = table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'")
}, constraints: table => { table.PrimaryKey("PK_owned_consoles", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
db_id = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
date = table.Column<string>("char(20)", nullable: false, defaultValueSql: "''"),
status = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
trade = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
boxed = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
manuals = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'")
}, constraints: table =>
{
table.PrimaryKey("PK_owned_consoles", x => x.id);
});
migrationBuilder.CreateTable("resolutions",
table => new
migrationBuilder.CreateTable("resolutions", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
width =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
height =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
width = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
height = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
colors = table.Column<long>("bigint(20)", nullable: true),
palette = table.Column<long>("bigint(20)", nullable: true),
chars = table.Column<sbyte>("tinyint(1)", nullable: false,
defaultValueSql: "'0'")
}, constraints: table => { table.PrimaryKey("PK_resolutions", x => x.id); });
migrationBuilder.CreateTable("companies",
table => new
chars = table.Column<sbyte>("tinyint(1)", nullable: false, defaultValueSql: "'0'")
}, constraints: table =>
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
name =
table.Column<string>("varchar(128)", nullable: false,
defaultValueSql: "''"),
table.PrimaryKey("PK_resolutions", x => x.id);
});
migrationBuilder.CreateTable("companies", table => new
{
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
name = table.Column<string>("varchar(128)", nullable: false, defaultValueSql: "''"),
founded = table.Column<DateTime>("datetime", nullable: true),
website = table.Column<string>("varchar(255)", nullable: true),
twitter = table.Column<string>("varchar(45)", nullable: true),
@@ -329,100 +235,84 @@ namespace Marechai.Database.Migrations
city = table.Column<string>("varchar(80)", nullable: true),
province = table.Column<string>("varchar(80)", nullable: true),
postal_code = table.Column<string>("varchar(25)", nullable: true),
country = table.Column<short>("smallint(3)", nullable: true),
status = table.Column<int>("int(11)", nullable: false)
country = table.Column<short>("smallint(3)", nullable: true), status = table.Column<int>("int(11)")
}, constraints: table =>
{
table.PrimaryKey("PK_companies", x => x.id);
table.ForeignKey("fk_companies_country", x => x.country,
"iso3166_1_numeric", "id",
table.ForeignKey("fk_companies_country", x => x.country, "iso3166_1_numeric", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("fk_companies_sold_to", x => x.sold_to, "companies", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable("company_descriptions",
table => new
migrationBuilder.CreateTable("company_descriptions", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
company_id = table.Column<int>("int(11)", nullable: false),
text = table.Column<string>("text", nullable: true)
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
company_id = table.Column<int>("int(11)"), text = table.Column<string>("text", nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_company_descriptions", x => x.id);
table.ForeignKey("fk_company_id", x => x.id, "companies", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_company_id", x => x.id, "companies", "id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("company_logos",
table => new
migrationBuilder.CreateTable("company_logos", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
company_id = table.Column<int>("int(11)", nullable: false),
year = table.Column<int>("int(4)", nullable: true),
logo_guid = table.Column<string>("char(36)", nullable: false)
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
company_id = table.Column<int>("int(11)"), year = table.Column<int>("int(4)", nullable: true),
logo_guid = table.Column<string>("char(36)")
}, constraints: table =>
{
table.PrimaryKey("PK_company_logos",
x => new {x.id, x.company_id, x.logo_guid});
table.ForeignKey("fk_company_logos_company1", x => x.company_id,
"companies", "id", onDelete: ReferentialAction.Restrict);
table.PrimaryKey("PK_company_logos", x => new
{
x.id, x.company_id, x.logo_guid
});
migrationBuilder.CreateTable("gpus",
table => new
table.ForeignKey("fk_company_logos_company1", x => x.company_id, "companies", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable("gpus", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
name =
table.Column<string>("char(128)", nullable: false,
defaultValueSql: "''"),
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
name = table.Column<string>("char(128)", nullable: false, defaultValueSql: "''"),
company = table.Column<int>("int(11)", nullable: true),
model_code = table.Column<string>("varchar(45)", nullable: true),
introduced = table.Column<DateTime>("datetime", nullable: true),
package = table.Column<string>("varchar(45)", nullable: true),
process = table.Column<string>("varchar(45)", nullable: true),
process_nm = table.Column<float>(nullable: true),
die_size = table.Column<float>(nullable: true),
process_nm = table.Column<float>(nullable: true), die_size = table.Column<float>(nullable: true),
transistors = table.Column<long>("bigint(20)", nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_gpus", x => x.id);
table.ForeignKey("fk_gpus_company", x => x.company, "companies", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable("machine_families",
table => new
migrationBuilder.CreateTable("machine_families", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
company = table.Column<int>("int(11)", nullable: false),
name = table.Column<string>("varchar(255)", nullable: false)
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
company = table.Column<int>("int(11)"), name = table.Column<string>("varchar(255)")
}, constraints: table =>
{
table.PrimaryKey("PK_machine_families", x => x.id);
table.ForeignKey("fk_machine_families_company", x => x.company,
"companies", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_machine_families_company", x => x.company, "companies", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("processors",
table => new
migrationBuilder.CreateTable("processors", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
name =
table.Column<string>("char(50)", nullable: false,
defaultValueSql: "''"),
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
name = table.Column<string>("char(50)", nullable: false, defaultValueSql: "''"),
company = table.Column<int>("int(11)", nullable: true),
model_code = table.Column<string>("varchar(45)", nullable: true),
introduced = table.Column<DateTime>("datetime", nullable: true),
@@ -436,37 +326,30 @@ namespace Marechai.Database.Migrations
cores = table.Column<int>("int(11)", nullable: true),
threads_per_core = table.Column<int>("int(11)", nullable: true),
process = table.Column<string>("varchar(45)", nullable: true),
process_nm = table.Column<float>(nullable: true),
die_size = table.Column<float>(nullable: true),
process_nm = table.Column<float>(nullable: true), die_size = table.Column<float>(nullable: true),
transistors = table.Column<long>("bigint(20)", nullable: true),
data_bus = table.Column<int>("int(11)", nullable: true),
addr_bus = table.Column<int>("int(11)", nullable: true),
SIMD_registers = table.Column<int>("int(11)", nullable: true),
SIMD_size = table.Column<int>("int(11)", nullable: true),
L1_instruction = table.Column<float>(nullable: true),
L1_data = table.Column<float>(nullable: true),
L2 = table.Column<float>(nullable: true),
L3 = table.Column<float>(nullable: true)
L1_instruction = table.Column<float>(nullable: true), L1_data = table.Column<float>(nullable: true),
L2 = table.Column<float>(nullable: true), L3 = table.Column<float>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_processors", x => x.id);
table.ForeignKey("fk_processors_company", x => x.company, "companies",
"id", onDelete: ReferentialAction.Restrict);
table.ForeignKey("fk_processors_instruction_set", x => x.instruction_set,
"instruction_sets", "id",
table.ForeignKey("fk_processors_company", x => x.company, "companies", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("fk_processors_instruction_set", x => x.instruction_set, "instruction_sets", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable("sound_synths",
table => new
migrationBuilder.CreateTable("sound_synths", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
name =
table.Column<string>("char(50)", nullable: false,
defaultValueSql: "''"),
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
name = table.Column<string>("char(50)", nullable: false, defaultValueSql: "''"),
company = table.Column<int>("int(11)", nullable: true),
model_code = table.Column<string>("varchar(45)", nullable: true),
introduced = table.Column<DateTime>("datetime", nullable: true),
@@ -479,161 +362,148 @@ namespace Marechai.Database.Migrations
}, constraints: table =>
{
table.PrimaryKey("PK_sound_synths", x => x.id);
table.ForeignKey("fk_sound_synths_company", x => x.company, "companies",
"id", onDelete: ReferentialAction.Restrict);
table.ForeignKey("fk_sound_synths_company", x => x.company, "companies", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable("resolutions_by_gpu",
table => new
migrationBuilder.CreateTable("resolutions_by_gpu", table => new
{
gpu = table.Column<int>("int(11)", nullable: false),
resolution = table.Column<int>("int(11)", nullable: false),
id = table.Column<long>("bigint(20)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn)
gpu = table.Column<int>("int(11)"), resolution = table.Column<int>("int(11)"),
id = table.Column<long>("bigint(20)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
}, constraints: table =>
{
table.PrimaryKey("PK_resolutions_by_gpu", x => x.id);
table.ForeignKey("fk_resolutions_by_gpu_gpu", x => x.gpu, "gpus", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_resolutions_by_gpu_resolution", x => x.resolution,
"resolutions", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_resolutions_by_gpu_resolution", x => x.resolution, "resolutions", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("machines",
table => new
migrationBuilder.CreateTable("machines", table => new
{
id =
table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
company =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
name = table.Column<string>("varchar(255)", nullable: false),
type =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
company = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
name = table.Column<string>("varchar(255)"),
type = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
introduced = table.Column<DateTime>("datetime", nullable: true),
family = table.Column<int>("int(11)", nullable: true),
model = table.Column<string>("varchar(50)", nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_machines", x => x.id);
table.ForeignKey("fk_machines_company", x => x.company, "companies", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("fk_machines_family", x => x.family, "machine_families",
"id", onDelete: ReferentialAction.Restrict);
table.ForeignKey("fk_machines_family", x => x.family, "machine_families", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable("instruction_set_extensions_by_processor",
table => new
migrationBuilder.CreateTable("instruction_set_extensions_by_processor", table => new
{
id = table.Column<int>("int(11)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
processor_id = table.Column<int>("int(11)", nullable: false),
extension_id = table.Column<int>("int(11)", nullable: false)
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
processor_id = table.Column<int>("int(11)"), extension_id = table.Column<int>("int(11)")
}, constraints: table =>
{
table.PrimaryKey("PK_instruction_set_extensions_by_processor",
x => new {x.id, x.processor_id, x.extension_id});
table.ForeignKey("fk_extension_extension_id", x => x.extension_id,
"instruction_set_extensions", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("fk_extension_processor_id", x => x.processor_id,
"processors", "id", onDelete: ReferentialAction.Restrict);
table.PrimaryKey("PK_instruction_set_extensions_by_processor", x => new
{
x.id, x.processor_id, x.extension_id
});
migrationBuilder.CreateTable("gpus_by_machine",
table => new
table.ForeignKey("fk_extension_extension_id", x => x.extension_id, "instruction_set_extensions", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("fk_extension_processor_id", x => x.processor_id, "processors", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable("gpus_by_machine", table => new
{
gpu = table.Column<int>("int(11)", nullable: false),
machine = table.Column<int>("int(11)", nullable: false),
id = table.Column<long>("bigint(20)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn)
gpu = table.Column<int>("int(11)"), machine = table.Column<int>("int(11)"),
id = table.Column<long>("bigint(20)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
}, constraints: table =>
{
table.PrimaryKey("PK_gpus_by_machine", x => x.id);
table.ForeignKey("fk_gpus_by_machine_gpu", x => x.gpu, "gpus", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_gpus_by_machine_machine", x => x.machine, "machines",
"id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_gpus_by_machine_machine", x => x.machine, "machines", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("memory_by_machine",
table => new
migrationBuilder.CreateTable("memory_by_machine", table => new
{
machine = table.Column<int>("int(11)", nullable: false),
type =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
usage =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
machine = table.Column<int>("int(11)"),
type = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
usage = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
size = table.Column<long>("bigint(20)", nullable: true),
speed = table.Column<double>(nullable: true),
id = table.Column<long>("bigint(20)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn)
id = table.Column<long>("bigint(20)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
}, constraints: table =>
{
table.PrimaryKey("PK_memory_by_machine", x => x.id);
table.ForeignKey("fk_memory_by_machine_machine", x => x.machine,
"machines", "id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("processors_by_machine",
table => new
{
processor = table.Column<int>("int(11)", nullable: false),
machine = table.Column<int>("int(11)", nullable: false),
speed = table.Column<float>(nullable: true),
id = table.Column<long>("bigint(20)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn)
}, constraints: table =>
{
table.PrimaryKey("PK_processors_by_machine", x => x.id);
table.ForeignKey("fk_processors_by_machine_machine", x => x.machine,
"machines", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_processors_by_machine_processor", x => x.processor,
"processors", "id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("sound_by_machine",
table => new
{
sound_synth = table.Column<int>("int(11)", nullable: false),
machine = table.Column<int>("int(11)", nullable: false),
id = table.Column<long>("bigint(20)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn)
}, constraints: table =>
{
table.PrimaryKey("PK_sound_by_machine", x => x.id);
table.ForeignKey("fk_sound_by_machine_machine", x => x.machine, "machines",
"id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_sound_by_machine_sound_synth", x => x.sound_synth,
"sound_synths", "id",
table.ForeignKey("fk_memory_by_machine_machine", x => x.machine, "machines", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("storage_by_machine",
table => new
migrationBuilder.CreateTable("processors_by_machine", table => new
{
machine = table.Column<int>("int(11)", nullable: false),
type =
table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
@interface =
table.Column<int>(name: "interface", type: "int(11)", nullable: false,
processor = table.Column<int>("int(11)"), machine = table.Column<int>("int(11)"),
speed = table.Column<float>(nullable: true),
id = table.Column<long>("bigint(20)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
}, constraints: table =>
{
table.PrimaryKey("PK_processors_by_machine", x => x.id);
table.ForeignKey("fk_processors_by_machine_machine", x => x.machine, "machines", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_processors_by_machine_processor", x => x.processor, "processors", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("sound_by_machine", table => new
{
sound_synth = table.Column<int>("int(11)"), machine = table.Column<int>("int(11)"),
id = table.Column<long>("bigint(20)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
}, constraints: table =>
{
table.PrimaryKey("PK_sound_by_machine", x => x.id);
table.ForeignKey("fk_sound_by_machine_machine", x => x.machine, "machines", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_sound_by_machine_sound_synth", x => x.sound_synth, "sound_synths", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("storage_by_machine", table => new
{
machine = table.Column<int>("int(11)"),
type = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
@interface = table.Column<int>(name: "interface", type: "int(11)", nullable: false,
defaultValueSql: "'0'"),
capacity = table.Column<long>("bigint(20)", nullable: true),
id = table.Column<long>("bigint(20)", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn)
id = table.Column<long>("bigint(20)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
}, constraints: table =>
{
table.PrimaryKey("PK_storage_by_machine", x => x.id);
table.ForeignKey("fk_storage_by_machine_machine", x => x.machine,
"machines", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_storage_by_machine_machine", x => x.machine, "machines", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("idx_admins_user", "admins", "user");
@@ -876,13 +746,20 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("idx_resolutions_width", "resolutions", "width");
migrationBuilder.CreateIndex("idx_resolutions_resolution", "resolutions", new[] {"width", "height"});
migrationBuilder.CreateIndex("idx_resolutions_resolution", "resolutions", new[]
{
"width", "height"
});
migrationBuilder.CreateIndex("idx_resolutions_resolution_with_color", "resolutions",
new[] {"width", "height", "colors"});
migrationBuilder.CreateIndex("idx_resolutions_resolution_with_color", "resolutions", new[]
{
"width", "height", "colors"
});
migrationBuilder.CreateIndex("idx_resolutions_resolution_with_color_and_palette", "resolutions",
new[] {"width", "height", "colors", "palette"});
migrationBuilder.CreateIndex("idx_resolutions_resolution_with_color_and_palette", "resolutions", new[]
{
"width", "height", "colors", "palette"
});
migrationBuilder.CreateIndex("idx_resolutions_by_gpu_gpu", "resolutions_by_gpu", "gpu");

View File

@@ -4,14 +4,8 @@ namespace Marechai.Database.Migrations
{
public partial class BrowserTestFieldsAsBoolean : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) { }
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder) { }
}
}

View File

@@ -38,115 +38,109 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("AspNetRoles",
table => new
migrationBuilder.CreateTable("AspNetRoles", table => new
{
Id = table.Column<string>(nullable: false),
Name = table.Column<string>(maxLength: 256, nullable: true),
Id = table.Column<string>(), Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
}, constraints: table => { table.PrimaryKey("PK_AspNetRoles", x => x.Id); });
migrationBuilder.CreateTable("AspNetUsers",
table => new
}, constraints: table =>
{
Id = table.Column<string>(nullable: false),
UserName =
table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName =
table.Column<string>(maxLength: 256, nullable: true),
Email =
table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail =
table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable("AspNetUsers", table => new
{
Id = table.Column<string>(),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(), PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
PhoneNumber = table.Column<string>(nullable: true), PhoneNumberConfirmed = table.Column<bool>(),
TwoFactorEnabled = table.Column<bool>(),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false)
}, constraints: table => { table.PrimaryKey("PK_AspNetUsers", x => x.Id); });
migrationBuilder.CreateTable("AspNetRoleClaims",
table => new
LockoutEnabled = table.Column<bool>(), AccessFailedCount = table.Column<int>()
}, constraints: table =>
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable("AspNetRoleClaims", table => new
{
Id = table.Column<int>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(), ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey("FK_AspNetRoleClaims_AspNetRoles_RoleId", x => x.RoleId,
"AspNetRoles", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_AspNetRoleClaims_AspNetRoles_RoleId", x => x.RoleId, "AspNetRoles", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("AspNetUserClaims",
table => new
migrationBuilder.CreateTable("AspNetUserClaims", table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
Id = table.Column<int>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(), ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey("FK_AspNetUserClaims_AspNetUsers_UserId", x => x.UserId,
"AspNetUsers", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_AspNetUserClaims_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("AspNetUserLogins",
table => new
migrationBuilder.CreateTable("AspNetUserLogins", table => new
{
LoginProvider =
table.Column<string>(maxLength: 128, nullable: false),
ProviderKey =
table.Column<string>(maxLength: 128, nullable: false),
ProviderDisplayName = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false)
LoginProvider = table.Column<string>(maxLength: 128),
ProviderKey = table.Column<string>(maxLength: 128),
ProviderDisplayName = table.Column<string>(nullable: true), UserId = table.Column<string>()
}, constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins",
x => new {x.LoginProvider, x.ProviderKey});
table.ForeignKey("FK_AspNetUserLogins_AspNetUsers_UserId", x => x.UserId,
"AspNetUsers", "Id", onDelete: ReferentialAction.Cascade);
table.PrimaryKey("PK_AspNetUserLogins", x => new
{
x.LoginProvider, x.ProviderKey
});
migrationBuilder.CreateTable("AspNetUserRoles",
table => new
{
UserId = table.Column<string>(nullable: false),
RoleId = table.Column<string>(nullable: false)
}, constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new {x.UserId, x.RoleId});
table.ForeignKey("FK_AspNetUserRoles_AspNetRoles_RoleId", x => x.RoleId,
"AspNetRoles", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_AspNetUserRoles_AspNetUsers_UserId", x => x.UserId,
"AspNetUsers", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_AspNetUserLogins_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("AspNetUserTokens",
table => new
migrationBuilder.CreateTable("AspNetUserRoles", table => new
{
UserId = table.Column<string>(nullable: false),
LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
Name = table.Column<string>(maxLength: 128, nullable: false),
Value = table.Column<string>(nullable: true)
UserId = table.Column<string>(), RoleId = table.Column<string>()
}, constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens",
x => new {x.UserId, x.LoginProvider, x.Name});
table.ForeignKey("FK_AspNetUserTokens_AspNetUsers_UserId", x => x.UserId,
"AspNetUsers", "Id", onDelete: ReferentialAction.Cascade);
table.PrimaryKey("PK_AspNetUserRoles", x => new
{
x.UserId, x.RoleId
});
table.ForeignKey("FK_AspNetUserRoles_AspNetRoles_RoleId", x => x.RoleId, "AspNetRoles", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_AspNetUserRoles_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("AspNetUserTokens", table => new
{
UserId = table.Column<string>(), LoginProvider = table.Column<string>(maxLength: 128),
Name = table.Column<string>(maxLength: 128), Value = table.Column<string>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new
{
x.UserId, x.LoginProvider, x.Name
});
table.ForeignKey("FK_AspNetUserTokens_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_AspNetRoleClaims_RoleId", "AspNetRoleClaims", "RoleId");

View File

@@ -5,26 +5,20 @@ namespace Marechai.Database.Migrations
{
public partial class RemoveCompanyDescriptions : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("company_descriptions");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("company_descriptions",
table => new
migrationBuilder.CreateTable("company_descriptions", table => new
{
id = table.Column<int>("int(11)")
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
company_id = table.Column<int>("int(11)"),
text = table.Column<string>("text", nullable: true)
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
company_id = table.Column<int>("int(11)"), text = table.Column<string>("text", nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_company_descriptions", x => x.id);
table.ForeignKey("fk_company_id", x => x.id, "companies", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("fk_company_id", x => x.id, "companies", "id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("idx_company_id", "company_descriptions", "company_id", unique: true);

View File

@@ -7,28 +7,23 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("CompanyDescriptions",
table => new
migrationBuilder.CreateTable("CompanyDescriptions", table => new
{
Id = table.Column<int>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(),
Text = table.Column<string>(nullable: true)
Id = table.Column<int>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(), Text = table.Column<string>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_CompanyDescriptions", x => x.Id);
table.ForeignKey("FK_CompanyDescriptions_companies_CompanyId",
x => x.CompanyId, "companies", "id",
table.ForeignKey("FK_CompanyDescriptions_companies_CompanyId", x => x.CompanyId, "companies", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_CompanyDescriptions_CompanyId", "CompanyDescriptions", "CompanyId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("CompanyDescriptions");
}
}
}

View File

@@ -9,8 +9,8 @@ namespace Marechai.Database.Migrations
migrationBuilder.AlterColumn<string>("Text", "CompanyDescriptions", nullable: true,
oldClrType: typeof(string), oldNullable: true);
migrationBuilder.CreateIndex("IX_CompanyDescriptions_Text", "CompanyDescriptions", "Text")
.Annotation("MySql:FullTextIndex", true);
migrationBuilder.CreateIndex("IX_CompanyDescriptions_Text", "CompanyDescriptions", "Text").
Annotation("MySql:FullTextIndex", true);
}
protected override void Down(MigrationBuilder migrationBuilder)

View File

@@ -4,16 +4,12 @@ namespace Marechai.Database.Migrations
{
public partial class AnnotateCompanyDescription : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<string>("Text", "CompanyDescriptions", maxLength: 262144, nullable: true,
oldClrType: typeof(string), oldNullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<string>("Text", "CompanyDescriptions", nullable: true,
oldClrType: typeof(string), oldMaxLength: 262144, oldNullable: true);
}
}
}

View File

@@ -4,14 +4,10 @@ namespace Marechai.Database.Migrations
{
public partial class AddPreRenderedCompanyDescription : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.AddColumn<string>("Html", "CompanyDescriptions", maxLength: 262144, nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropColumn("Html", "CompanyDescriptions");
}
}
}

View File

@@ -5,17 +5,13 @@ namespace Marechai.Database.Migrations
{
public partial class NewsDateAsDateTime : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<DateTime>("date", "news", "datetime", nullable: false,
oldClrType: typeof(string), oldType: "char(20)",
oldDefaultValueSql: "''");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<string>("date", "news", "char(20)", nullable: false, defaultValueSql: "''",
oldClrType: typeof(DateTime), oldType: "datetime");
}
}
}

View File

@@ -5,25 +5,20 @@ namespace Marechai.Database.Migrations
{
public partial class DropOldAdminsTable : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("admins");
}
protected override void Up(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("admins");
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("admins",
table => new
migrationBuilder.CreateTable("admins", table => new
{
id = table.Column<int>("int(11)")
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
password =
table.Column<string>("char(50)", nullable: false,
defaultValueSql: "''"),
user = table.Column<string>("char(50)", nullable: false,
defaultValueSql: "''")
}, constraints: table => { table.PrimaryKey("PK_admins", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
password = table.Column<string>("char(50)", nullable: false, defaultValueSql: "''"),
user = table.Column<string>("char(50)", nullable: false, defaultValueSql: "''")
}, constraints: table =>
{
table.PrimaryKey("PK_admins", x => x.id);
});
migrationBuilder.CreateIndex("idx_admins_user", "admins", "user");
}

View File

@@ -4,14 +4,10 @@ namespace Marechai.Database.Migrations
{
public partial class GrayscaleResolutions : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.AddColumn<bool>("Grayscale", "resolutions", nullable: false, defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropColumn("Grayscale", "resolutions");
}
}
}

View File

@@ -4,27 +4,12 @@ namespace Marechai.Database.Migrations
{
public partial class DataAnnotations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "CompanyDescriptions",
maxLength: 262144,
nullable: false,
oldClrType: typeof(string),
oldMaxLength: 262144,
oldNullable: true);
}
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<string>("Text", "CompanyDescriptions", maxLength: 262144, nullable: false,
oldClrType: typeof(string), oldMaxLength: 262144, oldNullable: true);
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Text",
table: "CompanyDescriptions",
maxLength: 262144,
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 262144);
}
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<string>("Text", "CompanyDescriptions", maxLength: 262144, nullable: true,
oldClrType: typeof(string), oldMaxLength: 262144);
}
}

View File

@@ -10,11 +10,9 @@ namespace Marechai.Database.Migrations
{
migrationBuilder.AddColumn<string>("Discriminator", "AspNetUsers", nullable: false, defaultValue: "");
migrationBuilder.CreateTable("MachinePhotos",
table => new
migrationBuilder.CreateTable("MachinePhotos", table => new
{
Id = table.Column<Guid>(),
Author = table.Column<string>(nullable: true),
Id = table.Column<Guid>(), Author = table.Column<string>(nullable: true),
CameraManufacturer = table.Column<string>(nullable: true),
CameraModel = table.Column<string>(nullable: true),
ColorSpace = table.Column<string>(nullable: true),
@@ -45,9 +43,8 @@ namespace Marechai.Database.Migrations
Sharpness = table.Column<string>(nullable: true),
SoftwareUsed = table.Column<string>(nullable: true),
SubjectDistanceRange = table.Column<string>(nullable: true),
UploadDate =
table.Column<DateTime>()
.Annotation("MySql:ValueGenerationStrategy",
UploadDate = table.Column<DateTime>().
Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.ComputedColumn),
VerticalResolution = table.Column<int>(nullable: true),
WhiteBalance = table.Column<string>(nullable: true),
@@ -56,10 +53,12 @@ namespace Marechai.Database.Migrations
}, constraints: table =>
{
table.PrimaryKey("PK_MachinePhotos", x => x.Id);
table.ForeignKey("FK_MachinePhotos_machines_MachineId", x => x.MachineId,
"machines", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_MachinePhotos_AspNetUsers_UserId", x => x.UserId,
"AspNetUsers", "Id", onDelete: ReferentialAction.SetNull);
table.ForeignKey("FK_MachinePhotos_machines_MachineId", x => x.MachineId, "machines", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_MachinePhotos_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateIndex("IX_MachinePhotos_Author", "MachinePhotos", "Author");

File diff suppressed because it is too large Load Diff

View File

@@ -4,15 +4,11 @@ namespace Marechai.Database.Migrations
{
public partial class MachinePhotoForeignKeys : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<int>("MachineId", "MachinePhotos", nullable: false, oldClrType: typeof(int),
oldNullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<int>("MachineId", "MachinePhotos", nullable: true, oldClrType: typeof(int));
}
}
}

View File

@@ -4,16 +4,12 @@ namespace Marechai.Database.Migrations
{
public partial class ChangeMachinePhotoSharpnessTypeToExifType : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<ushort>("Sharpness", "MachinePhotos", nullable: true,
oldClrType: typeof(string), oldNullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.AlterColumn<string>("Sharpness", "MachinePhotos", nullable: true,
oldClrType: typeof(ushort), oldNullable: true);
}
}
}

View File

@@ -4,14 +4,10 @@ namespace Marechai.Database.Migrations
{
public partial class AddMachinePhotoSourceUrl : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) =>
migrationBuilder.AddColumn<string>("Source", "MachinePhotos", nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropColumn("Source", "MachinePhotos");
}
}
}

View File

@@ -8,76 +8,61 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("OwnedMachines",
table => new
migrationBuilder.CreateTable("OwnedMachines", table => new
{
Id =
table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
AcquisitionDate = table.Column<DateTime>(),
LostDate = table.Column<DateTime>(nullable: true),
Status = table.Column<int>(),
LastStatusDate = table.Column<DateTime>(nullable: true),
Trade = table.Column<bool>(),
Boxed = table.Column<bool>(),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
AcquisitionDate = table.Column<DateTime>(), LostDate = table.Column<DateTime>(nullable: true),
Status = table.Column<int>(), LastStatusDate = table.Column<DateTime>(nullable: true),
Trade = table.Column<bool>(), Boxed = table.Column<bool>(),
Manuals = table.Column<bool>(),
SerialNumber = table.Column<string>(nullable: true),
SerialNumberVisible =
table.Column<bool>(nullable: false, defaultValue: true),
MachineId = table.Column<int>(),
UserId = table.Column<string>(nullable: true)
SerialNumberVisible = table.Column<bool>(nullable: false, defaultValue: true),
MachineId = table.Column<int>(), UserId = table.Column<string>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_OwnedMachines", x => x.Id);
table.ForeignKey("FK_OwnedMachines_machines_MachineId", x => x.MachineId,
"machines", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_OwnedMachines_AspNetUsers_UserId", x => x.UserId,
"AspNetUsers", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_OwnedMachines_machines_MachineId", x => x.MachineId, "machines", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_OwnedMachines_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("GpusByOwnedMachine",
table => new
migrationBuilder.CreateTable("GpusByOwnedMachine", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
GpuId = table.Column<int>(),
OwnedMachineId = table.Column<long>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
GpuId = table.Column<int>(), OwnedMachineId = table.Column<long>()
}, constraints: table =>
{
table.PrimaryKey("PK_GpusByOwnedMachine", x => x.Id);
table.ForeignKey("FK_GpusByOwnedMachine_gpus_GpuId", x => x.GpuId, "gpus",
"id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_GpusByOwnedMachine_OwnedMachines_OwnedMachineId",
x => x.OwnedMachineId, "OwnedMachines", "Id",
table.ForeignKey("FK_GpusByOwnedMachine_gpus_GpuId", x => x.GpuId, "gpus", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_GpusByOwnedMachine_OwnedMachines_OwnedMachineId", x => x.OwnedMachineId,
"OwnedMachines", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("MemoryByOwnedMachine",
table => new
migrationBuilder.CreateTable("MemoryByOwnedMachine", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
OwnedMachineId = table.Column<long>(),
Type = table.Column<int>(),
Usage = table.Column<int>(),
Size = table.Column<long>(),
Speed = table.Column<double>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
OwnedMachineId = table.Column<long>(), Type = table.Column<int>(), Usage = table.Column<int>(),
Size = table.Column<long>(), Speed = table.Column<double>()
}, constraints: table =>
{
table.PrimaryKey("PK_MemoryByOwnedMachine", x => x.Id);
table.ForeignKey("FK_MemoryByOwnedMachine_OwnedMachines_OwnedMachineId",
x => x.OwnedMachineId, "OwnedMachines", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_MemoryByOwnedMachine_OwnedMachines_OwnedMachineId", x => x.OwnedMachineId,
"OwnedMachines", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("OwnedMachinePhotos",
table => new
migrationBuilder.CreateTable("OwnedMachinePhotos", table => new
{
Id = table.Column<Guid>(),
Author = table.Column<string>(nullable: true),
Id = table.Column<Guid>(), Author = table.Column<string>(nullable: true),
CameraManufacturer = table.Column<string>(nullable: true),
CameraModel = table.Column<string>(nullable: true),
ColorSpace = table.Column<ushort>(nullable: true),
@@ -106,84 +91,71 @@ namespace Marechai.Database.Migrations
Sharpness = table.Column<ushort>(nullable: true),
SoftwareUsed = table.Column<string>(nullable: true),
SubjectDistanceRange = table.Column<ushort>(nullable: true),
UploadDate =
table.Column<DateTime>()
.Annotation("MySql:ValueGenerationStrategy",
UploadDate = table.Column<DateTime>().
Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.ComputedColumn),
VerticalResolution = table.Column<double>(nullable: true),
WhiteBalance = table.Column<ushort>(nullable: true),
UserId = table.Column<string>(nullable: true),
LicenseId = table.Column<int>(),
OwnedMachineId = table.Column<long>()
LicenseId = table.Column<int>(), OwnedMachineId = table.Column<long>()
}, constraints: table =>
{
table.PrimaryKey("PK_OwnedMachinePhotos", x => x.Id);
table.ForeignKey("FK_OwnedMachinePhotos_Licenses_LicenseId",
x => x.LicenseId, "Licenses", "Id",
table.ForeignKey("FK_OwnedMachinePhotos_Licenses_LicenseId", x => x.LicenseId, "Licenses", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_OwnedMachinePhotos_OwnedMachines_OwnedMachineId",
x => x.OwnedMachineId, "OwnedMachines", "Id",
table.ForeignKey("FK_OwnedMachinePhotos_OwnedMachines_OwnedMachineId", x => x.OwnedMachineId,
"OwnedMachines", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_OwnedMachinePhotos_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_OwnedMachinePhotos_AspNetUsers_UserId", x => x.UserId,
"AspNetUsers", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("ProcessorsByOwnedMachine",
table => new
migrationBuilder.CreateTable("ProcessorsByOwnedMachine", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
ProcessorId = table.Column<int>(),
OwnedMachineId = table.Column<long>(),
Speed = table.Column<float>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ProcessorId = table.Column<int>(), OwnedMachineId = table.Column<long>(), Speed = table.Column<float>()
}, constraints: table =>
{
table.PrimaryKey("PK_ProcessorsByOwnedMachine", x => x.Id);
table
.ForeignKey("FK_ProcessorsByOwnedMachine_OwnedMachines_OwnedMachineId",
x => x.OwnedMachineId, "OwnedMachines", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_ProcessorsByOwnedMachine_processors_ProcessorId",
x => x.ProcessorId, "processors", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_ProcessorsByOwnedMachine_OwnedMachines_OwnedMachineId", x => x.OwnedMachineId,
"OwnedMachines", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_ProcessorsByOwnedMachine_processors_ProcessorId", x => x.ProcessorId, "processors",
"id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("SoundByOwnedMachine",
table => new
migrationBuilder.CreateTable("SoundByOwnedMachine", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
SoundSynthId = table.Column<int>(),
OwnedMachineId = table.Column<long>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
SoundSynthId = table.Column<int>(), OwnedMachineId = table.Column<long>()
}, constraints: table =>
{
table.PrimaryKey("PK_SoundByOwnedMachine", x => x.Id);
table.ForeignKey("FK_SoundByOwnedMachine_OwnedMachines_OwnedMachineId",
x => x.OwnedMachineId, "OwnedMachines", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_SoundByOwnedMachine_sound_synths_SoundSynthId",
x => x.SoundSynthId, "sound_synths", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_SoundByOwnedMachine_OwnedMachines_OwnedMachineId", x => x.OwnedMachineId,
"OwnedMachines", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_SoundByOwnedMachine_sound_synths_SoundSynthId", x => x.SoundSynthId,
"sound_synths", "id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("StorageByOwnedMachine",
table => new
migrationBuilder.CreateTable("StorageByOwnedMachine", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
OwnedMachineId = table.Column<long>(),
Type = table.Column<int>(),
Interface = table.Column<int>(),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
OwnedMachineId = table.Column<long>(), Type = table.Column<int>(), Interface = table.Column<int>(),
Capacity = table.Column<long>()
}, constraints: table =>
{
table.PrimaryKey("PK_StorageByOwnedMachine", x => x.Id);
table.ForeignKey("FK_StorageByOwnedMachine_OwnedMachines_OwnedMachineId",
x => x.OwnedMachineId, "OwnedMachines", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_StorageByOwnedMachine_OwnedMachines_OwnedMachineId", x => x.OwnedMachineId,
"OwnedMachines", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_GpusByOwnedMachine_GpuId", "GpusByOwnedMachine", "GpuId");
@@ -357,91 +329,46 @@ SELECT a.date, a.status, a.trade, a.boxed, a.manuals, a.db_id + 356, @userId FRO
migrationBuilder.DropTable("OwnedMachines");
migrationBuilder.CreateTable("owned_computers",
table => new
migrationBuilder.CreateTable("owned_computers", table => new
{
id =
table.Column<int>("int(11)")
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
boxed =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
cap1 =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
cap2 =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
cpu1 =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
cpu2 =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
date =
table.Column<string>("varchar(20)", nullable: false,
defaultValueSql: "''"),
db_id =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
disk1 =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
disk2 =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
manuals =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
mhz1 =
table.Column<decimal>("decimal(10,0)", nullable: false,
defaultValueSql: "'0'"),
mhz2 =
table.Column<decimal>("decimal(10,0)", nullable: false,
defaultValueSql: "'0'"),
ram =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
rigid =
table.Column<string>("varchar(64)", nullable: false,
defaultValueSql: "''"),
status =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
trade = table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
vram = table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'")
},
constraints: table => { table.PrimaryKey("PK_owned_computers", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
boxed = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cap1 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cap2 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cpu1 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
cpu2 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
date = table.Column<string>("varchar(20)", nullable: false, defaultValueSql: "''"),
db_id = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
disk1 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
disk2 = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
manuals = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
mhz1 = table.Column<decimal>("decimal(10,0)", nullable: false, defaultValueSql: "'0'"),
mhz2 = table.Column<decimal>("decimal(10,0)", nullable: false, defaultValueSql: "'0'"),
ram = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
rigid = table.Column<string>("varchar(64)", nullable: false, defaultValueSql: "''"),
status = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
trade = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
vram = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'")
}, constraints: table =>
{
table.PrimaryKey("PK_owned_computers", x => x.id);
});
migrationBuilder.CreateTable("owned_consoles",
table => new
migrationBuilder.CreateTable("owned_consoles", table => new
{
id =
table.Column<int>("int(11)")
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
boxed =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
date =
table.Column<string>("char(20)", nullable: false,
defaultValueSql: "''"),
db_id =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
manuals =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
status =
table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'"),
trade = table.Column<int>("int(11)", nullable: false,
defaultValueSql: "'0'")
},
constraints: table => { table.PrimaryKey("PK_owned_consoles", x => x.id); });
id = table.Column<int>("int(11)").
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
boxed = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
date = table.Column<string>("char(20)", nullable: false, defaultValueSql: "''"),
db_id = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
manuals = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
status = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'"),
trade = table.Column<int>("int(11)", nullable: false, defaultValueSql: "'0'")
}, constraints: table =>
{
table.PrimaryKey("PK_owned_consoles", x => x.id);
});
migrationBuilder.CreateIndex("idx_owned_computers_boxed", "owned_computers", "boxed");

View File

@@ -7,61 +7,51 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("Screens",
table => new
migrationBuilder.CreateTable("Screens", table => new
{
Id = table.Column<int>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Width = table.Column<double>(nullable: true),
Height = table.Column<double>(nullable: true),
Diagonal = table.Column<double>(),
NativeResolutionId = table.Column<int>(),
EffectiveColors = table.Column<long>(nullable: true),
Type = table.Column<string>()
Id = table.Column<int>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Width = table.Column<double>(nullable: true), Height = table.Column<double>(nullable: true),
Diagonal = table.Column<double>(), NativeResolutionId = table.Column<int>(),
EffectiveColors = table.Column<long>(nullable: true), Type = table.Column<string>()
}, constraints: table =>
{
table.PrimaryKey("PK_Screens", x => x.Id);
table.ForeignKey("FK_Screens_resolutions_NativeResolutionId",
x => x.NativeResolutionId, "resolutions", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_Screens_resolutions_NativeResolutionId", x => x.NativeResolutionId, "resolutions",
"id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("ResolutionsByScreen",
table => new
migrationBuilder.CreateTable("ResolutionsByScreen", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
ScreenId = table.Column<int>(),
ResolutionId = table.Column<int>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ScreenId = table.Column<int>(), ResolutionId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_ResolutionsByScreen", x => x.Id);
table.ForeignKey("FK_ResolutionsByScreen_resolutions_ResolutionId",
x => x.ResolutionId, "resolutions", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_ResolutionsByScreen_Screens_ScreenId",
x => x.ScreenId, "Screens", "Id",
table.ForeignKey("FK_ResolutionsByScreen_resolutions_ResolutionId", x => x.ResolutionId, "resolutions",
"id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_ResolutionsByScreen_Screens_ScreenId", x => x.ScreenId, "Screens", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("ScreensByMachine",
table => new
migrationBuilder.CreateTable("ScreensByMachine", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
ScreenId = table.Column<int>(),
MachineId = table.Column<int>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ScreenId = table.Column<int>(), MachineId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_ScreensByMachine", x => x.Id);
table.ForeignKey("FK_ScreensByMachine_machines_MachineId",
x => x.MachineId, "machines", "id",
table.ForeignKey("FK_ScreensByMachine_machines_MachineId", x => x.MachineId, "machines", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_ScreensByMachine_Screens_ScreenId", x => x.ScreenId, "Screens", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_ScreensByMachine_Screens_ScreenId", x => x.ScreenId,
"Screens", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_ResolutionsByScreen_ResolutionId", "ResolutionsByScreen", "ResolutionId");

View File

@@ -8,27 +8,21 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("People",
table => new
migrationBuilder.CreateTable("People", table => new
{
Id = table.Column<int>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(),
Surname = table.Column<string>(),
Id = table.Column<int>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(), Surname = table.Column<string>(),
BirthDate = table.Column<DateTime>(),
DeathDate = table.Column<DateTime>(nullable: true),
Webpage = table.Column<string>(nullable: true),
Twitter = table.Column<string>(nullable: true),
Facebook = table.Column<string>(nullable: true),
Photo = table.Column<Guid>(),
CountryOfBirthId = table.Column<short>(nullable: true)
DeathDate = table.Column<DateTime>(nullable: true), Webpage = table.Column<string>(nullable: true),
Twitter = table.Column<string>(nullable: true), Facebook = table.Column<string>(nullable: true),
Photo = table.Column<Guid>(), CountryOfBirthId = table.Column<short>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_People", x => x.Id);
table.ForeignKey("FK_People_iso3166_1_numeric_CountryOfBirthId",
x => x.CountryOfBirthId, "iso3166_1_numeric", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("FK_People_iso3166_1_numeric_CountryOfBirthId", x => x.CountryOfBirthId,
"iso3166_1_numeric", "id", onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex("IX_People_BirthDate", "People", "BirthDate");
@@ -50,9 +44,6 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_People_Webpage", "People", "Webpage");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("People");
}
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("People");
}
}

View File

@@ -6,18 +6,17 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("ISO_639-3",
table => new
migrationBuilder.CreateTable("ISO_639-3", table => new
{
Id = table.Column<string>("char(3)"),
Part2B = table.Column<string>("char(3)", nullable: true),
Id = table.Column<string>("char(3)"), Part2B = table.Column<string>("char(3)", nullable: true),
Part2T = table.Column<string>("char(3)", nullable: true),
Part1 = table.Column<string>("char(2)", nullable: true),
Scope = table.Column<string>("char(1)"),
Type = table.Column<string>("char(1)"),
Ref_Name = table.Column<string>("varchar(150)"),
Part1 = table.Column<string>("char(2)", nullable: true), Scope = table.Column<string>("char(1)"),
Type = table.Column<string>("char(1)"), Ref_Name = table.Column<string>("varchar(150)"),
Comment = table.Column<string>("varchar(150)", nullable: true)
}, constraints: table => { table.PrimaryKey("PK_ISO_639-3", x => x.Id); });
}, constraints: table =>
{
table.PrimaryKey("PK_ISO_639-3", x => x.Id);
});
migrationBuilder.CreateIndex("IX_ISO_639-3_Comment", "ISO_639-3", "Comment");
@@ -34,9 +33,6 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_ISO_639-3_Type", "ISO_639-3", "Type");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("ISO_639-3");
}
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("ISO_639-3");
}
}

View File

@@ -8,66 +8,36 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PeopleByCompany",
columns: table => new
migrationBuilder.CreateTable("PeopleByCompany", table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(nullable: false),
CompanyId = table.Column<int>(nullable: false),
Position = table.Column<string>(nullable: true),
Start = table.Column<DateTime>(nullable: true),
End = table.Column<DateTime>(nullable: true),
Ongoing = table.Column<bool>(nullable: false)
},
constraints: table =>
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(), CompanyId = table.Column<int>(),
Position = table.Column<string>(nullable: true), Start = table.Column<DateTime>(nullable: true),
End = table.Column<DateTime>(nullable: true), Ongoing = table.Column<bool>()
}, constraints: table =>
{
table.PrimaryKey("PK_PeopleByCompany", x => x.Id);
table.ForeignKey(
name: "FK_PeopleByCompany_companies_CompanyId",
column: x => x.CompanyId,
principalTable: "companies",
principalColumn: "id",
table.ForeignKey("FK_PeopleByCompany_companies_CompanyId", x => x.CompanyId, "companies", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PeopleByCompany_People_PersonId",
column: x => x.PersonId,
principalTable: "People",
principalColumn: "Id",
table.ForeignKey("FK_PeopleByCompany_People_PersonId", x => x.PersonId, "People", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_PeopleByCompany_CompanyId",
table: "PeopleByCompany",
column: "CompanyId");
migrationBuilder.CreateIndex("IX_PeopleByCompany_CompanyId", "PeopleByCompany", "CompanyId");
migrationBuilder.CreateIndex(
name: "IX_PeopleByCompany_End",
table: "PeopleByCompany",
column: "End");
migrationBuilder.CreateIndex("IX_PeopleByCompany_End", "PeopleByCompany", "End");
migrationBuilder.CreateIndex(
name: "IX_PeopleByCompany_PersonId",
table: "PeopleByCompany",
column: "PersonId");
migrationBuilder.CreateIndex("IX_PeopleByCompany_PersonId", "PeopleByCompany", "PersonId");
migrationBuilder.CreateIndex(
name: "IX_PeopleByCompany_Position",
table: "PeopleByCompany",
column: "Position");
migrationBuilder.CreateIndex("IX_PeopleByCompany_Position", "PeopleByCompany", "Position");
migrationBuilder.CreateIndex(
name: "IX_PeopleByCompany_Start",
table: "PeopleByCompany",
column: "Start");
migrationBuilder.CreateIndex("IX_PeopleByCompany_Start", "PeopleByCompany", "Start");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PeopleByCompany");
}
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("PeopleByCompany");
}
}

View File

@@ -8,23 +8,19 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("Documents",
table => new
migrationBuilder.CreateTable("Documents", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(),
NativeTitle = table.Column<string>(nullable: true),
Published = table.Column<DateTime>(nullable: true),
CountryId = table.Column<short>(nullable: true),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(), NativeTitle = table.Column<string>(nullable: true),
Published = table.Column<DateTime>(nullable: true), CountryId = table.Column<short>(nullable: true),
Synopsis = table.Column<string>(maxLength: 262144, nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_Documents", x => x.Id);
table.ForeignKey("FK_Documents_iso3166_1_numeric_CountryId",
x => x.CountryId, "iso3166_1_numeric", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("FK_Documents_iso3166_1_numeric_CountryId", x => x.CountryId, "iso3166_1_numeric",
"id", onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex("IX_Documents_CountryId", "Documents", "CountryId");
@@ -33,15 +29,12 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_Documents_Published", "Documents", "Published");
migrationBuilder.CreateIndex("IX_Documents_Synopsis", "Documents", "Synopsis")
.Annotation("MySql:FullTextIndex", true);
migrationBuilder.CreateIndex("IX_Documents_Synopsis", "Documents", "Synopsis").
Annotation("MySql:FullTextIndex", true);
migrationBuilder.CreateIndex("IX_Documents_Title", "Documents", "Title");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("Documents");
}
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("Documents");
}
}

View File

@@ -6,164 +6,833 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("DocumentRoles",
table => new
migrationBuilder.CreateTable("DocumentRoles", table => new
{
Id = table.Column<string>("char(3)"),
Name = table.Column<string>(nullable: true),
Id = table.Column<string>("char(3)"), Name = table.Column<string>(nullable: true),
Enabled = table.Column<bool>(nullable: false, defaultValue: true)
},
constraints: table => { table.PrimaryKey("PK_DocumentRoles", x => x.Id); });
migrationBuilder.InsertData("DocumentRoles", new[] {"Id", "Enabled", "Name"},
new object[,]
}, constraints: table =>
{
{"abr", true, "Abridger"}, {"orm", true, "Organizer"},
{"osp", true, "Onscreen presenter"}, {"oth", true, "Other"},
{"own", true, "Owner"}, {"pan", true, "Panelist"},
{"pat", true, "Patron"}, {"pbd", true, "Publishing director"},
{"pbl", true, "Publisher"}, {"pdr", true, "Project director"},
{"pfr", true, "Proofreader"}, {"pht", true, "Photographer"},
{"plt", true, "Platemaker"}, {"pma", true, "Permitting agency"},
{"pmn", true, "Production manager"}, {"org", true, "Originator"},
{"pop", true, "Printer of plates"}, {"ppt", true, "Puppeteer"},
{"pra", true, "Praeses"}, {"prc", true, "Process contact"},
{"prd", true, "Production personnel"}, {"pre", true, "Presenter"},
{"prf", true, "Performer"}, {"prg", true, "Programmer"},
{"prm", true, "Printmaker"}, {"prn", true, "Production company"},
{"pro", true, "Producer"}, {"prp", true, "Production place"},
{"prs", true, "Production designer"}, {"prt", true, "Printer"},
{"prv", true, "Provider"}, {"ppm", true, "Papermaker"},
{"pta", true, "Patent applicant"}, {"opn", true, "Opponent"},
{"mus", true, "Musician"}, {"jug", true, "Jurisdiction governed"},
{"lbr", true, "Laboratory"}, {"lbt", true, "Librettist"},
{"ldr", true, "Laboratory director"}, {"led", true, "Lead"},
{"lee", true, "Libelee-appellee"}, {"lel", true, "Libelee"},
{"len", true, "Lender"}, {"let", true, "Libelee-appellant"},
{"lgd", true, "Lighting designer"}, {"lie", true, "Libelant-appellee"},
{"lil", true, "Libelant"}, {"lit", true, "Libelant-appellant"},
{"lsa", true, "Landscape architect"}, {"nrt", true, "Narrator"},
{"lse", true, "Licensee"}, {"ltg", true, "Lithographer"},
{"lyr", true, "Lyricist"}, {"mcp", true, "Music copyist"},
{"mdc", true, "Metadata contact"}, {"med", true, "Medium"},
{"mfp", true, "Manufacture place"}, {"mfr", true, "Manufacturer"},
{"mod", true, "Moderator"}, {"mon", true, "Monitor"},
{"mrb", true, "Marbler"}, {"mrk", true, "Markup editor"},
{"msd", true, "Musical director"}, {"mte", true, "Metal-engraver"},
{"mtk", true, "Minute taker"}, {"lso", true, "Licensor"},
{"jud", true, "Judge"}, {"pte", true, "Plaintiff-appellee"},
{"pth", true, "Patent holder"}, {"spn", true, "Sponsor"},
{"spy", true, "Second party"}, {"srv", true, "Surveyor"},
{"std", true, "Set designer"}, {"stg", true, "Setting"},
{"stl", true, "Storyteller"}, {"stm", true, "Stage manager"},
{"stn", true, "Standards body"}, {"str", true, "Stereotyper"},
{"tcd", true, "Technical director"}, {"tch", true, "Teacher"},
{"ths", true, "Thesis advisor"}, {"tld", true, "Television director"},
{"tlp", true, "Television producer"}, {"spk", true, "Speaker"},
{"trc", true, "Transcriber"}, {"tyd", true, "Type designer"},
{"tyg", true, "Typographer"}, {"uvp", true, "University place"},
{"vac", true, "Voice actor"}, {"vdg", true, "Videographer"},
{"voc", false, "Vocalist"}, {"wac", true, "Writer of added commentary"},
{"wal", true, "Writer of added lyrics"},
{"wam", true, "Writer of accompanying material"},
{"wat", true, "Writer of added text"}, {"wdc", true, "Woodcutter"},
{"wde", true, "Wood engraver"}, {"win", true, "Writer of introduction"},
{"wit", true, "Witness"}, {"trl", true, "Translator"},
{"ptf", true, "Plaintiff"}, {"sng", true, "Singer"},
{"sht", true, "Supporting host"}, {"ptt", true, "Plaintiff-appellant"},
{"pup", true, "Publication place"}, {"rbr", true, "Rubricator"},
{"rcd", true, "Recordist"}, {"rce", true, "Recording engineer"},
{"rcp", true, "Addressee"}, {"rdd", true, "Radio director"},
{"red", true, "Redaktor"}, {"ren", true, "Renderer"},
{"res", true, "Researcher"}, {"rev", true, "Reviewer"},
{"rpc", true, "Radio producer"}, {"rps", true, "Repository"},
{"rpt", true, "Reporter"}, {"sll", true, "Seller"},
{"rpy", true, "Responsible party"}, {"rsg", true, "Restager"},
{"rsp", true, "Respondent"}, {"rsr", true, "Restorationist"},
{"rst", true, "Respondent-appellant"},
{"rth", true, "Research team head"},
{"rtm", true, "Research team member"},
{"sad", true, "Scientific advisor"}, {"sce", true, "Scenarist"},
{"scl", true, "Sculptor"}, {"scr", true, "Scribe"},
{"sds", true, "Sound designer"}, {"sec", true, "Secretary"},
{"sgd", true, "Stage director"}, {"sgn", true, "Signer"},
{"rse", true, "Respondent-appellee"},
{"wpr", true, "Writer of preface"}, {"ivr", true, "Interviewer"},
{"itr", true, "Instrumentalist"}, {"brl", true, "Braille embosser"},
{"bsl", true, "Bookseller"}, {"cas", true, "Caster"},
{"ccp", true, "Conceptor"}, {"chr", true, "Choreographer"},
{"clb", false, "Collaborator"}, {"cli", true, "Client"},
{"cll", true, "Calligrapher"}, {"clr", true, "Colorist"},
{"clt", true, "Collotyper"}, {"cmm", true, "Commentator"},
{"cmp", true, "Composer"}, {"cmt", true, "Compositor"},
{"cnd", true, "Conductor"}, {"brd", true, "Broadcaster"},
{"cng", true, "Cinematographer"}, {"coe", true, "Contestant-appellee"},
{"col", true, "Collector"}, {"com", true, "Compiler"},
{"con", true, "Conservator"}, {"cor", true, "Collection registrar"},
{"cos", true, "Contestant"}, {"cot", true, "Contestant-appellant"},
{"cou", true, "Court governed"}, {"cov", true, "Cover designer"},
{"cpc", true, "Copyright claimant"},
{"cpe", true, "Complainant-appellee"},
{"cph", true, "Copyright holder"}, {"cpl", true, "Complainant"},
{"cpt", true, "Complainant-appellant"}, {"cns", true, "Censor"},
{"cre", true, "Creator"}, {"bpd", true, "Bookplate designer"},
{"blw", true, "Blurb writer"}, {"acp", true, "Art copyist"},
{"act", true, "Actor"}, {"adi", true, "Art director"},
{"adp", true, "Adapter"},
{"aft", true, "Author of afterword, colophon, etc."},
{"anl", true, "Analyst"}, {"anm", true, "Animator"},
{"ann", true, "Annotator"}, {"ant", true, "Bibliographic antecedent"},
{"ape", true, "Appellee"}, {"apl", true, "Appellant"},
{"app", true, "Applicant"},
{"aqt", true, "Author in quotations or text abstracts"},
{"arc", true, "Architect"}, {"bnd", true, "Binder"},
{"ard", true, "Artistic director"}, {"art", true, "Artist"},
{"asg", true, "Assignee"}, {"asn", true, "Associated name"},
{"ato", true, "Autographer"}, {"att", true, "Attributed name"},
{"auc", true, "Auctioneer"}, {"aud", true, "Author of dialog"},
{"aui", true, "Author of introduction, etc."},
{"aus", true, "Screenwriter"}, {"aut", true, "Author"},
{"bdd", true, "Binding designer"}, {"bjd", true, "Bookjacket designer"},
{"bkd", true, "Book designer"}, {"bkp", true, "Book producer"},
{"arr", true, "Arranger"}, {"ive", true, "Interviewee"},
{"crp", true, "Correspondent"}, {"crt", true, "Court reporter"},
{"edt", true, "Editor"}, {"egr", true, "Engraver"},
{"elg", true, "Electrician"}, {"elt", true, "Electrotyper"},
{"eng", true, "Engineer"}, {"enj", true, "Enacting jurisdiction"},
{"etr", true, "Etcher"}, {"evp", true, "Event place"},
{"exp", true, "Expert"}, {"fac", true, "Facsimilist"},
{"fds", true, "Film distributor"}, {"fld", true, "Field director"},
{"flm", true, "Film editor"}, {"fmd", true, "Film director"},
{"edm", true, "Editor of moving image work"},
{"fmk", true, "Filmmaker"}, {"fmp", true, "Film producer"},
{"fnd", true, "Funder"}, {"fpy", true, "First party"},
{"frg", true, "Forger"},
{"gis", true, "Geographic information specialist"},
{"grt", false, "Graphic technician"}, {"his", true, "Host institution"},
{"hnr", true, "Honoree"}, {"hst", true, "Host"},
{"ill", true, "Illustrator"}, {"ilu", true, "Illuminator"},
{"ins", true, "Inscriber"}, {"inv", true, "Inventor"},
{"isb", true, "Issuing body"}, {"fmo", true, "Former owner"},
{"crr", true, "Corrector"}, {"edc", true, "Editor of compilation"},
{"dto", true, "Dedicator"}, {"csl", true, "Consultant"},
{"csp", true, "Consultant to a project"},
{"cst", true, "Costume designer"}, {"ctb", true, "Contributor"},
{"cte", true, "Contestee-appellee"}, {"ctg", true, "Cartographer"},
{"ctr", true, "Contractor"}, {"cts", true, "Contestee"},
{"ctt", true, "Contestee-appellant"}, {"cur", true, "Curator"},
{"cwt", true, "Commentator for written text"},
{"dbp", true, "Distribution place"}, {"dfd", true, "Defendant"},
{"dfe", true, "Defendant-appellee"}, {"dub", true, "Dubious author"},
{"dft", true, "Defendant-appellant"},
{"dgs", true, "Degree supervisor"}, {"dis", true, "Dissertant"},
{"dln", true, "Delineator"}, {"dnc", true, "Dancer"},
{"dnr", true, "Donor"}, {"dpc", true, "Depicted"},
{"dpt", true, "Depositor"}, {"drm", true, "Draftsman"},
{"drt", true, "Director"}, {"dsr", true, "Designer"},
{"dst", true, "Distributor"}, {"dtc", true, "Data contributor"},
{"dte", true, "Dedicatee"}, {"dtm", true, "Data manager"},
{"dgg", true, "Degree granting institution"},
{"wst", true, "Writer of supplementary textual content"}
table.PrimaryKey("PK_DocumentRoles", x => x.Id);
});
migrationBuilder.InsertData("DocumentRoles", new[]
{
"Id", "Enabled", "Name"
}, new object[,]
{
{
"abr", true, "Abridger"
},
{
"orm", true, "Organizer"
},
{
"osp", true, "Onscreen presenter"
},
{
"oth", true, "Other"
},
{
"own", true, "Owner"
},
{
"pan", true, "Panelist"
},
{
"pat", true, "Patron"
},
{
"pbd", true, "Publishing director"
},
{
"pbl", true, "Publisher"
},
{
"pdr", true, "Project director"
},
{
"pfr", true, "Proofreader"
},
{
"pht", true, "Photographer"
},
{
"plt", true, "Platemaker"
},
{
"pma", true, "Permitting agency"
},
{
"pmn", true, "Production manager"
},
{
"org", true, "Originator"
},
{
"pop", true, "Printer of plates"
},
{
"ppt", true, "Puppeteer"
},
{
"pra", true, "Praeses"
},
{
"prc", true, "Process contact"
},
{
"prd", true, "Production personnel"
},
{
"pre", true, "Presenter"
},
{
"prf", true, "Performer"
},
{
"prg", true, "Programmer"
},
{
"prm", true, "Printmaker"
},
{
"prn", true, "Production company"
},
{
"pro", true, "Producer"
},
{
"prp", true, "Production place"
},
{
"prs", true, "Production designer"
},
{
"prt", true, "Printer"
},
{
"prv", true, "Provider"
},
{
"ppm", true, "Papermaker"
},
{
"pta", true, "Patent applicant"
},
{
"opn", true, "Opponent"
},
{
"mus", true, "Musician"
},
{
"jug", true, "Jurisdiction governed"
},
{
"lbr", true, "Laboratory"
},
{
"lbt", true, "Librettist"
},
{
"ldr", true, "Laboratory director"
},
{
"led", true, "Lead"
},
{
"lee", true, "Libelee-appellee"
},
{
"lel", true, "Libelee"
},
{
"len", true, "Lender"
},
{
"let", true, "Libelee-appellant"
},
{
"lgd", true, "Lighting designer"
},
{
"lie", true, "Libelant-appellee"
},
{
"lil", true, "Libelant"
},
{
"lit", true, "Libelant-appellant"
},
{
"lsa", true, "Landscape architect"
},
{
"nrt", true, "Narrator"
},
{
"lse", true, "Licensee"
},
{
"ltg", true, "Lithographer"
},
{
"lyr", true, "Lyricist"
},
{
"mcp", true, "Music copyist"
},
{
"mdc", true, "Metadata contact"
},
{
"med", true, "Medium"
},
{
"mfp", true, "Manufacture place"
},
{
"mfr", true, "Manufacturer"
},
{
"mod", true, "Moderator"
},
{
"mon", true, "Monitor"
},
{
"mrb", true, "Marbler"
},
{
"mrk", true, "Markup editor"
},
{
"msd", true, "Musical director"
},
{
"mte", true, "Metal-engraver"
},
{
"mtk", true, "Minute taker"
},
{
"lso", true, "Licensor"
},
{
"jud", true, "Judge"
},
{
"pte", true, "Plaintiff-appellee"
},
{
"pth", true, "Patent holder"
},
{
"spn", true, "Sponsor"
},
{
"spy", true, "Second party"
},
{
"srv", true, "Surveyor"
},
{
"std", true, "Set designer"
},
{
"stg", true, "Setting"
},
{
"stl", true, "Storyteller"
},
{
"stm", true, "Stage manager"
},
{
"stn", true, "Standards body"
},
{
"str", true, "Stereotyper"
},
{
"tcd", true, "Technical director"
},
{
"tch", true, "Teacher"
},
{
"ths", true, "Thesis advisor"
},
{
"tld", true, "Television director"
},
{
"tlp", true, "Television producer"
},
{
"spk", true, "Speaker"
},
{
"trc", true, "Transcriber"
},
{
"tyd", true, "Type designer"
},
{
"tyg", true, "Typographer"
},
{
"uvp", true, "University place"
},
{
"vac", true, "Voice actor"
},
{
"vdg", true, "Videographer"
},
{
"voc", false, "Vocalist"
},
{
"wac", true, "Writer of added commentary"
},
{
"wal", true, "Writer of added lyrics"
},
{
"wam", true, "Writer of accompanying material"
},
{
"wat", true, "Writer of added text"
},
{
"wdc", true, "Woodcutter"
},
{
"wde", true, "Wood engraver"
},
{
"win", true, "Writer of introduction"
},
{
"wit", true, "Witness"
},
{
"trl", true, "Translator"
},
{
"ptf", true, "Plaintiff"
},
{
"sng", true, "Singer"
},
{
"sht", true, "Supporting host"
},
{
"ptt", true, "Plaintiff-appellant"
},
{
"pup", true, "Publication place"
},
{
"rbr", true, "Rubricator"
},
{
"rcd", true, "Recordist"
},
{
"rce", true, "Recording engineer"
},
{
"rcp", true, "Addressee"
},
{
"rdd", true, "Radio director"
},
{
"red", true, "Redaktor"
},
{
"ren", true, "Renderer"
},
{
"res", true, "Researcher"
},
{
"rev", true, "Reviewer"
},
{
"rpc", true, "Radio producer"
},
{
"rps", true, "Repository"
},
{
"rpt", true, "Reporter"
},
{
"sll", true, "Seller"
},
{
"rpy", true, "Responsible party"
},
{
"rsg", true, "Restager"
},
{
"rsp", true, "Respondent"
},
{
"rsr", true, "Restorationist"
},
{
"rst", true, "Respondent-appellant"
},
{
"rth", true, "Research team head"
},
{
"rtm", true, "Research team member"
},
{
"sad", true, "Scientific advisor"
},
{
"sce", true, "Scenarist"
},
{
"scl", true, "Sculptor"
},
{
"scr", true, "Scribe"
},
{
"sds", true, "Sound designer"
},
{
"sec", true, "Secretary"
},
{
"sgd", true, "Stage director"
},
{
"sgn", true, "Signer"
},
{
"rse", true, "Respondent-appellee"
},
{
"wpr", true, "Writer of preface"
},
{
"ivr", true, "Interviewer"
},
{
"itr", true, "Instrumentalist"
},
{
"brl", true, "Braille embosser"
},
{
"bsl", true, "Bookseller"
},
{
"cas", true, "Caster"
},
{
"ccp", true, "Conceptor"
},
{
"chr", true, "Choreographer"
},
{
"clb", false, "Collaborator"
},
{
"cli", true, "Client"
},
{
"cll", true, "Calligrapher"
},
{
"clr", true, "Colorist"
},
{
"clt", true, "Collotyper"
},
{
"cmm", true, "Commentator"
},
{
"cmp", true, "Composer"
},
{
"cmt", true, "Compositor"
},
{
"cnd", true, "Conductor"
},
{
"brd", true, "Broadcaster"
},
{
"cng", true, "Cinematographer"
},
{
"coe", true, "Contestant-appellee"
},
{
"col", true, "Collector"
},
{
"com", true, "Compiler"
},
{
"con", true, "Conservator"
},
{
"cor", true, "Collection registrar"
},
{
"cos", true, "Contestant"
},
{
"cot", true, "Contestant-appellant"
},
{
"cou", true, "Court governed"
},
{
"cov", true, "Cover designer"
},
{
"cpc", true, "Copyright claimant"
},
{
"cpe", true, "Complainant-appellee"
},
{
"cph", true, "Copyright holder"
},
{
"cpl", true, "Complainant"
},
{
"cpt", true, "Complainant-appellant"
},
{
"cns", true, "Censor"
},
{
"cre", true, "Creator"
},
{
"bpd", true, "Bookplate designer"
},
{
"blw", true, "Blurb writer"
},
{
"acp", true, "Art copyist"
},
{
"act", true, "Actor"
},
{
"adi", true, "Art director"
},
{
"adp", true, "Adapter"
},
{
"aft", true, "Author of afterword, colophon, etc."
},
{
"anl", true, "Analyst"
},
{
"anm", true, "Animator"
},
{
"ann", true, "Annotator"
},
{
"ant", true, "Bibliographic antecedent"
},
{
"ape", true, "Appellee"
},
{
"apl", true, "Appellant"
},
{
"app", true, "Applicant"
},
{
"aqt", true, "Author in quotations or text abstracts"
},
{
"arc", true, "Architect"
},
{
"bnd", true, "Binder"
},
{
"ard", true, "Artistic director"
},
{
"art", true, "Artist"
},
{
"asg", true, "Assignee"
},
{
"asn", true, "Associated name"
},
{
"ato", true, "Autographer"
},
{
"att", true, "Attributed name"
},
{
"auc", true, "Auctioneer"
},
{
"aud", true, "Author of dialog"
},
{
"aui", true, "Author of introduction, etc."
},
{
"aus", true, "Screenwriter"
},
{
"aut", true, "Author"
},
{
"bdd", true, "Binding designer"
},
{
"bjd", true, "Bookjacket designer"
},
{
"bkd", true, "Book designer"
},
{
"bkp", true, "Book producer"
},
{
"arr", true, "Arranger"
},
{
"ive", true, "Interviewee"
},
{
"crp", true, "Correspondent"
},
{
"crt", true, "Court reporter"
},
{
"edt", true, "Editor"
},
{
"egr", true, "Engraver"
},
{
"elg", true, "Electrician"
},
{
"elt", true, "Electrotyper"
},
{
"eng", true, "Engineer"
},
{
"enj", true, "Enacting jurisdiction"
},
{
"etr", true, "Etcher"
},
{
"evp", true, "Event place"
},
{
"exp", true, "Expert"
},
{
"fac", true, "Facsimilist"
},
{
"fds", true, "Film distributor"
},
{
"fld", true, "Field director"
},
{
"flm", true, "Film editor"
},
{
"fmd", true, "Film director"
},
{
"edm", true, "Editor of moving image work"
},
{
"fmk", true, "Filmmaker"
},
{
"fmp", true, "Film producer"
},
{
"fnd", true, "Funder"
},
{
"fpy", true, "First party"
},
{
"frg", true, "Forger"
},
{
"gis", true, "Geographic information specialist"
},
{
"grt", false, "Graphic technician"
},
{
"his", true, "Host institution"
},
{
"hnr", true, "Honoree"
},
{
"hst", true, "Host"
},
{
"ill", true, "Illustrator"
},
{
"ilu", true, "Illuminator"
},
{
"ins", true, "Inscriber"
},
{
"inv", true, "Inventor"
},
{
"isb", true, "Issuing body"
},
{
"fmo", true, "Former owner"
},
{
"crr", true, "Corrector"
},
{
"edc", true, "Editor of compilation"
},
{
"dto", true, "Dedicator"
},
{
"csl", true, "Consultant"
},
{
"csp", true, "Consultant to a project"
},
{
"cst", true, "Costume designer"
},
{
"ctb", true, "Contributor"
},
{
"cte", true, "Contestee-appellee"
},
{
"ctg", true, "Cartographer"
},
{
"ctr", true, "Contractor"
},
{
"cts", true, "Contestee"
},
{
"ctt", true, "Contestee-appellant"
},
{
"cur", true, "Curator"
},
{
"cwt", true, "Commentator for written text"
},
{
"dbp", true, "Distribution place"
},
{
"dfd", true, "Defendant"
},
{
"dfe", true, "Defendant-appellee"
},
{
"dub", true, "Dubious author"
},
{
"dft", true, "Defendant-appellant"
},
{
"dgs", true, "Degree supervisor"
},
{
"dis", true, "Dissertant"
},
{
"dln", true, "Delineator"
},
{
"dnc", true, "Dancer"
},
{
"dnr", true, "Donor"
},
{
"dpc", true, "Depicted"
},
{
"dpt", true, "Depositor"
},
{
"drm", true, "Draftsman"
},
{
"drt", true, "Director"
},
{
"dsr", true, "Designer"
},
{
"dst", true, "Distributor"
},
{
"dtc", true, "Data contributor"
},
{
"dte", true, "Dedicatee"
},
{
"dtm", true, "Data manager"
},
{
"dgg", true, "Degree granting institution"
},
{
"wst", true, "Writer of supplementary textual content"
}
});
migrationBuilder.CreateIndex("IX_DocumentRoles_Enabled", "DocumentRoles", "Enabled");
@@ -171,9 +840,6 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_DocumentRoles_Name", "DocumentRoles", "Name");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("DocumentRoles");
}
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("DocumentRoles");
}
}

View File

@@ -9,20 +9,18 @@ namespace Marechai.Database.Migrations
{
migrationBuilder.AddColumn<int>("DocumentPersonId", "People", nullable: true);
migrationBuilder.CreateTable("DocumentPeople",
table => new
migrationBuilder.CreateTable("DocumentPeople", table => new
{
Id = table.Column<int>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(),
Surname = table.Column<string>(),
Id = table.Column<int>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(), Surname = table.Column<string>(),
PersonId = table.Column<int>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_DocumentPeople", x => x.Id);
table.ForeignKey("FK_DocumentPeople_People_PersonId", x => x.PersonId,
"People", "Id", onDelete: ReferentialAction.SetNull);
table.ForeignKey("FK_DocumentPeople_People_PersonId", x => x.PersonId, "People", "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateIndex("IX_DocumentPeople_Name", "DocumentPeople", "Name");

View File

@@ -7,26 +7,23 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("PeopleByDocuments",
table => new
migrationBuilder.CreateTable("PeopleByDocuments", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(),
DocumentId = table.Column<long>(),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(), DocumentId = table.Column<long>(),
RoleId = table.Column<string>("char(3)")
}, constraints: table =>
{
table.PrimaryKey("PK_PeopleByDocuments", x => x.Id);
table.ForeignKey("FK_PeopleByDocuments_Documents_DocumentId",
x => x.DocumentId, "Documents", "Id",
table.ForeignKey("FK_PeopleByDocuments_Documents_DocumentId", x => x.DocumentId, "Documents", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByDocuments_DocumentPeople_PersonId",
x => x.PersonId, "DocumentPeople", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByDocuments_DocumentRoles_RoleId",
x => x.RoleId, "DocumentRoles", "Id",
table.ForeignKey("FK_PeopleByDocuments_DocumentPeople_PersonId", x => x.PersonId, "DocumentPeople",
"Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByDocuments_DocumentRoles_RoleId", x => x.RoleId, "DocumentRoles", "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -37,9 +34,7 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_PeopleByDocuments_RoleId", "PeopleByDocuments", "RoleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("PeopleByDocuments");
}
}
}

View File

@@ -9,16 +9,12 @@ namespace Marechai.Database.Migrations
{
migrationBuilder.AddColumn<int>("DocumentCompanyId", "companies", nullable: true);
migrationBuilder.CreateTable("DocumentCompanies",
table => new
migrationBuilder.CreateTable("DocumentCompanies", table => new
{
Id = table.Column<int>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(),
CompanyId = table.Column<int>(nullable: true)
},
constraints: table =>
Id = table.Column<int>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(), CompanyId = table.Column<int>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_DocumentCompanies", x => x.Id);
});

View File

@@ -7,26 +7,23 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("CompaniesByDocuments",
table => new
migrationBuilder.CreateTable("CompaniesByDocuments", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(),
DocumentId = table.Column<long>(),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(), DocumentId = table.Column<long>(),
RoleId = table.Column<string>("char(3)")
}, constraints: table =>
{
table.PrimaryKey("PK_CompaniesByDocuments", x => x.Id);
table.ForeignKey("FK_CompaniesByDocuments_DocumentCompanies_CompanyId",
x => x.CompanyId, "DocumentCompanies", "Id",
table.ForeignKey("FK_CompaniesByDocuments_DocumentCompanies_CompanyId", x => x.CompanyId,
"DocumentCompanies", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByDocuments_Documents_DocumentId", x => x.DocumentId, "Documents", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByDocuments_Documents_DocumentId",
x => x.DocumentId, "Documents", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByDocuments_DocumentRoles_RoleId",
x => x.RoleId, "DocumentRoles", "Id",
table.ForeignKey("FK_CompaniesByDocuments_DocumentRoles_RoleId", x => x.RoleId, "DocumentRoles", "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -37,9 +34,7 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_CompaniesByDocuments_RoleId", "CompaniesByDocuments", "RoleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("CompaniesByDocuments");
}
}
}

View File

@@ -7,22 +7,19 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("DocumentsByMachines",
table => new
migrationBuilder.CreateTable("DocumentsByMachines", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
DocumentId = table.Column<long>(),
MachineId = table.Column<int>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DocumentId = table.Column<long>(), MachineId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_DocumentsByMachines", x => x.Id);
table.ForeignKey("FK_DocumentsByMachines_Documents_DocumentId",
x => x.DocumentId, "Documents", "Id",
table.ForeignKey("FK_DocumentsByMachines_Documents_DocumentId", x => x.DocumentId, "Documents", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_DocumentsByMachines_machines_MachineId",
x => x.MachineId, "machines", "id",
table.ForeignKey("FK_DocumentsByMachines_machines_MachineId", x => x.MachineId, "machines", "id",
onDelete: ReferentialAction.Cascade);
});
@@ -31,9 +28,7 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_DocumentsByMachines_MachineId", "DocumentsByMachines", "MachineId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("DocumentsByMachines");
}
}
}

View File

@@ -7,24 +7,20 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("DocumentsByMachineFamily",
table => new
migrationBuilder.CreateTable("DocumentsByMachineFamily", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
DocumentId = table.Column<long>(),
MachineFamilyId = table.Column<int>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DocumentId = table.Column<long>(), MachineFamilyId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_DocumentsByMachineFamily", x => x.Id);
table.ForeignKey("FK_DocumentsByMachineFamily_Documents_DocumentId",
x => x.DocumentId, "Documents", "Id",
onDelete: ReferentialAction.Cascade);
table
.ForeignKey("FK_DocumentsByMachineFamily_machine_families_MachineFamilyId",
x => x.MachineFamilyId, "machine_families", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_DocumentsByMachineFamily_Documents_DocumentId", x => x.DocumentId, "Documents",
"Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_DocumentsByMachineFamily_machine_families_MachineFamilyId", x => x.MachineFamilyId,
"machine_families", "id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_DocumentsByMachineFamily_DocumentId", "DocumentsByMachineFamily",
@@ -34,9 +30,7 @@ namespace Marechai.Database.Migrations
"MachineFamilyId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("DocumentsByMachineFamily");
}
}
}

View File

@@ -8,17 +8,12 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("Books",
table => new
migrationBuilder.CreateTable("Books", table => new
{
Id =
table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(),
NativeTitle = table.Column<string>(nullable: true),
Published = table.Column<DateTime>(nullable: true),
CountryId = table.Column<short>(nullable: true),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(), NativeTitle = table.Column<string>(nullable: true),
Published = table.Column<DateTime>(nullable: true), CountryId = table.Column<short>(nullable: true),
Synopsis = table.Column<string>(maxLength: 262144, nullable: true),
Isbn = table.Column<string>(maxLength: 13, nullable: true),
Pages = table.Column<short>(nullable: true),
@@ -28,11 +23,13 @@ namespace Marechai.Database.Migrations
}, constraints: table =>
{
table.PrimaryKey("PK_Books", x => x.Id);
table.ForeignKey("FK_Books_iso3166_1_numeric_CountryId", x => x.CountryId,
"iso3166_1_numeric", "id",
table.ForeignKey("FK_Books_iso3166_1_numeric_CountryId", x => x.CountryId, "iso3166_1_numeric", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("FK_Books_Books_PreviousId", x => x.PreviousId, "Books",
"Id", onDelete: ReferentialAction.Restrict);
table.ForeignKey("FK_Books_Books_PreviousId", x => x.PreviousId, "Books", "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("FK_Books_Books_SourceId", x => x.SourceId, "Books", "Id",
onDelete: ReferentialAction.Restrict);
});
@@ -53,15 +50,12 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_Books_SourceId", "Books", "SourceId");
migrationBuilder.CreateIndex("IX_Books_Synopsis", "Books", "Synopsis")
.Annotation("MySql:FullTextIndex", true);
migrationBuilder.CreateIndex("IX_Books_Synopsis", "Books", "Synopsis").
Annotation("MySql:FullTextIndex", true);
migrationBuilder.CreateIndex("IX_Books_Title", "Books", "Title");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("Books");
}
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("Books");
}
}

View File

@@ -7,25 +7,22 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("CompaniesByBooks",
table => new
migrationBuilder.CreateTable("CompaniesByBooks", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(),
BookId = table.Column<long>(),
RoleId = table.Column<string>("char(3)")
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(), BookId = table.Column<long>(), RoleId = table.Column<string>("char(3)")
}, constraints: table =>
{
table.PrimaryKey("PK_CompaniesByBooks", x => x.Id);
table.ForeignKey("FK_CompaniesByBooks_Books_BookId", x => x.BookId,
"Books", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByBooks_DocumentCompanies_CompanyId",
x => x.CompanyId, "DocumentCompanies", "Id",
table.ForeignKey("FK_CompaniesByBooks_Books_BookId", x => x.BookId, "Books", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByBooks_DocumentRoles_RoleId", x => x.RoleId,
"DocumentRoles", "Id",
table.ForeignKey("FK_CompaniesByBooks_DocumentCompanies_CompanyId", x => x.CompanyId,
"DocumentCompanies", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByBooks_DocumentRoles_RoleId", x => x.RoleId, "DocumentRoles", "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -36,9 +33,7 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_CompaniesByBooks_RoleId", "CompaniesByBooks", "RoleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("CompaniesByBooks");
}
}
}

View File

@@ -7,25 +7,22 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("PeopleByBooks",
table => new
migrationBuilder.CreateTable("PeopleByBooks", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(),
BookId = table.Column<long>(),
RoleId = table.Column<string>("char(3)")
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(), BookId = table.Column<long>(), RoleId = table.Column<string>("char(3)")
}, constraints: table =>
{
table.PrimaryKey("PK_PeopleByBooks", x => x.Id);
table.ForeignKey("FK_PeopleByBooks_Books_BookId", x => x.BookId, "Books",
"Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByBooks_DocumentPeople_PersonId",
x => x.PersonId, "DocumentPeople", "Id",
table.ForeignKey("FK_PeopleByBooks_Books_BookId", x => x.BookId, "Books", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByBooks_DocumentRoles_RoleId", x => x.RoleId,
"DocumentRoles", "Id",
table.ForeignKey("FK_PeopleByBooks_DocumentPeople_PersonId", x => x.PersonId, "DocumentPeople", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByBooks_DocumentRoles_RoleId", x => x.RoleId, "DocumentRoles", "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -36,9 +33,6 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_PeopleByBooks_RoleId", "PeopleByBooks", "RoleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("PeopleByBooks");
}
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("PeopleByBooks");
}
}

View File

@@ -7,21 +7,20 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("BooksByMachines",
table => new
migrationBuilder.CreateTable("BooksByMachines", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
BookId = table.Column<long>(),
MachineId = table.Column<int>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
BookId = table.Column<long>(), MachineId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_BooksByMachines", x => x.Id);
table.ForeignKey("FK_BooksByMachines_Books_BookId", x => x.BookId, "Books",
"Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_BooksByMachines_machines_MachineId", x => x.MachineId,
"machines", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_BooksByMachines_Books_BookId", x => x.BookId, "Books", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_BooksByMachines_machines_MachineId", x => x.MachineId, "machines", "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_BooksByMachines_BookId", "BooksByMachines", "BookId");
@@ -29,9 +28,7 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_BooksByMachines_MachineId", "BooksByMachines", "MachineId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("BooksByMachines");
}
}
}

View File

@@ -7,23 +7,20 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("BooksByMachineFamilies",
table => new
migrationBuilder.CreateTable("BooksByMachineFamilies", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
BookId = table.Column<long>(),
MachineFamilyId = table.Column<int>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
BookId = table.Column<long>(), MachineFamilyId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_BooksByMachineFamilies", x => x.Id);
table.ForeignKey("FK_BooksByMachineFamilies_Books_BookId", x => x.BookId,
"Books", "Id", onDelete: ReferentialAction.Cascade);
table
.ForeignKey("FK_BooksByMachineFamilies_machine_families_MachineFamilyId",
x => x.MachineFamilyId, "machine_families", "id",
table.ForeignKey("FK_BooksByMachineFamilies_Books_BookId", x => x.BookId, "Books", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_BooksByMachineFamilies_machine_families_MachineFamilyId", x => x.MachineFamilyId,
"machine_families", "id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_BooksByMachineFamilies_BookId", "BooksByMachineFamilies", "BookId");
@@ -32,9 +29,7 @@ namespace Marechai.Database.Migrations
"MachineFamilyId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("BooksByMachineFamilies");
}
}
}

View File

@@ -8,12 +8,10 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("Magazines",
table => new
migrationBuilder.CreateTable("Magazines", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(),
NativeTitle = table.Column<string>(nullable: true),
Published = table.Column<DateTime>(nullable: true),
@@ -24,9 +22,9 @@ namespace Marechai.Database.Migrations
}, constraints: table =>
{
table.PrimaryKey("PK_Magazines", x => x.Id);
table.ForeignKey("FK_Magazines_iso3166_1_numeric_CountryId",
x => x.CountryId, "iso3166_1_numeric", "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey("FK_Magazines_iso3166_1_numeric_CountryId", x => x.CountryId, "iso3166_1_numeric",
"id", onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex("IX_Magazines_CountryId", "Magazines", "CountryId");
@@ -39,15 +37,12 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_Magazines_Published", "Magazines", "Published");
migrationBuilder.CreateIndex("IX_Magazines_Synopsis", "Magazines", "Synopsis")
.Annotation("MySql:FullTextIndex", true);
migrationBuilder.CreateIndex("IX_Magazines_Synopsis", "Magazines", "Synopsis").
Annotation("MySql:FullTextIndex", true);
migrationBuilder.CreateIndex("IX_Magazines_Title", "Magazines", "Title");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("Magazines");
}
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("Magazines");
}
}

View File

@@ -8,23 +8,19 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("MagazineIssues",
table => new
migrationBuilder.CreateTable("MagazineIssues", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
MagazineId = table.Column<long>(),
Caption = table.Column<string>(),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MagazineId = table.Column<long>(), Caption = table.Column<string>(),
NativeCaption = table.Column<string>(nullable: true),
Published = table.Column<DateTime>(nullable: true),
ProductCode = table.Column<string>(maxLength: 18, nullable: true),
Pages = table.Column<short>()
ProductCode = table.Column<string>(maxLength: 18, nullable: true), Pages = table.Column<short>()
}, constraints: table =>
{
table.PrimaryKey("PK_MagazineIssues", x => x.Id);
table.ForeignKey("FK_MagazineIssues_Magazines_MagazineId",
x => x.MagazineId, "Magazines", "Id",
table.ForeignKey("FK_MagazineIssues_Magazines_MagazineId", x => x.MagazineId, "Magazines", "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -41,9 +37,6 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_MagazineIssues_Published", "MagazineIssues", "Published");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("MagazineIssues");
}
protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropTable("MagazineIssues");
}
}

View File

@@ -7,26 +7,23 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("CompaniesByMagazines",
table => new
migrationBuilder.CreateTable("CompaniesByMagazines", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(),
MagazineId = table.Column<long>(),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CompanyId = table.Column<int>(), MagazineId = table.Column<long>(),
RoleId = table.Column<string>("char(3)")
}, constraints: table =>
{
table.PrimaryKey("PK_CompaniesByMagazines", x => x.Id);
table.ForeignKey("FK_CompaniesByMagazines_DocumentCompanies_CompanyId",
x => x.CompanyId, "DocumentCompanies", "Id",
table.ForeignKey("FK_CompaniesByMagazines_DocumentCompanies_CompanyId", x => x.CompanyId,
"DocumentCompanies", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByMagazines_Magazines_MagazineId", x => x.MagazineId, "Magazines", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByMagazines_Magazines_MagazineId",
x => x.MagazineId, "Magazines", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_CompaniesByMagazines_DocumentRoles_RoleId",
x => x.RoleId, "DocumentRoles", "Id",
table.ForeignKey("FK_CompaniesByMagazines_DocumentRoles_RoleId", x => x.RoleId, "DocumentRoles", "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -37,9 +34,7 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_CompaniesByMagazines_RoleId", "CompaniesByMagazines", "RoleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("CompaniesByMagazines");
}
}
}

View File

@@ -7,26 +7,23 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("PeopleByMagazines",
table => new
migrationBuilder.CreateTable("PeopleByMagazines", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(),
MagazineId = table.Column<long>(),
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(), MagazineId = table.Column<long>(),
RoleId = table.Column<string>("char(3)")
}, constraints: table =>
{
table.PrimaryKey("PK_PeopleByMagazines", x => x.Id);
table.ForeignKey("FK_PeopleByMagazines_MagazineIssues_MagazineId",
x => x.MagazineId, "MagazineIssues", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByMagazines_DocumentPeople_PersonId",
x => x.PersonId, "DocumentPeople", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByMagazines_DocumentRoles_RoleId",
x => x.RoleId, "DocumentRoles", "Id",
table.ForeignKey("FK_PeopleByMagazines_MagazineIssues_MagazineId", x => x.MagazineId, "MagazineIssues",
"Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByMagazines_DocumentPeople_PersonId", x => x.PersonId, "DocumentPeople",
"Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByMagazines_DocumentRoles_RoleId", x => x.RoleId, "DocumentRoles", "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -37,9 +34,7 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_PeopleByMagazines_RoleId", "PeopleByMagazines", "RoleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("PeopleByMagazines");
}
}
}

View File

@@ -7,23 +7,20 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("MagazinesByMachines",
table => new
migrationBuilder.CreateTable("MagazinesByMachines", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
MagazineId = table.Column<long>(),
MachineId = table.Column<int>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MagazineId = table.Column<long>(), MachineId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_MagazinesByMachines", x => x.Id);
table.ForeignKey("FK_MagazinesByMachines_machines_MachineId",
x => x.MachineId, "machines", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_MagazinesByMachines_MagazineIssues_MagazineId",
x => x.MagazineId, "MagazineIssues", "Id",
table.ForeignKey("FK_MagazinesByMachines_machines_MachineId", x => x.MachineId, "machines", "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_MagazinesByMachines_MagazineIssues_MagazineId", x => x.MagazineId,
"MagazineIssues", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_MagazinesByMachines_MachineId", "MagazinesByMachines", "MachineId");
@@ -31,9 +28,7 @@ namespace Marechai.Database.Migrations
migrationBuilder.CreateIndex("IX_MagazinesByMachines_MagazineId", "MagazinesByMachines", "MagazineId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("MagazinesByMachines");
}
}
}

View File

@@ -7,25 +7,20 @@ namespace Marechai.Database.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("MagazinesByMachinesFamilies",
table => new
migrationBuilder.CreateTable("MagazinesByMachinesFamilies", table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
MagazineId = table.Column<long>(),
MachineFamilyId = table.Column<int>()
Id = table.Column<long>().
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MagazineId = table.Column<long>(), MachineFamilyId = table.Column<int>()
}, constraints: table =>
{
table.PrimaryKey("PK_MagazinesByMachinesFamilies", x => x.Id);
table
.ForeignKey("FK_MagazinesByMachinesFamilies_machine_families_MachineFamilyId",
x => x.MachineFamilyId, "machine_families", "id",
onDelete: ReferentialAction.Cascade);
table
.ForeignKey("FK_MagazinesByMachinesFamilies_MagazineIssues_MagazineId",
x => x.MagazineId, "MagazineIssues", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_MagazinesByMachinesFamilies_machine_families_MachineFamilyId",
x => x.MachineFamilyId, "machine_families", "id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_MagazinesByMachinesFamilies_MagazineIssues_MagazineId", x => x.MagazineId,
"MagazineIssues", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_MagazinesByMachinesFamilies_MachineFamilyId",
@@ -35,9 +30,7 @@ namespace Marechai.Database.Migrations
"MagazineId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("MagazinesByMachinesFamilies");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -35,22 +35,15 @@ namespace Marechai.Database.Models
{
public class BrowserTest : BaseModel<int>
{
[DisplayName("User agent")]
[Required]
[StringLength(128)]
[DisplayName("User agent"), Required, StringLength(128)]
public string UserAgent { get; set; }
[Required]
[StringLength(64)]
[Required, StringLength(64)]
public string Browser { get; set; }
[Required]
[StringLength(16)]
[Required, StringLength(16)]
public string Version { get; set; }
[DisplayName("Operating system")]
[Required]
[StringLength(32)]
[DisplayName("Operating system"), Required, StringLength(32)]
public string Os { get; set; }
[Required]
[StringLength(8)]
[Required, StringLength(8)]
public string Platform { get; set; }
[DisplayName("GIF87")]
public bool Gif87 { get; set; }

View File

@@ -7,8 +7,7 @@ namespace Marechai.Database.Models
{
public int CompanyId { get; set; }
public long BookId { get; set; }
[Column(TypeName = "char(3)")]
[Required]
[Column(TypeName = "char(3)"), Required]
public string RoleId { get; set; }
public virtual DocumentCompany Company { get; set; }

View File

@@ -7,8 +7,7 @@ namespace Marechai.Database.Models
{
public int CompanyId { get; set; }
public long DocumentId { get; set; }
[Column(TypeName = "char(3)")]
[Required]
[Column(TypeName = "char(3)"), Required]
public string RoleId { get; set; }
public virtual DocumentCompany Company { get; set; }

View File

@@ -7,8 +7,7 @@ namespace Marechai.Database.Models
{
public int CompanyId { get; set; }
public long MagazineId { get; set; }
[Column(TypeName = "char(3)")]
[Required]
[Column(TypeName = "char(3)"), Required]
public string RoleId { get; set; }
public virtual DocumentCompany Company { get; set; }

View File

@@ -52,18 +52,15 @@ namespace Marechai.Database.Models
[Required]
public string Name { get; set; }
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true), DataType(DataType.Date)]
public DateTime? Founded { get; set; }
[Url]
[StringLength(255)]
[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)]
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
public DateTime? Sold { get; set; }
public int? SoldToId { get; set; }
[StringLength(80)]
@@ -72,8 +69,7 @@ namespace Marechai.Database.Models
public string City { get; set; }
[StringLength(80)]
public string Province { get; set; }
[StringLength(25)]
[DisplayName("Postal code")]
[StringLength(25), DisplayName("Postal code")]
public string PostalCode { get; set; }
public short? CountryId { get; set; }
[Required]
@@ -96,10 +92,8 @@ namespace Marechai.Database.Models
Logos?.OrderByDescending(l => l.Year).FirstOrDefault();
public virtual DocumentCompany DocumentCompany { get; set; }
[DisplayName("Sold")]
[NotMapped]
public string SoldView =>
Status != CompanyStatus.Active && Status != CompanyStatus.Unknown
[DisplayName("Sold"), NotMapped]
public string SoldView => Status != CompanyStatus.Active && Status != CompanyStatus.Unknown
? Sold is null
? "Unknown"
: Sold.Value.ToShortDateString()

View File

@@ -36,11 +36,9 @@ namespace Marechai.Database.Models
public class CompanyDescription : BaseModel<int>
{
public int CompanyId { get; set; }
[MaxLength(262144, ErrorMessage = "Description is too long")]
[Required]
[MaxLength(262144, ErrorMessage = "Description is too long"), Required]
public string Text { get; set; }
[MaxLength(262144, ErrorMessage = "Description is too long")]
[DisplayName("HTML")]
[MaxLength(262144, ErrorMessage = "Description is too long"), DisplayName("HTML")]
public string Html { get; set; }
public virtual Company Company { get; set; }

View File

@@ -45,9 +45,7 @@ namespace Marechai.Database.Models
public virtual Company Company { get; set; }
[NotMapped]
[Required(ErrorMessage = "SVG logo required")]
[DisplayName("Upload SVG logo:")]
[NotMapped, Required(ErrorMessage = "SVG logo required"), DisplayName("Upload SVG logo:")]
public IFormFile SvgLogo { get; set; }
[NotMapped]

View File

@@ -8,8 +8,7 @@ namespace Marechai.Database.Models
[Required]
public string Title { get; set; }
public string NativeTitle { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
public DateTime? Published { get; set; }
public short? CountryId { get; set; }
[MaxLength(262144, ErrorMessage = "Synopsis is too long")]

View File

@@ -16,8 +16,7 @@ namespace Marechai.Database.Models
[DisplayName("Name to be displayed")]
public string DisplayName { get; set; }
[NotMapped]
[DisplayName("Name")]
[NotMapped, DisplayName("Name")]
public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}";
[DisplayName("Linked person")]

View File

@@ -5,9 +5,7 @@ namespace Marechai.Database.Models
{
public class DocumentRole
{
[Column(TypeName = "char(3)")]
[Key]
[Required]
[Column(TypeName = "char(3)"), Key, Required]
public string Id { get; set; }
public string Name { get; set; }
public bool Enabled { get; set; }

View File

@@ -45,15 +45,12 @@ namespace Marechai.Database.Models
ResolutionsByGpu = new HashSet<ResolutionsByGpu>();
}
[Required]
[StringLength(128)]
[Required, StringLength(128)]
public string Name { get; set; }
public int? CompanyId { get; set; }
[DisplayName("Model code")]
[StringLength(45)]
[DisplayName("Model code"), StringLength(45)]
public string ModelCode { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
public DateTime? Introduced { get; set; }
[StringLength(45)]
public string Package { get; set; }

View File

@@ -36,14 +36,9 @@ namespace Marechai.Database.Models
{
public class InstructionSet : BaseModel<int>
{
public InstructionSet()
{
Processors = new HashSet<Processor>();
}
public InstructionSet() => Processors = new HashSet<Processor>();
[Required]
[StringLength(45)]
[Remote("VerifyUnique", "InstructionSets", "Admin")]
[Required, StringLength(45), Remote("VerifyUnique", "InstructionSets", "Admin")]
public string Name { get; set; }
public virtual ICollection<Processor> Processors { get; set; }

View File

@@ -37,15 +37,10 @@ namespace Marechai.Database.Models
{
public class InstructionSetExtension : BaseModel<int>
{
public InstructionSetExtension()
{
public InstructionSetExtension() =>
InstructionSetExtensionsByProcessor = new HashSet<InstructionSetExtensionsByProcessor>();
}
[DisplayName("Name")]
[Required]
[StringLength(45)]
[Remote("VerifyUnique", "InstructionSetExtensions", "Admin")]
[DisplayName("Name"), Required, StringLength(45), Remote("VerifyUnique", "InstructionSetExtensions", "Admin")]
public string Extension { get; set; }
public virtual ICollection<InstructionSetExtensionsByProcessor> InstructionSetExtensionsByProcessor

View File

@@ -35,15 +35,11 @@ namespace Marechai.Database.Models
{
public class Iso31661Numeric
{
public Iso31661Numeric()
{
Companies = new HashSet<Company>();
}
public Iso31661Numeric() => Companies = new HashSet<Company>();
[Required]
public short Id { get; set; }
[Required]
[StringLength(64)]
[Required, StringLength(64)]
public string Name { get; set; }
public virtual ICollection<Company> Companies { get; set; }

View File

@@ -3,14 +3,10 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Marechai.Database.Models
{
/// <summary>
/// ISO-639 codes
/// </summary>
/// <summary>ISO-639 codes</summary>
public class Iso639
{
[Column(TypeName = "char(3)")]
[Key]
[Required]
[Column(TypeName = "char(3)"), Key, Required]
public string Id { get; set; }
[Column(TypeName = "char(3)")]
public string Part2B { get; set; }
@@ -18,14 +14,11 @@ namespace Marechai.Database.Models
public string Part2T { get; set; }
[Column(TypeName = "char(2)")]
public string Part1 { get; set; }
[Column(TypeName = "char(1)")]
[Required]
[Column(TypeName = "char(1)"), Required]
public string Scope { get; set; }
[Column(TypeName = "char(1)")]
[Required]
[Column(TypeName = "char(1)"), Required]
public string Type { get; set; }
[Column(TypeName = "varchar(150)")]
[Required]
[Column(TypeName = "varchar(150)"), Required]
public string ReferenceName { get; set; }
[Column(TypeName = "varchar(150)")]
public string Comment { get; set; }

View File

@@ -11,20 +11,14 @@ namespace Marechai.Database.Models
public string Name { get; set; }
[DisplayName("SPDX identifier")]
public string SPDX { get; set; }
[DisplayName("FSF approved")]
[Required]
[DisplayName("FSF approved"), Required]
public bool FsfApproved { get; set; }
[DisplayName("OSI approved")]
[Required]
[DisplayName("OSI approved"), Required]
public bool OsiApproved { get; set; }
[DisplayName("License text link")]
[StringLength(512)]
[Url]
[DisplayName("License text link"), StringLength(512), Url]
public string Link { get; set; }
[DisplayName("License text")]
[Column(TypeName = "longtext")]
[StringLength(131072)]
[DataType(DataType.MultilineText)]
[DisplayName("License text"), Column(TypeName = "longtext"), StringLength(131072),
DataType(DataType.MultilineText)]
public string Text { get; set; }
public virtual ICollection<MachinePhoto> Photos { get; set; }
public virtual ICollection<OwnedMachinePhoto> OwnedMachinePhotos { get; set; }

View File

@@ -49,13 +49,11 @@ namespace Marechai.Database.Models
[Required]
public int CompanyId { get; set; }
[Required]
[StringLength(255)]
[Required, StringLength(255)]
public string Name { get; set; }
[Required]
public MachineType Type { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
public DateTime? Introduced { get; set; }
public int? FamilyId { get; set; }
[StringLength(50)]
@@ -74,8 +72,7 @@ namespace Marechai.Database.Models
public virtual ICollection<BooksByMachine> Books { get; set; }
public virtual ICollection<MagazinesByMachine> Magazines { get; set; }
[NotMapped]
[DisplayName("Introduced")]
[NotMapped, DisplayName("Introduced")]
public string IntroducedView =>
Introduced == DateTime.MinValue ? "Prototype" : Introduced?.ToShortDateString() ?? "Unknown";
}

View File

@@ -35,14 +35,10 @@ namespace Marechai.Database.Models
{
public class MachineFamily : BaseModel<int>
{
public MachineFamily()
{
Machines = new HashSet<Machine>();
}
public MachineFamily() => Machines = new HashSet<Machine>();
public int CompanyId { get; set; }
[Required]
[StringLength(255)]
[Required, StringLength(255)]
public string Name { get; set; }
public virtual Company Company { get; set; }

View File

@@ -8,8 +8,7 @@ namespace Marechai.Database.Models
{
[StringLength(8, MinimumLength = 8)]
public string Issn { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
public DateTime? FirstPublication { get; set; }
public virtual Iso31661Numeric Country { get; set; }

View File

@@ -11,8 +11,7 @@ namespace Marechai.Database.Models
[Required]
public string Caption { get; set; }
public string NativeCaption { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
public DateTime? Published { get; set; }
[StringLength(18)]
public string ProductCode { get; set; }

View File

@@ -99,9 +99,10 @@ namespace Marechai.Database.Models
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if(optionsBuilder.IsConfigured) return;
if(optionsBuilder.IsConfigured)
return;
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http: //go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
optionsBuilder.UseMySql("server=localhost;port=3306;user=marechai;password=marechaipass;database=marechai");
optionsBuilder.UseLazyLoadingProxies();
}
@@ -128,11 +129,11 @@ namespace Marechai.Database.Models
entity.HasIndex(e => e.Edition);
entity.HasOne(d => d.Previous).WithOne(d => d.Next).HasForeignKey<Book>(d => d.PreviousId)
.OnDelete(DeleteBehavior.ClientSetNull);
entity.HasOne(d => d.Previous).WithOne(d => d.Next).HasForeignKey<Book>(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);
});
@@ -175,51 +176,51 @@ namespace Marechai.Database.Models
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.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.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<MarechaiDb>(entity =>
@@ -228,8 +229,8 @@ namespace Marechai.Database.Models
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)");
});
@@ -315,8 +316,8 @@ namespace Marechai.Database.Models
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)");
@@ -332,21 +333,24 @@ namespace Marechai.Database.Models
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<DocumentCompany>(d => d.CompanyId).OnDelete(DeleteBehavior.SetNull);
entity.HasOne(d => d.DocumentCompany).WithOne(p => p.Company).
HasForeignKey<DocumentCompany>(d => d.CompanyId).OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<CompanyDescription>().HasIndex(e => e.Text).ForMySqlIsFullText();
modelBuilder.Entity<CompanyLogo>(entity =>
{
entity.HasKey(e => new {e.Id, e.CompanyId, LogoGuid = e.Guid});
entity.HasKey(e => new
{
e.Id, e.CompanyId, LogoGuid = e.Guid
});
entity.ToTable("company_logos");
@@ -364,8 +368,8 @@ namespace Marechai.Database.Models
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");
entity.HasOne(d => d.Company).WithMany(p => p.Logos).HasForeignKey(d => d.CompanyId).
OnDelete(DeleteBehavior.ClientSetNull).HasConstraintName("fk_company_logos_company1");
});
modelBuilder.Entity<Document>(entity =>
@@ -402,8 +406,8 @@ namespace Marechai.Database.Models
entity.HasIndex(e => e.DisplayName);
entity.HasOne(d => d.Person).WithOne(p => p.DocumentPerson)
.HasForeignKey<Person>(d => d.DocumentPersonId).OnDelete(DeleteBehavior.SetNull);
entity.HasOne(d => d.Person).WithOne(p => p.DocumentPerson).
HasForeignKey<Person>(d => d.DocumentPersonId).OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<DocumentRole>(entity =>
@@ -451,17 +455,17 @@ namespace Marechai.Database.Models
entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)");
entity.Property(e => e.Browser).IsRequired().HasColumnName("browser").HasColumnType("char(128)")
.HasDefaultValueSql("''");
entity.Property(e => e.Browser).IsRequired().HasColumnName("browser").HasColumnType("char(128)").
HasDefaultValueSql("''");
entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("char(20)")
.HasDefaultValueSql("''");
entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("char(20)").
HasDefaultValueSql("''");
entity.Property(e => e.Ip).IsRequired().HasColumnName("ip").HasColumnType("char(16)")
.HasDefaultValueSql("''");
entity.Property(e => e.Ip).IsRequired().HasColumnName("ip").HasColumnType("char(16)").
HasDefaultValueSql("''");
entity.Property(e => e.Referer).IsRequired().HasColumnName("referer").HasColumnType("char(255)")
.HasDefaultValueSql("''");
entity.Property(e => e.Referer).IsRequired().HasColumnName("referer").HasColumnType("char(255)").
HasDefaultValueSql("''");
});
modelBuilder.Entity<Gpu>(entity =>
@@ -496,8 +500,8 @@ namespace Marechai.Database.Models
entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)");
entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(128)")
.HasDefaultValueSql("''");
entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(128)").
HasDefaultValueSql("''");
entity.Property(e => e.Package).HasColumnName("package").HasColumnType("varchar(45)");
@@ -507,8 +511,8 @@ namespace Marechai.Database.Models
entity.Property(e => e.Transistors).HasColumnName("transistors").HasColumnType("bigint(20)");
entity.HasOne(d => d.Company).WithMany(p => p.Gpus).HasForeignKey(d => d.CompanyId)
.HasConstraintName("fk_gpus_company");
entity.HasOne(d => d.Company).WithMany(p => p.Gpus).HasForeignKey(d => d.CompanyId).
HasConstraintName("fk_gpus_company");
});
modelBuilder.Entity<GpusByMachine>(entity =>
@@ -525,11 +529,11 @@ namespace Marechai.Database.Models
entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)");
entity.HasOne(d => d.Gpu).WithMany(p => p.GpusByMachine).HasForeignKey(d => d.GpuId)
.HasConstraintName("fk_gpus_by_machine_gpu");
entity.HasOne(d => d.Gpu).WithMany(p => p.GpusByMachine).HasForeignKey(d => d.GpuId).
HasConstraintName("fk_gpus_by_machine_gpu");
entity.HasOne(d => d.Machine).WithMany(p => p.Gpus).HasForeignKey(d => d.MachineId)
.HasConstraintName("fk_gpus_by_machine_machine");
entity.HasOne(d => d.Machine).WithMany(p => p.Gpus).HasForeignKey(d => d.MachineId).
HasConstraintName("fk_gpus_by_machine_machine");
});
modelBuilder.Entity<GpusByOwnedMachine>(entity =>
@@ -552,7 +556,10 @@ namespace Marechai.Database.Models
modelBuilder.Entity<InstructionSetExtensionsByProcessor>(entity =>
{
entity.HasKey(e => new {e.Id, e.ProcessorId, e.ExtensionId});
entity.HasKey(e => new
{
e.Id, e.ProcessorId, e.ExtensionId
});
entity.ToTable("instruction_set_extensions_by_processor");
@@ -566,13 +573,13 @@ namespace Marechai.Database.Models
entity.Property(e => e.ExtensionId).HasColumnName("extension_id").HasColumnType("int(11)");
entity.HasOne(d => d.Extension).WithMany(p => p.InstructionSetExtensionsByProcessor)
.HasForeignKey(d => d.ExtensionId).OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_extension_extension_id");
entity.HasOne(d => d.Extension).WithMany(p => p.InstructionSetExtensionsByProcessor).
HasForeignKey(d => d.ExtensionId).OnDelete(DeleteBehavior.ClientSetNull).
HasConstraintName("fk_extension_extension_id");
entity.HasOne(d => d.Processor).WithMany(p => p.InstructionSetExtensions)
.HasForeignKey(d => d.ProcessorId).OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_extension_processor_id");
entity.HasOne(d => d.Processor).WithMany(p => p.InstructionSetExtensions).
HasForeignKey(d => d.ProcessorId).OnDelete(DeleteBehavior.ClientSetNull).
HasConstraintName("fk_extension_processor_id");
});
modelBuilder.Entity<InstructionSet>(entity =>
@@ -632,17 +639,17 @@ namespace Marechai.Database.Models
entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)");
entity.Property(e => e.Browser).IsRequired().HasColumnName("browser").HasColumnType("char(128)")
.HasDefaultValueSql("''");
entity.Property(e => e.Browser).IsRequired().HasColumnName("browser").HasColumnType("char(128)").
HasDefaultValueSql("''");
entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("char(20)")
.HasDefaultValueSql("''");
entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("char(20)").
HasDefaultValueSql("''");
entity.Property(e => e.Ip).IsRequired().HasColumnName("ip").HasColumnType("char(16)")
.HasDefaultValueSql("''");
entity.Property(e => e.Ip).IsRequired().HasColumnName("ip").HasColumnType("char(16)").
HasDefaultValueSql("''");
entity.Property(e => e.Referer).IsRequired().HasColumnName("referer").HasColumnType("char(255)")
.HasDefaultValueSql("''");
entity.Property(e => e.Referer).IsRequired().HasColumnName("referer").HasColumnType("char(255)").
HasDefaultValueSql("''");
});
modelBuilder.Entity<MachineFamily>(entity =>
@@ -659,8 +666,8 @@ namespace Marechai.Database.Models
entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("varchar(255)");
entity.HasOne(d => d.Company).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.CompanyId)
.HasConstraintName("fk_machine_families_company");
entity.HasOne(d => d.Company).WithMany(p => p.MachineFamilies).HasForeignKey(d => d.CompanyId).
HasConstraintName("fk_machine_families_company");
});
modelBuilder.Entity<Machine>(entity =>
@@ -681,8 +688,8 @@ namespace Marechai.Database.Models
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)").
HasDefaultValueSql("'0'");
entity.Property(e => e.FamilyId).HasColumnName("family").HasColumnType("int(11)");
@@ -694,11 +701,11 @@ namespace Marechai.Database.Models
entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'");
entity.HasOne(d => d.Company).WithMany(p => p.Machines).HasForeignKey(d => d.CompanyId)
.OnDelete(DeleteBehavior.ClientSetNull).HasConstraintName("fk_machines_company");
entity.HasOne(d => d.Company).WithMany(p => p.Machines).HasForeignKey(d => d.CompanyId).
OnDelete(DeleteBehavior.ClientSetNull).HasConstraintName("fk_machines_company");
entity.HasOne(d => d.Family).WithMany(p => p.Machines).HasForeignKey(d => d.FamilyId)
.HasConstraintName("fk_machines_family");
entity.HasOne(d => d.Family).WithMany(p => p.Machines).HasForeignKey(d => d.FamilyId).
HasConstraintName("fk_machines_family");
});
modelBuilder.Entity<OwnedMachine>(entity =>
@@ -954,8 +961,8 @@ namespace Marechai.Database.Models
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");
entity.HasOne(d => d.Machine).WithMany(p => p.Memory).HasForeignKey(d => d.MachineId).
HasConstraintName("fk_memory_by_machine_machine");
});
modelBuilder.Entity<MemoryByOwnedMachine>(entity =>
@@ -983,11 +990,11 @@ namespace Marechai.Database.Models
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.Donator).IsRequired().HasColumnName("donator").HasColumnType("char(128)").
HasDefaultValueSql("''");
entity.Property(e => e.Quantity).HasColumnName("quantity").HasColumnType("decimal(11,2)")
.HasDefaultValueSql("'0.00'");
entity.Property(e => e.Quantity).HasColumnName("quantity").HasColumnType("decimal(11,2)").
HasDefaultValueSql("'0.00'");
});
modelBuilder.Entity<News>(entity =>
@@ -1002,8 +1009,8 @@ namespace Marechai.Database.Models
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.AddedId).HasColumnName("added_id").HasColumnType("int(11)").
HasDefaultValueSql("'0'");
entity.Property(e => e.Date).IsRequired().HasColumnName("date").HasColumnType("datetime");
@@ -1086,8 +1093,8 @@ namespace Marechai.Database.Models
entity.HasOne(d => d.CountryOfBirth).WithMany(p => p.People).HasForeignKey(d => d.CountryOfBirthId);
entity.HasOne(d => d.DocumentPerson).WithOne(p => p.Person)
.HasForeignKey<DocumentPerson>(d => d.PersonId).OnDelete(DeleteBehavior.SetNull);
entity.HasOne(d => d.DocumentPerson).WithOne(p => p.Person).
HasForeignKey<DocumentPerson>(d => d.PersonId).OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<Processor>(entity =>
@@ -1174,8 +1181,8 @@ namespace Marechai.Database.Models
entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)");
entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(50)")
.HasDefaultValueSql("''");
entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(50)").
HasDefaultValueSql("''");
entity.Property(e => e.Package).HasColumnName("package").HasColumnType("varchar(45)");
@@ -1193,11 +1200,11 @@ namespace Marechai.Database.Models
entity.Property(e => e.Transistors).HasColumnName("transistors").HasColumnType("bigint(20)");
entity.HasOne(d => d.Company).WithMany(p => p.Processors).HasForeignKey(d => d.CompanyId)
.HasConstraintName("fk_processors_company");
entity.HasOne(d => d.Company).WithMany(p => p.Processors).HasForeignKey(d => d.CompanyId).
HasConstraintName("fk_processors_company");
entity.HasOne(d => d.InstructionSet).WithMany(p => p.Processors).HasForeignKey(d => d.InstructionSetId)
.HasConstraintName("fk_processors_instruction_set");
entity.HasOne(d => d.InstructionSet).WithMany(p => p.Processors).HasForeignKey(d => d.InstructionSetId).
HasConstraintName("fk_processors_instruction_set");
});
modelBuilder.Entity<ProcessorsByMachine>(entity =>
@@ -1218,11 +1225,11 @@ namespace Marechai.Database.Models
entity.Property(e => e.Speed).HasColumnName("speed");
entity.HasOne(d => d.Machine).WithMany(p => p.Processors).HasForeignKey(d => d.MachineId)
.HasConstraintName("fk_processors_by_machine_machine");
entity.HasOne(d => d.Machine).WithMany(p => p.Processors).HasForeignKey(d => d.MachineId).
HasConstraintName("fk_processors_by_machine_machine");
entity.HasOne(d => d.Processor).WithMany(p => p.ProcessorsByMachine).HasForeignKey(d => d.ProcessorId)
.HasConstraintName("fk_processors_by_machine_processor");
entity.HasOne(d => d.Processor).WithMany(p => p.ProcessorsByMachine).HasForeignKey(d => d.ProcessorId).
HasConstraintName("fk_processors_by_machine_processor");
});
modelBuilder.Entity<ProcessorsByOwnedMachine>(entity =>
@@ -1248,23 +1255,30 @@ namespace Marechai.Database.Models
entity.HasIndex(e => e.Width).HasName("idx_resolutions_width");
entity.HasIndex(e => new {e.Width, e.Height}).HasName("idx_resolutions_resolution");
entity.HasIndex(e => new
{
e.Width, e.Height
}).HasName("idx_resolutions_resolution");
entity.HasIndex(e => new {e.Width, e.Height, e.Colors})
.HasName("idx_resolutions_resolution_with_color");
entity.HasIndex(e => new
{
e.Width, e.Height, e.Colors
}).HasName("idx_resolutions_resolution_with_color");
entity.HasIndex(e => new {e.Width, e.Height, e.Colors, e.Palette})
.HasName("idx_resolutions_resolution_with_color_and_palette");
entity.HasIndex(e => new
{
e.Width, e.Height, e.Colors, e.Palette
}).HasName("idx_resolutions_resolution_with_color_and_palette");
entity.Property(e => e.Id).HasColumnName("id").HasColumnType("int(11)");
entity.Property(e => e.Chars).HasColumnName("chars").HasColumnType("tinyint(1)")
.HasDefaultValueSql("'0'");
entity.Property(e => e.Chars).HasColumnName("chars").HasColumnType("tinyint(1)").
HasDefaultValueSql("'0'");
entity.Property(e => e.Colors).HasColumnName("colors").HasColumnType("bigint(20)");
entity.Property(e => e.Height).HasColumnName("height").HasColumnType("int(11)")
.HasDefaultValueSql("'0'");
entity.Property(e => e.Height).HasColumnName("height").HasColumnType("int(11)").
HasDefaultValueSql("'0'");
entity.Property(e => e.Palette).HasColumnName("palette").HasColumnType("bigint(20)");
@@ -1285,11 +1299,11 @@ namespace Marechai.Database.Models
entity.Property(e => e.ResolutionId).HasColumnName("resolution").HasColumnType("int(11)");
entity.HasOne(d => d.Gpu).WithMany(p => p.ResolutionsByGpu).HasForeignKey(d => d.GpuId)
.HasConstraintName("fk_resolutions_by_gpu_gpu");
entity.HasOne(d => d.Gpu).WithMany(p => p.ResolutionsByGpu).HasForeignKey(d => d.GpuId).
HasConstraintName("fk_resolutions_by_gpu_gpu");
entity.HasOne(d => d.Resolution).WithMany(p => p.ResolutionsByGpu).HasForeignKey(d => d.ResolutionId)
.HasConstraintName("fk_resolutions_by_gpu_resolution");
entity.HasOne(d => d.Resolution).WithMany(p => p.ResolutionsByGpu).HasForeignKey(d => d.ResolutionId).
HasConstraintName("fk_resolutions_by_gpu_resolution");
});
modelBuilder.Entity<ResolutionsByScreen>(entity =>
@@ -1335,11 +1349,11 @@ namespace Marechai.Database.Models
entity.Property(e => e.SoundSynthId).HasColumnName("sound_synth").HasColumnType("int(11)");
entity.HasOne(d => d.Machine).WithMany(p => p.Sound).HasForeignKey(d => d.MachineId)
.HasConstraintName("fk_sound_by_machine_machine");
entity.HasOne(d => d.Machine).WithMany(p => p.Sound).HasForeignKey(d => d.MachineId).
HasConstraintName("fk_sound_by_machine_machine");
entity.HasOne(d => d.SoundSynth).WithMany(p => p.SoundByMachine).HasForeignKey(d => d.SoundSynthId)
.HasConstraintName("fk_sound_by_machine_sound_synth");
entity.HasOne(d => d.SoundSynth).WithMany(p => p.SoundByMachine).HasForeignKey(d => d.SoundSynthId).
HasConstraintName("fk_sound_by_machine_sound_synth");
});
modelBuilder.Entity<SoundByOwnedMachine>(entity =>
@@ -1387,8 +1401,8 @@ namespace Marechai.Database.Models
entity.Property(e => e.ModelCode).HasColumnName("model_code").HasColumnType("varchar(45)");
entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(50)")
.HasDefaultValueSql("''");
entity.Property(e => e.Name).IsRequired().HasColumnName("name").HasColumnType("char(50)").
HasDefaultValueSql("''");
entity.Property(e => e.SquareWave).HasColumnName("square_wave").HasColumnType("int(11)");
@@ -1398,8 +1412,8 @@ namespace Marechai.Database.Models
entity.Property(e => e.WhiteNoise).HasColumnName("white_noise").HasColumnType("int(11)");
entity.HasOne(d => d.Company).WithMany(p => p.SoundSynths).HasForeignKey(d => d.CompanyId)
.HasConstraintName("fk_sound_synths_company");
entity.HasOne(d => d.Company).WithMany(p => p.SoundSynths).HasForeignKey(d => d.CompanyId).
HasConstraintName("fk_sound_synths_company");
});
modelBuilder.Entity<StorageByMachine>(entity =>
@@ -1418,15 +1432,15 @@ namespace Marechai.Database.Models
entity.Property(e => e.Capacity).HasColumnName("capacity").HasColumnType("bigint(20)");
entity.Property(e => e.Interface).HasColumnName("interface").HasColumnType("int(11)")
.HasDefaultValueSql("'0'");
entity.Property(e => e.Interface).HasColumnName("interface").HasColumnType("int(11)").
HasDefaultValueSql("'0'");
entity.Property(e => e.MachineId).HasColumnName("machine").HasColumnType("int(11)");
entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'");
entity.HasOne(d => d.Machine).WithMany(p => p.Storage).HasForeignKey(d => d.MachineId)
.HasConstraintName("fk_storage_by_machine_machine");
entity.HasOne(d => d.Machine).WithMany(p => p.Storage).HasForeignKey(d => d.MachineId).
HasConstraintName("fk_storage_by_machine_machine");
});
modelBuilder.Entity<StorageByOwnedMachine>(entity =>

View File

@@ -7,8 +7,7 @@ namespace Marechai.Database.Models
{
public int PersonId { get; set; }
public long BookId { get; set; }
[Column(TypeName = "char(3)")]
[Required]
[Column(TypeName = "char(3)"), Required]
public string RoleId { get; set; }
public virtual DocumentPerson Person { get; set; }

View File

@@ -7,8 +7,7 @@ namespace Marechai.Database.Models
{
public int PersonId { get; set; }
public long DocumentId { get; set; }
[Column(TypeName = "char(3)")]
[Required]
[Column(TypeName = "char(3)"), Required]
public string RoleId { get; set; }
public virtual DocumentPerson Person { get; set; }

View File

@@ -7,8 +7,7 @@ namespace Marechai.Database.Models
{
public int PersonId { get; set; }
public long MagazineId { get; set; }
[Column(TypeName = "char(3)")]
[Required]
[Column(TypeName = "char(3)"), Required]
public string RoleId { get; set; }
public virtual DocumentPerson Person { get; set; }

View File

@@ -15,11 +15,9 @@ namespace Marechai.Database.Models
public string Surname { get; set; }
[DisplayName("Country of birth")]
public virtual Iso31661Numeric CountryOfBirth { get; set; }
[DisplayName("Birth date")]
[DataType(DataType.Date)]
[DisplayName("Birth date"), DataType(DataType.Date)]
public DateTime BirthDate { get; set; }
[DisplayName("Date of death")]
[DataType(DataType.Date)]
[DisplayName("Date of death"), DataType(DataType.Date)]
public DateTime? DeathDate { get; set; }
[Url]
public string Webpage { get; set; }
@@ -32,8 +30,7 @@ namespace Marechai.Database.Models
[DisplayName("Name to be displayed")]
public string DisplayName { get; set; }
[NotMapped]
[DisplayName("Name")]
[NotMapped, DisplayName("Name")]
public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}";
public short? CountryOfBirthId { get; set; }

View File

@@ -45,15 +45,12 @@ namespace Marechai.Database.Models
ProcessorsByMachine = new HashSet<ProcessorsByMachine>();
}
[Required]
[StringLength(50)]
[Required, StringLength(50)]
public string Name { get; set; }
public int? CompanyId { get; set; }
[DisplayName("Model code")]
[StringLength(45)]
[DisplayName("Model code"), StringLength(45)]
public string ModelCode { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
public DateTime? Introduced { get; set; }
[DisplayName("Instruction set")]
public int? InstructionSetId { get; set; }

View File

@@ -36,16 +36,11 @@ namespace Marechai.Database.Models
{
public class Resolution : BaseModel<int>
{
public Resolution()
{
ResolutionsByGpu = new HashSet<ResolutionsByGpu>();
}
public Resolution() => ResolutionsByGpu = new HashSet<ResolutionsByGpu>();
[Required]
[Range(1, 131072)]
[Required, Range(1, 131072)]
public int Width { get; set; }
[Required]
[Range(1, 131072)]
[Required, Range(1, 131072)]
public int Height { get; set; }
[Range(2, 281474976710656)]
public long? Colors { get; set; }
@@ -66,27 +61,27 @@ namespace Marechai.Database.Models
{
if(Chars)
{
if(Colors == null) return $"{Width}x{Height} characters";
if(Colors == null)
return$"{Width}x{Height} characters";
if(Palette != null && Colors != Palette)
return Grayscale
? $"{Width}x{Height} characters at {Colors} grays from a palette of {Palette}"
if(Palette != null &&
Colors != Palette)
return Grayscale ? $"{Width}x{Height} characters at {Colors} grays from a palette of {Palette}"
: $"{Width}x{Height} characters at {Colors} colors from a palette of {Palette}";
return Colors == 2 && Grayscale
? $"{Width}x{Height} black and white characters"
return Colors == 2 && Grayscale ? $"{Width}x{Height} black and white characters"
: $"{Width}x{Height} characters at {Colors} colors";
}
if(Colors == null) return $"{Width}x{Height} pixels";
if(Colors == null)
return$"{Width}x{Height} pixels";
if(Palette != null && Colors != Palette)
return Grayscale
? $"{Width}x{Height} pixels at {Colors} grays from a palette of {Palette}"
if(Palette != null &&
Colors != Palette)
return Grayscale ? $"{Width}x{Height} pixels at {Colors} grays from a palette of {Palette}"
: $"{Width}x{Height} pixels at {Colors} colors from a palette of {Palette}";
return Colors == 2 && Grayscale
? $"{Width}x{Height} black and white pixels"
return Colors == 2 && Grayscale ? $"{Width}x{Height} black and white pixels"
: $"{Width}x{Height} pixels at {Colors} colors";
}
}

View File

@@ -28,7 +28,6 @@
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
using System.ComponentModel;
using Microsoft.AspNetCore.Mvc;
namespace Marechai.Database.Models

View File

@@ -7,19 +7,15 @@ namespace Marechai.Database.Models
{
public class Screen : BaseModel<int>
{
[Range(1, 131072)]
[DisplayName("Width (mm)")]
[Range(1, 131072), DisplayName("Width (mm)")]
public double? Width { get; set; }
[Range(1, 131072)]
[DisplayName("Height (mm)")]
[Range(1, 131072), DisplayName("Height (mm)")]
public double? Height { get; set; }
[Required]
[DisplayName("Diagonal (inches)")]
[Required, DisplayName("Diagonal (inches)")]
public double Diagonal { get; set; }
[DisplayName("Native resolution")]
public virtual Resolution NativeResolution { get; set; }
[Range(2, 281474976710656)]
[DisplayName("Effective colors")]
[Range(2, 281474976710656), DisplayName("Effective colors")]
public long? EffectiveColors { get; set; }
[Required]
public string Type { get; set; }
@@ -32,9 +28,11 @@ namespace Marechai.Database.Models
{
get
{
if(Width != null && Height != null) return $"{Width}x{Height} mm";
if(Width != null &&
Height != null)
return$"{Width}x{Height} mm";
return "Unknown";
return"Unknown";
}
}

View File

@@ -38,34 +38,24 @@ namespace Marechai.Database.Models
{
public class SoundSynth : BaseModel<int>
{
public SoundSynth()
{
SoundByMachine = new HashSet<SoundByMachine>();
}
public SoundSynth() => SoundByMachine = new HashSet<SoundByMachine>();
[Required]
[StringLength(50)]
[Required, StringLength(50)]
public string Name { get; set; }
public int? CompanyId { get; set; }
[DisplayName("Model code")]
[StringLength(45)]
[DisplayName("Model code"), StringLength(45)]
public string ModelCode { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}"), DataType(DataType.Date)]
public DateTime? Introduced { get; set; }
[DisplayName("PCM voices")]
[Range(1, int.MaxValue)]
[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)]
[DisplayName("Sample resolution"), Range(1, int.MaxValue)]
public int? Depth { get; set; }
[DisplayName("Square wave channels")]
[Range(1, int.MaxValue)]
[DisplayName("Square wave channels"), Range(1, int.MaxValue)]
public int? SquareWave { get; set; }
[DisplayName("White noise channels")]
[Range(1, int.MaxValue)]
[DisplayName("White noise channels"), Range(1, int.MaxValue)]
public int? WhiteNoise { get; set; }
public int? Type { get; set; }

View File

@@ -50,17 +50,18 @@ namespace Marechai.Database
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;
}
}
/// <summary>
/// Opens an existing database
/// </summary>
/// <summary>Opens an existing database</summary>
/// <param name="server">Server</param>
/// <param name="user">User</param>
/// <param name="database">Database name</param>
@@ -81,9 +82,11 @@ namespace Marechai.Database
bool res = Operations.UpdateDatabase();
if(res) return true;
if(res)
return true;
connection = null;
return false;
}
catch(MySqlException ex)
@@ -91,31 +94,26 @@ namespace Marechai.Database
Console.WriteLine("Error opening database.");
Console.WriteLine(ex);
connection = null;
return false;
}
}
/// <summary>
/// Closes the database
/// </summary>
/// <summary>Closes the database</summary>
public void CloseDb()
{
connection?.Close();
connection = null;
}
/// <summary>
/// Gets a data adapter for the opened database
/// </summary>
/// <summary>Gets a data adapter for the opened database</summary>
/// <returns>Data adapter</returns>
public IDbDataAdapter GetNewDataAdapter()
{
return new MySqlDataAdapter();
}
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}'";
@@ -125,12 +123,10 @@ namespace Marechai.Database
int count = reader.GetInt32(0);
reader.Close();
return count > 0;
}
~Mysql()
{
CloseDb();
}
~Mysql() => CloseDb();
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -37,29 +37,28 @@ using Microsoft.EntityFrameworkCore;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class BrowserTestsController : Controller
{
readonly MarechaiContext _context;
public BrowserTestsController(MarechaiContext context)
{
_context = context;
}
public BrowserTestsController(MarechaiContext context) => _context = context;
// GET: Admin/BrowserTests
public async Task<IActionResult> Index() =>
View(await _context.BrowserTests.OrderBy(b => b.Browser).ThenBy(b => b.Version).ThenBy(b => b.Os)
.ThenBy(b => b.Platform).ThenBy(b => b.UserAgent).ToListAsync());
View(await _context.BrowserTests.OrderBy(b => b.Browser).ThenBy(b => b.Version).ThenBy(b => b.Os).
ThenBy(b => b.Platform).ThenBy(b => b.UserAgent).ToListAsync());
// GET: Admin/BrowserTests/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
BrowserTest browserTest = await _context.BrowserTests.FirstOrDefaultAsync(m => m.Id == id);
if(browserTest == null) return NotFound();
if(browserTest == null)
return NotFound();
return View(browserTest);
}
@@ -67,10 +66,13 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/BrowserTests/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
BrowserTest browserTest = await _context.BrowserTests.FindAsync(id);
if(browserTest == null) return NotFound();
if(browserTest == null)
return NotFound();
return View(browserTest);
}
@@ -78,16 +80,17 @@ namespace Marechai.Areas.Admin.Controllers
// POST: Admin/BrowserTests/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
int id, [Bind(
"Id,UserAgent,Browser,Version,Os,Platform,Gif87,Gif89,Jpeg,Png,Pngt,Agif,Table,Colors,Js,Frames,Flash")]
int id,
[Bind("Id,UserAgent,Browser,Version,Os,Platform,Gif87,Gif89,Jpeg,Png,Pngt,Agif,Table,Colors,Js,Frames,Flash")]
BrowserTest browserTest)
{
if(id != browserTest.Id) return NotFound();
if(id != browserTest.Id)
return NotFound();
if(!ModelState.IsValid) return View(browserTest);
if(!ModelState.IsValid)
return View(browserTest);
try
{
@@ -96,7 +99,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!BrowserTestExists(browserTest.Id)) return NotFound();
if(!BrowserTestExists(browserTest.Id))
return NotFound();
throw;
}
@@ -107,29 +111,28 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/BrowserTests/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
BrowserTest browserTest = await _context.BrowserTests.FirstOrDefaultAsync(m => m.Id == id);
if(browserTest == null) return NotFound();
if(browserTest == null)
return NotFound();
return View(browserTest);
}
// POST: Admin/BrowserTests/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
BrowserTest browserTest = await _context.BrowserTests.FindAsync(id);
_context.BrowserTests.Remove(browserTest);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool BrowserTestExists(int id)
{
return _context.BrowserTests.Any(e => e.Id == id);
}
bool BrowserTestExists(int id) => _context.BrowserTests.Any(e => e.Id == id);
}
}

View File

@@ -30,8 +30,8 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -40,42 +40,37 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class CompaniesController : Controller
{
readonly MarechaiContext _context;
public CompaniesController(MarechaiContext context)
{
_context = context;
}
public CompaniesController(MarechaiContext context) => _context = context;
// GET: Admin/Companies
public async Task<IActionResult> Index()
{
IIncludableQueryable<Company, Company> marechaiContext =
_context.Companies.Include(c => c.Country).Include(c => c.SoldTo);
return View(marechaiContext.OrderBy(c => c.Name).Select(c => new CompanyViewModel
{
Id = c.Id,
Name = c.Name,
Founded = c.Founded,
Status = c.Status,
Country = c.Country.Name,
Sold = c.Sold,
SoldTo = c.SoldTo.Name
Id = c.Id, Name = c.Name, Founded = c.Founded, Status = c.Status,
Country = c.Country.Name, Sold = c.Sold, SoldTo = c.SoldTo.Name
}));
}
// GET: Admin/Companies/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Company company = await _context.Companies.Include(c => c.Country).Include(c => c.SoldTo)
.FirstOrDefaultAsync(m => m.Id == id);
if(company == null) return NotFound();
Company company = await _context.Companies.Include(c => c.Country).Include(c => c.SoldTo).
FirstOrDefaultAsync(m => m.Id == id);
if(company == null)
return NotFound();
return View(company);
}
@@ -85,59 +80,66 @@ namespace Marechai.Areas.Admin.Controllers
{
ViewData["CountryId"] = new SelectList(_context.Iso31661Numeric.OrderBy(c => c.Name), "Id", "Name");
ViewData["SoldToId"] = new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name");
return View();
}
// POST: Admin/Companies/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create(
[Bind(
"Id,Name,Founded,Website,Twitter,Facebook,Sold,SoldToId,Address,City,Province,PostalCode,CountryId,Status")]
[Bind("Id,Name,Founded,Website,Twitter,Facebook,Sold,SoldToId,Address,City,Province,PostalCode,CountryId,Status")]
Company company)
{
if(ModelState.IsValid)
{
_context.Add(company);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["CountryId"] =
new SelectList(_context.Iso31661Numeric.OrderBy(c => c.Name), "Id", "Name", company.CountryId);
ViewData["SoldToId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name", company.SoldToId);
return View(company);
}
// GET: Admin/Companies/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Company company = await _context.Companies.FindAsync(id);
if(company == null) return NotFound();
if(company == null)
return NotFound();
ViewData["CountryId"] =
new SelectList(_context.Iso31661Numeric.OrderBy(c => c.Name), "Id", "Name", company.CountryId);
ViewData["SoldToId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name", company.SoldToId);
return View(company);
}
// POST: Admin/Companies/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
int id, [Bind(
"Id,Name,Founded,Website,Twitter,Facebook,Sold,SoldToId,Address,City,Province,PostalCode,CountryId,Status")]
int id,
[Bind("Id,Name,Founded,Website,Twitter,Facebook,Sold,SoldToId,Address,City,Province,PostalCode,CountryId,Status")]
Company company)
{
if(id != company.Id) return NotFound();
if(id != company.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -148,7 +150,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!CompanyExists(company.Id)) return NotFound();
if(!CompanyExists(company.Id))
return NotFound();
throw;
}
@@ -158,38 +161,39 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["CountryId"] =
new SelectList(_context.Iso31661Numeric.OrderBy(c => c.Name), "Id", "Name", company.CountryId);
ViewData["SoldToId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name", company.SoldToId);
return View(company);
}
// GET: Admin/Companies/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Company company = await _context.Companies.Include(c => c.Country).Include(c => c.SoldTo)
.FirstOrDefaultAsync(m => m.Id == id);
if(company == null) return NotFound();
Company company = await _context.Companies.Include(c => c.Country).Include(c => c.SoldTo).
FirstOrDefaultAsync(m => m.Id == id);
if(company == null)
return NotFound();
return View(company);
}
// POST: Admin/Companies/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Company company = await _context.Companies.FindAsync(id);
_context.Companies.Remove(company);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool CompanyExists(int id)
{
return _context.Companies.Any(e => e.Id == id);
}
bool CompanyExists(int id) => _context.Companies.Any(e => e.Id == id);
}
}

View File

@@ -30,8 +30,8 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Markdig;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -41,8 +41,7 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class CompanyDescriptionsController : Controller
{
readonly MarechaiContext _context;
@@ -59,8 +58,8 @@ namespace Marechai.Areas.Admin.Controllers
{
IIncludableQueryable<CompanyDescription, Company> marechaiContext =
_context.CompanyDescriptions.Include(c => c.Company);
return View(await marechaiContext.OrderBy(c => c.Company.Name)
.Select(c => new CompanyDescriptionViewModel
return View(await marechaiContext.OrderBy(c => c.Company.Name).Select(c => new CompanyDescriptionViewModel
{
Id = c.Id, Company = c.Company.Name
}).ToListAsync());
@@ -69,12 +68,14 @@ namespace Marechai.Areas.Admin.Controllers
// GET: CompanyDescription/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
CompanyDescription companyDescription = await _context.CompanyDescriptions
.Include(c => c.Company)
.FirstOrDefaultAsync(m => m.Id == id);
if(companyDescription == null) return NotFound();
CompanyDescription companyDescription =
await _context.CompanyDescriptions.Include(c => c.Company).FirstOrDefaultAsync(m => m.Id == id);
if(companyDescription == null)
return NotFound();
return View(companyDescription);
}
@@ -83,14 +84,14 @@ namespace Marechai.Areas.Admin.Controllers
public IActionResult Create()
{
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name");
return View();
}
// POST: CompanyDescription/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,CompanyId,Text")] CompanyDescription companyDescription)
{
if(ModelState.IsValid)
@@ -98,35 +99,41 @@ namespace Marechai.Areas.Admin.Controllers
companyDescription.Html = Markdown.ToHtml(companyDescription.Text, pipeline);
_context.Add(companyDescription);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name",
companyDescription.CompanyId);
return View(companyDescription);
}
// GET: CompanyDescription/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
CompanyDescription companyDescription = await _context.CompanyDescriptions.FindAsync(id);
if(companyDescription == null) return NotFound();
if(companyDescription == null)
return NotFound();
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name",
companyDescription.CompanyId);
return View(companyDescription);
}
// POST: CompanyDescription/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,CompanyId,Text")] CompanyDescription companyDescription)
{
if(id != companyDescription.Id) return NotFound();
if(id != companyDescription.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -138,7 +145,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!CompanyDescriptionExists(companyDescription.Id)) return NotFound();
if(!CompanyDescriptionExists(companyDescription.Id))
return NotFound();
throw;
}
@@ -148,37 +156,36 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name",
companyDescription.CompanyId);
return View(companyDescription);
}
// GET: CompanyDescription/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
CompanyDescription companyDescription = await _context.CompanyDescriptions
.Include(c => c.Company)
.FirstOrDefaultAsync(m => m.Id == id);
if(companyDescription == null) return NotFound();
CompanyDescription companyDescription =
await _context.CompanyDescriptions.Include(c => c.Company).FirstOrDefaultAsync(m => m.Id == id);
if(companyDescription == null)
return NotFound();
return View(companyDescription);
}
// POST: CompanyDescription/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
CompanyDescription companyDescription = await _context.CompanyDescriptions.FindAsync(id);
_context.CompanyDescriptions.Remove(companyDescription);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool CompanyDescriptionExists(int id)
{
return _context.CompanyDescriptions.Any(e => e.Id == id);
}
bool CompanyDescriptionExists(int id) => _context.CompanyDescriptions.Any(e => e.Id == id);
}
}

View File

@@ -4,8 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
@@ -17,8 +17,7 @@ using SKSvg = SkiaSharp.Extended.Svg.SKSvg;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class CompanyLogosController : Controller
{
readonly MarechaiContext _context;
@@ -34,8 +33,9 @@ namespace Marechai.Areas.Admin.Controllers
public async Task<IActionResult> Index()
{
IIncludableQueryable<CompanyLogo, Company> marechaiContext = _context.CompanyLogos.Include(c => c.Company);
return View(await marechaiContext.OrderBy(l => l.Company.Name).ThenBy(l => l.Year)
.Select(l => new CompanyLogoViewModel
return View(await marechaiContext.OrderBy(l => l.Company.Name).ThenBy(l => l.Year).
Select(l => new CompanyLogoViewModel
{
Company = l.Company.Name, Id = l.Id, Year = l.Year
}).ToListAsync());
@@ -44,11 +44,14 @@ namespace Marechai.Areas.Admin.Controllers
// GET: CompanyLogos/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
CompanyLogo companyLogo = await _context.CompanyLogos
.Include(c => c.Company).FirstOrDefaultAsync(m => m.Id == id);
if(companyLogo == null) return NotFound();
CompanyLogo companyLogo =
await _context.CompanyLogos.Include(c => c.Company).FirstOrDefaultAsync(m => m.Id == id);
if(companyLogo == null)
return NotFound();
return View(companyLogo);
}
@@ -57,10 +60,11 @@ namespace Marechai.Areas.Admin.Controllers
// TODO: Upload
public IActionResult Create()
{
ViewData["CompanyId"] =
new
SelectList(_context.Companies.Select(c => new CompanyViewModel {Name = c.Name, Id = c.Id}).OrderBy(c => c.Name),
"Id", "Name");
ViewData["CompanyId"] = new SelectList(_context.Companies.Select(c => new CompanyViewModel
{
Name = c.Name, Id = c.Id
}).OrderBy(c => c.Name), "Id", "Name");
return View();
}
@@ -68,20 +72,20 @@ namespace Marechai.Areas.Admin.Controllers
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
// TODO: Upload
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,CompanyId,Year,SvgLogo")] CompanyLogo companyLogo)
{
if(!ModelState.IsValid)
{
ViewData["CompanyId"] =
new
SelectList(_context.Companies.Select(c => new CompanyViewModel {Name = c.Name, Id = c.Id}).OrderBy(c => c.Name),
"Id", "Name", companyLogo.CompanyId);
ViewData["CompanyId"] = new SelectList(_context.Companies.Select(c => new CompanyViewModel
{
Name = c.Name, Id = c.Id
}).OrderBy(c => c.Name), "Id", "Name", companyLogo.CompanyId);
return View(companyLogo);
}
using(MemoryStream svgMs = new MemoryStream())
using(var svgMs = new MemoryStream())
{
await companyLogo.SvgLogo.CopyToAsync(svgMs);
@@ -89,9 +93,9 @@ namespace Marechai.Areas.Admin.Controllers
try
{
StreamReader sr = new StreamReader(svgMs, Encoding.UTF8);
var sr = new StreamReader(svgMs, Encoding.UTF8);
string svgStr = await sr.ReadToEndAsync();
XmlDocument xml = new XmlDocument();
var xml = new XmlDocument();
xml.LoadXml(svgStr);
}
catch(XmlException)
@@ -99,10 +103,11 @@ namespace Marechai.Areas.Admin.Controllers
companyLogo.SvgLogo = null;
companyLogo.ErrorMessage = "Not a valid SVG file.";
ViewData["CompanyId"] =
new
SelectList(_context.Companies.Select(c => new CompanyViewModel {Name = c.Name, Id = c.Id}).OrderBy(c => c.Name),
"Id", "Name", companyLogo.CompanyId);
ViewData["CompanyId"] = new SelectList(_context.Companies.Select(c => new CompanyViewModel
{
Name = c.Name, Id = c.Id
}).OrderBy(c => c.Name), "Id", "Name", companyLogo.CompanyId);
return View(companyLogo);
}
@@ -111,19 +116,21 @@ namespace Marechai.Areas.Admin.Controllers
string vectorial = Path.Combine(hostingEnvironment.WebRootPath, "assets/logos",
companyLogo.Guid + ".svg");
if(System.IO.File.Exists(vectorial))
{
companyLogo.SvgLogo = null;
companyLogo.ErrorMessage = "GUID clash, please retry and report to the administrator.";
ViewData["CompanyId"] =
new
SelectList(_context.Companies.Select(c => new CompanyViewModel {Name = c.Name, Id = c.Id}).OrderBy(c => c.Name),
"Id", "Name", companyLogo.CompanyId);
ViewData["CompanyId"] = new SelectList(_context.Companies.Select(c => new CompanyViewModel
{
Name = c.Name, Id = c.Id
}).OrderBy(c => c.Name), "Id", "Name", companyLogo.CompanyId);
return View(companyLogo);
}
FileStream outSvg = new FileStream(vectorial, FileMode.CreateNew);
var outSvg = new FileStream(vectorial, FileMode.CreateNew);
await svgMs.CopyToAsync(outSvg);
svgMs.Position = 0;
@@ -131,23 +138,34 @@ namespace Marechai.Areas.Admin.Controllers
try
{
foreach(string format in new[] {"png", "webp"})
foreach(string format in new[]
{
if(!Directory.Exists(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos", format))) ;
"png", "webp"
})
{
if(!Directory.Exists(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos", format)))
;
Directory.CreateDirectory(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos", format));
SKEncodedImageFormat skFormat;
switch(format)
{
case "webp":
case"webp":
skFormat = SKEncodedImageFormat.Webp;
break;
default:
skFormat = SKEncodedImageFormat.Png;
break;
}
foreach(int multiplier in new[] {1, 2, 3})
foreach(int multiplier in new[]
{
1, 2, 3
})
{
if(!Directory.Exists(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos", format,
$"{multiplier}x")))
@@ -163,13 +181,16 @@ namespace Marechai.Areas.Admin.Controllers
companyLogo.ErrorMessage = "GUID clash, please retry and report to the administrator.";
ViewData["CompanyId"] =
new
SelectList(_context.Companies.Select(c => new CompanyViewModel {Name = c.Name, Id = c.Id}).OrderBy(c => c.Name),
"Id", "Name", companyLogo.CompanyId);
new SelectList(_context.Companies.Select(c => new CompanyViewModel
{
Name = c.Name, Id = c.Id
}).OrderBy(c => c.Name), "Id", "Name", companyLogo.CompanyId);
return View(companyLogo);
}
Console.WriteLine("Rendering {0}", rendered);
if(svg == null)
{
svg = new SKSvg();
@@ -177,15 +198,17 @@ namespace Marechai.Areas.Admin.Controllers
}
SKRect svgSize = svg.Picture.CullRect;
SKMatrix matrix = SKMatrix.MakeScale(multiplier, multiplier);
SKBitmap bitmap = new SKBitmap((int)(svgSize.Width * multiplier),
var matrix = SKMatrix.MakeScale(multiplier, multiplier);
var bitmap = new SKBitmap((int)(svgSize.Width * multiplier),
(int)(svgSize.Height * multiplier));
SKCanvas canvas = new SKCanvas(bitmap);
var canvas = new SKCanvas(bitmap);
canvas.DrawPicture(svg.Picture, ref matrix);
canvas.Flush();
SKImage image = SKImage.FromBitmap(bitmap);
var image = SKImage.FromBitmap(bitmap);
SKData data = image.Encode(skFormat, 100);
FileStream outfs = new FileStream(rendered, FileMode.CreateNew);
var outfs = new FileStream(rendered, FileMode.CreateNew);
data.SaveTo(outfs);
outfs.Close();
@@ -193,30 +216,40 @@ namespace Marechai.Areas.Admin.Controllers
}
}
foreach(string format in new[] {"png", "webp"})
foreach(string format in new[]
{
"png", "webp"
})
{
if(!Directory.Exists(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos/thumbs",
format)))
Directory.CreateDirectory(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos/thumbs",
format));
Directory.CreateDirectory(Path.Combine(hostingEnvironment.WebRootPath,
"assets/logos/thumbs", format));
SKEncodedImageFormat skFormat;
switch(format)
{
case "webp":
case"webp":
skFormat = SKEncodedImageFormat.Webp;
break;
default:
skFormat = SKEncodedImageFormat.Png;
break;
}
foreach(int multiplier in new[] {1, 2, 3})
foreach(int multiplier in new[]
{
1, 2, 3
})
{
if(!Directory.Exists(Path.Combine(hostingEnvironment.WebRootPath, "assets/logos/thumbs",
format, $"{multiplier}x")))
Directory.CreateDirectory(Path.Combine(hostingEnvironment.WebRootPath,
"assets/logos/thumbs", format, $"{multiplier}x"));
"assets/logos/thumbs", format,
$"{multiplier}x"));
string rendered = Path.Combine(hostingEnvironment.WebRootPath, "assets/logos/thumbs",
format, $"{multiplier}x", companyLogo.Guid + $".{format}");
@@ -227,13 +260,16 @@ namespace Marechai.Areas.Admin.Controllers
companyLogo.ErrorMessage = "GUID clash, please retry and report to the administrator.";
ViewData["CompanyId"] =
new
SelectList(_context.Companies.Select(c => new CompanyViewModel {Name = c.Name, Id = c.Id}).OrderBy(c => c.Name),
"Id", "Name", companyLogo.CompanyId);
new SelectList(_context.Companies.Select(c => new CompanyViewModel
{
Name = c.Name, Id = c.Id
}).OrderBy(c => c.Name), "Id", "Name", companyLogo.CompanyId);
return View(companyLogo);
}
Console.WriteLine("Rendering {0}", rendered);
if(svg == null)
{
svg = new SKSvg();
@@ -244,15 +280,17 @@ namespace Marechai.Areas.Admin.Controllers
float svgMax = Math.Max(svgSize.Width, svgSize.Height);
float canvasMin = 32 * multiplier;
float scale = canvasMin / svgMax;
SKMatrix matrix = SKMatrix.MakeScale(scale, scale);
SKBitmap bitmap =
var matrix = SKMatrix.MakeScale(scale, scale);
var bitmap =
new SKBitmap((int)(svgSize.Width * scale), (int)(svgSize.Height * scale));
SKCanvas canvas = new SKCanvas(bitmap);
var canvas = new SKCanvas(bitmap);
canvas.DrawPicture(svg.Picture, ref matrix);
canvas.Flush();
SKImage image = SKImage.FromBitmap(bitmap);
var image = SKImage.FromBitmap(bitmap);
SKData data = image.Encode(skFormat, 100);
FileStream outfs = new FileStream(rendered, FileMode.CreateNew);
var outfs = new FileStream(rendered, FileMode.CreateNew);
data.SaveTo(outfs);
outfs.Close();
@@ -263,36 +301,42 @@ namespace Marechai.Areas.Admin.Controllers
catch(IOException e)
{
Console.WriteLine(e);
throw;
}
}
_context.Add(companyLogo);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
// GET: CompanyLogos/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
CompanyLogo companyLogo = await _context.CompanyLogos.FirstOrDefaultAsync(c => c.Id == id);
if(companyLogo == null) return NotFound();
if(companyLogo == null)
return NotFound();
ViewData["CompanyId"] =
new SelectList(_context.Companies.OrderBy(l => l.Name), "Id", "Name", companyLogo.CompanyId);
return View(companyLogo);
}
// POST: CompanyLogos/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,CompanyId,Year,Guid")] CompanyLogo companyLogo)
{
if(id != companyLogo.Id) return NotFound();
if(id != companyLogo.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -303,7 +347,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!CompanyLogoExists(companyLogo.Id)) return NotFound();
if(!CompanyLogoExists(companyLogo.Id))
return NotFound();
throw;
}
@@ -313,38 +358,40 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["CompanyId"] =
new SelectList(_context.Companies.OrderBy(l => l.Name), "Id", "Name", companyLogo.CompanyId);
return View(companyLogo);
}
// GET: CompanyLogos/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
CompanyLogo companyLogo = await _context.CompanyLogos
.Include(c => c.Company).FirstOrDefaultAsync(m => m.Id == id);
if(companyLogo == null) return NotFound();
CompanyLogo companyLogo =
await _context.CompanyLogos.Include(c => c.Company).FirstOrDefaultAsync(m => m.Id == id);
if(companyLogo == null)
return NotFound();
return View(companyLogo);
}
// POST: CompanyLogos/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
CompanyLogo companyLogo = await _context.CompanyLogos.FirstOrDefaultAsync(m => m.Id == id);
if(companyLogo == null) return NotFound();
if(companyLogo == null)
return NotFound();
_context.CompanyLogos.Remove(companyLogo);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool CompanyLogoExists(int id)
{
return _context.CompanyLogos.Any(e => e.Id == id);
}
bool CompanyLogoExists(int id) => _context.CompanyLogos.Any(e => e.Id == id);
}
}

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -9,45 +9,37 @@ using Microsoft.EntityFrameworkCore;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class DocumentCompaniesController : Controller
{
readonly MarechaiContext _context;
public DocumentCompaniesController(MarechaiContext context)
{
_context = context;
}
public DocumentCompaniesController(MarechaiContext context) => _context = context;
// GET: DocumentCompanies
public async Task<IActionResult> Index()
public async Task<IActionResult> Index() => View(await _context.
DocumentCompanies.OrderBy(c => c.Name).
Select(d => new DocumentCompanyViewModel
{
return View(await _context.DocumentCompanies.OrderBy(c => c.Name)
.Select(d => new DocumentCompanyViewModel
{
Id = d.Id,
Name = d.Name,
Id = d.Id, Name = d.Name,
Company = d.Company.Name,
CompanyId = d.CompanyId
}).ToListAsync());
}
// GET: DocumentCompanies/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
DocumentCompanyViewModel documentCompany =
await _context.DocumentCompanies
.Select(d => new DocumentCompanyViewModel
await _context.DocumentCompanies.Select(d => new DocumentCompanyViewModel
{
Id = d.Id,
Name = d.Name,
Company = d.Company.Name,
CompanyId = d.CompanyId
Id = d.Id, Name = d.Name, Company = d.Company.Name, CompanyId = d.CompanyId
}).FirstOrDefaultAsync(m => m.Id == id);
if(documentCompany == null) return NotFound();
if(documentCompany == null)
return NotFound();
return View(documentCompany);
}
@@ -55,37 +47,44 @@ namespace Marechai.Areas.Admin.Controllers
// GET: DocumentCompanies/Create
public IActionResult Create()
{
ViewData["CompanyId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name).Select(c => new {c.Id, c.Name}), "Id", "Name");
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name).Select(c => new
{
c.Id, c.Name
}), "Id", "Name");
return View();
}
// POST: DocumentCompanies/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Name,CompanyId,Id")] DocumentCompany documentCompany)
{
if(!ModelState.IsValid) return View(documentCompany);
if(!ModelState.IsValid)
return View(documentCompany);
_context.Add(documentCompany);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
// GET: DocumentCompanies/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
DocumentCompany documentCompany = await _context.DocumentCompanies.FindAsync(id);
if(documentCompany == null) return NotFound();
if(documentCompany == null)
return NotFound();
ViewData["CompanyId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name).Select(c => new {c.Id, c.Name}), "Id", "Name",
documentCompany.CompanyId);
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name).Select(c => new
{
c.Id, c.Name
}), "Id", "Name", documentCompany.CompanyId);
return View(documentCompany);
}
@@ -93,11 +92,11 @@ namespace Marechai.Areas.Admin.Controllers
// POST: DocumentCompanies/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Name,CompanyId,Id")] DocumentCompany documentCompany)
{
if(id != documentCompany.Id) return NotFound();
if(id != documentCompany.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -108,7 +107,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!DocumentCompanyExists(documentCompany.Id)) return NotFound();
if(!DocumentCompanyExists(documentCompany.Id))
return NotFound();
throw;
}
@@ -116,9 +116,10 @@ namespace Marechai.Areas.Admin.Controllers
return RedirectToAction(nameof(Index));
}
ViewData["CompanyId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name).Select(c => new {c.Id, c.Name}), "Id", "Name",
documentCompany.CompanyId);
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name).Select(c => new
{
c.Id, c.Name
}), "Id", "Name", documentCompany.CompanyId);
return View(documentCompany);
}
@@ -126,37 +127,32 @@ namespace Marechai.Areas.Admin.Controllers
// GET: DocumentCompanies/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
DocumentCompanyViewModel documentCompany =
await _context.DocumentCompanies
.Select(d => new DocumentCompanyViewModel
await _context.DocumentCompanies.Select(d => new DocumentCompanyViewModel
{
Id = d.Id,
Name = d.Name,
Company = d.Company.Name,
CompanyId = d.CompanyId
Id = d.Id, Name = d.Name, Company = d.Company.Name, CompanyId = d.CompanyId
}).FirstOrDefaultAsync(m => m.Id == id);
if(documentCompany == null) return NotFound();
if(documentCompany == null)
return NotFound();
return View(documentCompany);
}
// POST: DocumentCompanies/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
DocumentCompany documentCompany = await _context.DocumentCompanies.FindAsync(id);
_context.DocumentCompanies.Remove(documentCompany);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool DocumentCompanyExists(int id)
{
return _context.DocumentCompanies.Any(e => e.Id == id);
}
bool DocumentCompanyExists(int id) => _context.DocumentCompanies.Any(e => e.Id == id);
}
}

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -9,37 +9,32 @@ using Microsoft.EntityFrameworkCore;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class DocumentPeopleController : Controller
{
readonly MarechaiContext _context;
public DocumentPeopleController(MarechaiContext context)
{
_context = context;
}
public DocumentPeopleController(MarechaiContext context) => _context = context;
// GET: DocumentPeople
public async Task<IActionResult> Index()
public async Task<IActionResult> Index() => View(await _context.
DocumentPeople.OrderBy(d => d.FullName).
Select(d => new DocumentPersonViewModel
{
return View(await _context.DocumentPeople.OrderBy(d => d.FullName)
.Select(d => new DocumentPersonViewModel
{
Id = d.Id,
Name = d.FullName,
Person = d.Person.FullName,
PersonId = d.PersonId
Id = d.Id, Name = d.FullName,
Person = d.Person.FullName, PersonId = d.PersonId
}).ToListAsync());
}
// GET: DocumentPeople/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
DocumentPerson documentPerson = await _context.DocumentPeople.FirstOrDefaultAsync(m => m.Id == id);
if(documentPerson == null) return NotFound();
if(documentPerson == null)
return NotFound();
return View(documentPerson);
}
@@ -47,39 +42,45 @@ namespace Marechai.Areas.Admin.Controllers
// GET: DocumentPeople/Create
public IActionResult Create()
{
ViewData["PersonId"] =
new SelectList(_context.People.OrderBy(c => c.FullName).Select(c => new {c.Id, Name = c.FullName}),
"Id", "Name");
ViewData["PersonId"] = new SelectList(_context.People.OrderBy(c => c.FullName).Select(c => new
{
c.Id, Name = c.FullName
}), "Id", "Name");
return View();
}
// POST: DocumentPeople/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Name,Surname,Alias,DisplayName,PersonId,Id")]
DocumentPerson documentPerson)
{
if(!ModelState.IsValid) return View(documentPerson);
if(!ModelState.IsValid)
return View(documentPerson);
_context.Add(documentPerson);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
// GET: DocumentPeople/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
DocumentPerson documentPerson = await _context.DocumentPeople.FindAsync(id);
if(documentPerson == null) return NotFound();
if(documentPerson == null)
return NotFound();
ViewData["PersonId"] =
new SelectList(_context.People.OrderBy(c => c.FullName).Select(c => new {c.Id, Name = c.FullName}),
"Id", "Name", documentPerson.PersonId);
ViewData["PersonId"] = new SelectList(_context.People.OrderBy(c => c.FullName).Select(c => new
{
c.Id, Name = c.FullName
}), "Id", "Name", documentPerson.PersonId);
return View(documentPerson);
}
@@ -87,12 +88,12 @@ namespace Marechai.Areas.Admin.Controllers
// POST: DocumentPeople/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Name,Surname,Alias,DisplayName,PersonId,Id")]
DocumentPerson documentPerson)
{
if(id != documentPerson.Id) return NotFound();
if(id != documentPerson.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -103,7 +104,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!DocumentPersonExists(documentPerson.Id)) return NotFound();
if(!DocumentPersonExists(documentPerson.Id))
return NotFound();
throw;
}
@@ -111,9 +113,10 @@ namespace Marechai.Areas.Admin.Controllers
return RedirectToAction(nameof(Index));
}
ViewData["PersonId"] =
new SelectList(_context.People.OrderBy(c => c.FullName).Select(c => new {c.Id, Name = c.FullName}),
"Id", "Name", documentPerson.PersonId);
ViewData["PersonId"] = new SelectList(_context.People.OrderBy(c => c.FullName).Select(c => new
{
c.Id, Name = c.FullName
}), "Id", "Name", documentPerson.PersonId);
return View(documentPerson);
}
@@ -121,29 +124,28 @@ namespace Marechai.Areas.Admin.Controllers
// GET: DocumentPeople/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
DocumentPerson documentPerson = await _context.DocumentPeople.FirstOrDefaultAsync(m => m.Id == id);
if(documentPerson == null) return NotFound();
if(documentPerson == null)
return NotFound();
return View(documentPerson);
}
// POST: DocumentPeople/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
DocumentPerson documentPerson = await _context.DocumentPeople.FindAsync(id);
_context.DocumentPeople.Remove(documentPerson);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool DocumentPersonExists(int id)
{
return _context.DocumentPeople.Any(e => e.Id == id);
}
bool DocumentPersonExists(int id) => _context.DocumentPeople.Any(e => e.Id == id);
}
}

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -10,24 +10,21 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class GpusByMachineController : Controller
{
readonly MarechaiContext _context;
public GpusByMachineController(MarechaiContext context)
{
_context = context;
}
public GpusByMachineController(MarechaiContext context) => _context = context;
// GET: GpusByMachine
public async Task<IActionResult> Index()
{
IIncludableQueryable<GpusByMachine, Machine> marechaiContext =
_context.GpusByMachine.Include(g => g.Gpu).Include(g => g.Machine);
return View(await marechaiContext.OrderBy(g => g.Machine.Name).ThenBy(g => g.Gpu.Name)
.Select(g => new GpusByMachineViewModel
return View(await marechaiContext.OrderBy(g => g.Machine.Name).ThenBy(g => g.Gpu.Name).
Select(g => new GpusByMachineViewModel
{
Id = g.Id, Gpu = g.Gpu.Name, Machine = g.Machine.Name
}).ToListAsync());
@@ -36,12 +33,15 @@ namespace Marechai.Areas.Admin.Controllers
// GET: GpusByMachine/Details/5
public async Task<IActionResult> Details(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
GpusByMachine gpusByMachine = await _context.GpusByMachine
.Include(g => g.Gpu).Include(g => g.Machine)
.FirstOrDefaultAsync(m => m.Id == id);
if(gpusByMachine == null) return NotFound();
GpusByMachine gpusByMachine = await _context.
GpusByMachine.Include(g => g.Gpu).Include(g => g.Machine).
FirstOrDefaultAsync(m => m.Id == id);
if(gpusByMachine == null)
return NotFound();
return View(gpusByMachine);
}
@@ -51,51 +51,59 @@ namespace Marechai.Areas.Admin.Controllers
{
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name");
ViewData["MachineId"] = new SelectList(_context.Machines.OrderBy(m => m.Name), "Id", "Name");
return View();
}
// POST: GpusByMachine/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("GpuId,MachineId,Id")] GpusByMachine gpusByMachine)
{
if(ModelState.IsValid)
{
_context.Add(gpusByMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByMachine.GpuId);
ViewData["MachineId"] =
new SelectList(_context.Machines.OrderBy(m => m.Name), "Id", "Name", gpusByMachine.MachineId);
return View(gpusByMachine);
}
// GET: GpusByMachine/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
GpusByMachine gpusByMachine = await _context.GpusByMachine.FindAsync(id);
if(gpusByMachine == null) return NotFound();
if(gpusByMachine == null)
return NotFound();
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByMachine.GpuId);
ViewData["MachineId"] =
new SelectList(_context.Machines.OrderBy(m => m.Name), "Id", "Name", gpusByMachine.MachineId);
return View(gpusByMachine);
}
// POST: GpusByMachine/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(long id, [Bind("GpuId,MachineId,Id")] GpusByMachine gpusByMachine)
{
if(id != gpusByMachine.Id) return NotFound();
if(id != gpusByMachine.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -106,7 +114,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!GpusByMachineExists(gpusByMachine.Id)) return NotFound();
if(!GpusByMachineExists(gpusByMachine.Id))
return NotFound();
throw;
}
@@ -115,39 +124,40 @@ namespace Marechai.Areas.Admin.Controllers
}
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByMachine.GpuId);
ViewData["MachineId"] =
new SelectList(_context.Machines.OrderBy(m => m.Name), "Id", "Name", gpusByMachine.MachineId);
return View(gpusByMachine);
}
// GET: GpusByMachine/Delete/5
public async Task<IActionResult> Delete(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
GpusByMachine gpusByMachine = await _context.GpusByMachine
.Include(g => g.Gpu).Include(g => g.Machine)
.FirstOrDefaultAsync(m => m.Id == id);
if(gpusByMachine == null) return NotFound();
GpusByMachine gpusByMachine = await _context.
GpusByMachine.Include(g => g.Gpu).Include(g => g.Machine).
FirstOrDefaultAsync(m => m.Id == id);
if(gpusByMachine == null)
return NotFound();
return View(gpusByMachine);
}
// POST: GpusByMachine/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
GpusByMachine gpusByMachine = await _context.GpusByMachine.FindAsync(id);
_context.GpusByMachine.Remove(gpusByMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool GpusByMachineExists(long id)
{
return _context.GpusByMachine.Any(e => e.Id == id);
}
bool GpusByMachineExists(long id) => _context.GpusByMachine.Any(e => e.Id == id);
}
}

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -10,27 +10,23 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class GpusByOwnedMachineController : Controller
{
readonly MarechaiContext _context;
public GpusByOwnedMachineController(MarechaiContext context)
{
_context = context;
}
public GpusByOwnedMachineController(MarechaiContext context) => _context = context;
// GET: GpusByOwnedMachine
public async Task<IActionResult> Index()
{
IIncludableQueryable<GpusByOwnedMachine, OwnedMachine> marechaiContext =
_context.GpusByOwnedMachine.Include(g => g.Gpu).Include(g => g.OwnedMachine);
return View(await marechaiContext.OrderBy(g => g.OwnedMachine.Machine.Name).ThenBy(g => g.Gpu.Name)
.Select(g => new GpusByMachineViewModel
return View(await marechaiContext.OrderBy(g => g.OwnedMachine.Machine.Name).ThenBy(g => g.Gpu.Name).
Select(g => new GpusByMachineViewModel
{
Id = g.Id,
Gpu = g.Gpu.Name,
Id = g.Id, Gpu = g.Gpu.Name,
Machine =
$"{g.OwnedMachine.Machine.Company.Name} {g.OwnedMachine.Machine.Name} <{g.OwnedMachine.User.UserName}>"
}).ToListAsync());
@@ -39,19 +35,20 @@ namespace Marechai.Areas.Admin.Controllers
// GET: GpusByOwnedMachine/Details/5
public async Task<IActionResult> Details(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
GpusByMachineViewModel gpusByOwnedMachine = await _context.GpusByOwnedMachine
.Include(g => g.Gpu).Include(g => g.OwnedMachine)
.Select(o => new GpusByMachineViewModel
GpusByMachineViewModel gpusByOwnedMachine =
await _context.GpusByOwnedMachine.Include(g => g.Gpu).Include(g => g.OwnedMachine).
Select(o => new GpusByMachineViewModel
{
Gpu = o.Gpu.Name,
Id = o.Id,
Gpu = o.Gpu.Name, Id = o.Id,
Machine =
$"{o.OwnedMachine.Machine.Company.Name} {o.OwnedMachine.Machine.Name} <{o.OwnedMachine.User.UserName}>"
}).FirstOrDefaultAsync(m => m.Id ==
id);
if(gpusByOwnedMachine == null) return NotFound();
}).FirstOrDefaultAsync(m => m.Id == id);
if(gpusByOwnedMachine == null)
return NotFound();
return View(gpusByOwnedMachine);
}
@@ -60,62 +57,83 @@ namespace Marechai.Areas.Admin.Controllers
public IActionResult Create()
{
ViewData["GpuId"] = new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name");
ViewData["OwnedMachineId"] =
new
SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).ThenBy(m => m.Machine.Name).ThenBy(m => m.User.UserName).Select(m => new {m.Id, Name = $"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"}),
"Id", "Name");
ViewData["OwnedMachineId"] = new SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).
ThenBy(m => m.Machine.Name).
ThenBy(m => m.User.UserName).Select(m => new
{
m.Id,
Name =
$"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"
}), "Id", "Name");
return View();
}
// POST: GpusByOwnedMachine/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("GpuId,OwnedMachineId,Id")] GpusByOwnedMachine gpusByOwnedMachine)
{
if(ModelState.IsValid)
{
_context.Add(gpusByOwnedMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["GpuId"] =
new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByOwnedMachine.GpuId);
ViewData["OwnedMachineId"] =
new
SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).ThenBy(m => m.Machine.Name).ThenBy(m => m.User.UserName).Select(m => new {m.Id, Name = $"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"}),
"Id", "Name", gpusByOwnedMachine.OwnedMachineId);
ViewData["OwnedMachineId"] = new SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).
ThenBy(m => m.Machine.Name).
ThenBy(m => m.User.UserName).Select(m => new
{
m.Id,
Name =
$"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"
}), "Id", "Name", gpusByOwnedMachine.OwnedMachineId);
return View(gpusByOwnedMachine);
}
// GET: GpusByOwnedMachine/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
GpusByOwnedMachine gpusByOwnedMachine = await _context.GpusByOwnedMachine.FindAsync(id);
if(gpusByOwnedMachine == null) return NotFound();
if(gpusByOwnedMachine == null)
return NotFound();
ViewData["GpuId"] =
new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByOwnedMachine.GpuId);
ViewData["OwnedMachineId"] =
new
SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).ThenBy(m => m.Machine.Name).ThenBy(m => m.User.UserName).Select(m => new {m.Id, Name = $"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"}),
"Id", "Name", gpusByOwnedMachine.OwnedMachineId);
ViewData["OwnedMachineId"] = new SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).
ThenBy(m => m.Machine.Name).
ThenBy(m => m.User.UserName).Select(m => new
{
m.Id,
Name =
$"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"
}), "Id", "Name", gpusByOwnedMachine.OwnedMachineId);
return View(gpusByOwnedMachine);
}
// POST: GpusByOwnedMachine/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
long id, [Bind("GpuId,OwnedMachineId,Id")] GpusByOwnedMachine gpusByOwnedMachine)
{
if(id != gpusByOwnedMachine.Id) return NotFound();
if(id != gpusByOwnedMachine.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -126,7 +144,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!GpusByOwnedMachineExists(gpusByOwnedMachine.Id)) return NotFound();
if(!GpusByOwnedMachineExists(gpusByOwnedMachine.Id))
return NotFound();
throw;
}
@@ -136,48 +155,51 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["GpuId"] =
new SelectList(_context.Gpus.OrderBy(g => g.Name), "Id", "Name", gpusByOwnedMachine.GpuId);
ViewData["OwnedMachineId"] =
new
SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).ThenBy(m => m.Machine.Name).ThenBy(m => m.User.UserName).Select(m => new {m.Id, Name = $"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"}),
"Id", "Name", gpusByOwnedMachine.OwnedMachineId);
ViewData["OwnedMachineId"] = new SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).
ThenBy(m => m.Machine.Name).
ThenBy(m => m.User.UserName).Select(m => new
{
m.Id,
Name =
$"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"
}), "Id", "Name", gpusByOwnedMachine.OwnedMachineId);
return View(gpusByOwnedMachine);
}
// GET: GpusByOwnedMachine/Delete/5
public async Task<IActionResult> Delete(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
GpusByMachineViewModel gpusByOwnedMachine = await _context.GpusByOwnedMachine
.Include(g => g.Gpu).Include(g => g.OwnedMachine)
.Select(o => new GpusByMachineViewModel
GpusByMachineViewModel gpusByOwnedMachine =
await _context.GpusByOwnedMachine.Include(g => g.Gpu).Include(g => g.OwnedMachine).
Select(o => new GpusByMachineViewModel
{
Gpu = o.Gpu.Name,
Id = o.Id,
Gpu = o.Gpu.Name, Id = o.Id,
Machine =
$"{o.OwnedMachine.Machine.Company.Name} {o.OwnedMachine.Machine.Name} <{o.OwnedMachine.User.UserName}>"
}).FirstOrDefaultAsync(m => m.Id ==
id);
if(gpusByOwnedMachine == null) return NotFound();
}).FirstOrDefaultAsync(m => m.Id == id);
if(gpusByOwnedMachine == null)
return NotFound();
return View(gpusByOwnedMachine);
}
// POST: GpusByOwnedMachine/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
GpusByOwnedMachine gpusByOwnedMachine = await _context.GpusByOwnedMachine.FindAsync(id);
_context.GpusByOwnedMachine.Remove(gpusByOwnedMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool GpusByOwnedMachineExists(long id)
{
return _context.GpusByOwnedMachine.Any(e => e.Id == id);
}
bool GpusByOwnedMachineExists(long id) => _context.GpusByOwnedMachine.Any(e => e.Id == id);
}
}

View File

@@ -30,8 +30,8 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -40,39 +40,37 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class GpusController : Controller
{
readonly MarechaiContext _context;
public GpusController(MarechaiContext context)
{
_context = context;
}
public GpusController(MarechaiContext context) => _context = context;
// GET: Admin/Gpus
public async Task<IActionResult> Index()
{
IIncludableQueryable<Gpu, Company> marechaiContext = _context.Gpus.Include(g => g.Company);
return View(await marechaiContext.OrderBy(g => g.Company.Name).ThenBy(g => g.Name).ThenBy(g => g.Introduced)
.Select(g => new GpuViewModel
return View(await marechaiContext.OrderBy(g => g.Company.Name).ThenBy(g => g.Name).
ThenBy(g => g.Introduced).Select(g => new GpuViewModel
{
Id = g.Id,
Company = g.Company.Name,
Id = g.Id, Company = g.Company.Name,
Introduced = g.Introduced,
ModelCode = g.ModelCode,
Name = g.Name
ModelCode = g.ModelCode, Name = g.Name
}).ToListAsync());
}
// GET: Admin/Gpus/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Gpu gpu = await _context.Gpus.Include(g => g.Company).FirstOrDefaultAsync(m => m.Id == id);
if(gpu == null) return NotFound();
if(gpu == null)
return NotFound();
return View(gpu);
}
@@ -81,14 +79,14 @@ namespace Marechai.Areas.Admin.Controllers
public IActionResult Create()
{
ViewData["CompanyId"] = new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name");
return View();
}
// POST: Admin/Gpus/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create(
[Bind("Id,Name,CompanyId,ModelCode,Introduced,Package,Process,ProcessNm,DieSize,Transistors")]
Gpu gpu)
@@ -97,37 +95,43 @@ namespace Marechai.Areas.Admin.Controllers
{
_context.Add(gpu);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["CompanyId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name", gpu.CompanyId);
return View(gpu);
}
// GET: Admin/Gpus/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Gpu gpu = await _context.Gpus.FindAsync(id);
if(gpu == null) return NotFound();
if(gpu == null)
return NotFound();
ViewData["CompanyId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name", gpu.CompanyId);
return View(gpu);
}
// POST: Admin/Gpus/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
int id, [Bind("Id,Name,CompanyId,ModelCode,Introduced,Package,Process,ProcessNm,DieSize,Transistors")]
Gpu gpu)
{
if(id != gpu.Id) return NotFound();
if(id != gpu.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -138,7 +142,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!GpuExists(gpu.Id)) return NotFound();
if(!GpuExists(gpu.Id))
return NotFound();
throw;
}
@@ -148,35 +153,35 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["CompanyId"] =
new SelectList(_context.Companies.OrderBy(c => c.Name), "Id", "Name", gpu.CompanyId);
return View(gpu);
}
// GET: Admin/Gpus/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Gpu gpu = await _context.Gpus.Include(g => g.Company).FirstOrDefaultAsync(m => m.Id == id);
if(gpu == null) return NotFound();
if(gpu == null)
return NotFound();
return View(gpu);
}
// POST: Admin/Gpus/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Gpu gpu = await _context.Gpus.FindAsync(id);
_context.Gpus.Remove(gpu);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool GpuExists(int id)
{
return _context.Gpus.Any(e => e.Id == id);
}
bool GpuExists(int id) => _context.Gpus.Any(e => e.Id == id);
}
}

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -10,27 +10,23 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class InstructionSetExtensionsByProcessorController : Controller
{
readonly MarechaiContext _context;
public InstructionSetExtensionsByProcessorController(MarechaiContext context)
{
_context = context;
}
public InstructionSetExtensionsByProcessorController(MarechaiContext context) => _context = context;
// GET: InstructionSetExtensionsByProcessor
public async Task<IActionResult> Index()
{
IIncludableQueryable<InstructionSetExtensionsByProcessor, Processor> marechaiContext =
_context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor);
return View(await marechaiContext.OrderBy(e => e.Processor.Name).ThenBy(e => e.Extension.Extension)
.Select(e => new InstructionSetExtensionsByProcessorViewModel
return View(await marechaiContext.OrderBy(e => e.Processor.Name).ThenBy(e => e.Extension.Extension).
Select(e => new InstructionSetExtensionsByProcessorViewModel
{
Id = e.Id,
Extension = e.Extension.Extension,
Id = e.Id, Extension = e.Extension.Extension,
Processor = e.Processor.Name
}).ToListAsync());
}
@@ -38,12 +34,15 @@ namespace Marechai.Areas.Admin.Controllers
// GET: InstructionSetExtensionsByProcessor/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
await _context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor)
.FirstOrDefaultAsync(m => m.Id == id);
if(instructionSetExtensionsByProcessor == null) return NotFound();
await _context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor).
FirstOrDefaultAsync(m => m.Id == id);
if(instructionSetExtensionsByProcessor == null)
return NotFound();
return View(instructionSetExtensionsByProcessor);
}
@@ -53,14 +52,14 @@ namespace Marechai.Areas.Admin.Controllers
{
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension");
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name");
return View();
}
// POST: InstructionSetExtensionsByProcessor/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create(
[Bind("Id,ProcessorId,ExtensionId")]
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor)
@@ -69,43 +68,51 @@ namespace Marechai.Areas.Admin.Controllers
{
_context.Add(instructionSetExtensionsByProcessor);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
instructionSetExtensionsByProcessor.ExtensionId);
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
instructionSetExtensionsByProcessor.ProcessorId);
return View(instructionSetExtensionsByProcessor);
}
// GET: InstructionSetExtensionsByProcessor/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(e => e.Id == id);
if(instructionSetExtensionsByProcessor == null) return NotFound();
if(instructionSetExtensionsByProcessor == null)
return NotFound();
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
instructionSetExtensionsByProcessor.ExtensionId);
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
instructionSetExtensionsByProcessor.ProcessorId);
return View(instructionSetExtensionsByProcessor);
}
// POST: InstructionSetExtensionsByProcessor/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
int id,
[Bind("Id,ProcessorId,ExtensionId")]
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor)
{
if(id != instructionSetExtensionsByProcessor.Id) return NotFound();
if(id != instructionSetExtensionsByProcessor.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -127,53 +134,49 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
instructionSetExtensionsByProcessor.ExtensionId);
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
instructionSetExtensionsByProcessor.ProcessorId);
return View(instructionSetExtensionsByProcessor);
}
// GET: InstructionSetExtensionsByProcessor/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
await _context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor)
.FirstOrDefaultAsync(m => m.Id == id);
if(instructionSetExtensionsByProcessor == null) return NotFound();
await _context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor).
FirstOrDefaultAsync(m => m.Id == id);
if(instructionSetExtensionsByProcessor == null)
return NotFound();
return View(instructionSetExtensionsByProcessor);
}
// POST: InstructionSetExtensionsByProcessor/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(e => e.Id == id);
_context.InstructionSetExtensionsByProcessor.Remove(instructionSetExtensionsByProcessor);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool InstructionSetExtensionsByProcessorExists(int id)
{
return _context.InstructionSetExtensionsByProcessor.Any(e => e.Id == id);
}
bool InstructionSetExtensionsByProcessorExists(int id) =>
_context.InstructionSetExtensionsByProcessor.Any(e => e.Id == id);
[AcceptVerbs("Get", "Post")]
public async Task<IActionResult> VerifyUnique(int processorId, int extensionId)
{
return
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(i =>
i.ProcessorId ==
processorId &&
i.ExtensionId == extensionId)
is null
? Json(true)
: Json("The selected processor already has the selected extension.");
}
public async Task<IActionResult> VerifyUnique(int processorId, int extensionId) =>
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(i => i.ProcessorId == processorId &&
i.ExtensionId == extensionId) is
null ? Json(true) : Json("The selected processor already has the selected extension.");
}
}

View File

@@ -38,16 +38,12 @@ using Microsoft.EntityFrameworkCore;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class InstructionSetExtensionsController : Controller
{
readonly MarechaiContext _context;
public InstructionSetExtensionsController(MarechaiContext context)
{
_context = context;
}
public InstructionSetExtensionsController(MarechaiContext context) => _context = context;
// GET: Admin/InstructionSetExtensions
public async Task<IActionResult> Index() =>
@@ -56,15 +52,18 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/InstructionSetExtensions/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSetExtension instructionSetExtension =
await _context.InstructionSetExtensions.FirstOrDefaultAsync(m => m.Id == id);
if(instructionSetExtension == null) return NotFound();
ViewBag.Processors = _context.InstructionSetExtensionsByProcessor.Where(e => e.ExtensionId == id)
.Join(_context.Processors, p => p.ProcessorId, i => i.Id, (p, i) => i)
.Select(p => p.Name);
if(instructionSetExtension == null)
return NotFound();
ViewBag.Processors = _context.InstructionSetExtensionsByProcessor.Where(e => e.ExtensionId == id).
Join(_context.Processors, p => p.ProcessorId, i => i.Id, (p, i) => i).
Select(p => p.Name);
return View(instructionSetExtension);
}
@@ -75,14 +74,14 @@ namespace Marechai.Areas.Admin.Controllers
// POST: Admin/InstructionSetExtensions/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Extension")] InstructionSetExtension instructionSetExtension)
{
if(ModelState.IsValid)
{
_context.Add(instructionSetExtension);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
@@ -92,10 +91,13 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/InstructionSetExtensions/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSetExtension instructionSetExtension = await _context.InstructionSetExtensions.FindAsync(id);
if(instructionSetExtension == null) return NotFound();
if(instructionSetExtension == null)
return NotFound();
return View(instructionSetExtension);
}
@@ -103,12 +105,12 @@ namespace Marechai.Areas.Admin.Controllers
// POST: Admin/InstructionSetExtensions/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
int id, [Bind("Id,Extension")] InstructionSetExtension instructionSetExtension)
{
if(id != instructionSetExtension.Id) return NotFound();
if(id != instructionSetExtension.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -119,7 +121,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!InstructionSetExtensionExists(instructionSetExtension.Id)) return NotFound();
if(!InstructionSetExtensionExists(instructionSetExtension.Id))
return NotFound();
throw;
}
@@ -133,37 +136,35 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/InstructionSetExtensions/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSetExtension instructionSetExtension =
await _context.InstructionSetExtensions.FirstOrDefaultAsync(m => m.Id == id);
if(instructionSetExtension == null) return NotFound();
if(instructionSetExtension == null)
return NotFound();
return View(instructionSetExtension);
}
// POST: Admin/InstructionSetExtensions/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
InstructionSetExtension instructionSetExtension = await _context.InstructionSetExtensions.FindAsync(id);
_context.InstructionSetExtensions.Remove(instructionSetExtension);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool InstructionSetExtensionExists(int id)
{
return _context.InstructionSetExtensions.Any(e => e.Id == id);
}
bool InstructionSetExtensionExists(int id) => _context.InstructionSetExtensions.Any(e => e.Id == id);
[AcceptVerbs("Get", "Post")]
public IActionResult VerifyUnique(string extension) =>
_context.InstructionSetExtensions.Any(i => string.Equals(i.Extension, extension,
StringComparison.InvariantCultureIgnoreCase))
? Json("Instruction set extension already exists.")
: Json(true);
? Json("Instruction set extension already exists.") : Json(true);
}
}

View File

@@ -38,16 +38,12 @@ using Microsoft.EntityFrameworkCore;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class InstructionSetsController : Controller
{
readonly MarechaiContext _context;
public InstructionSetsController(MarechaiContext context)
{
_context = context;
}
public InstructionSetsController(MarechaiContext context) => _context = context;
// GET: Admin/InstructionSets
public async Task<IActionResult> Index() =>
@@ -56,10 +52,13 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/InstructionSets/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSet instructionSet = await _context.InstructionSets.FirstOrDefaultAsync(m => m.Id == id);
if(instructionSet == null) return NotFound();
if(instructionSet == null)
return NotFound();
return View(instructionSet);
}
@@ -70,24 +69,28 @@ namespace Marechai.Areas.Admin.Controllers
// POST: Admin/InstructionSets/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Name")] InstructionSet instructionSet)
{
if(!ModelState.IsValid) return View(instructionSet);
if(!ModelState.IsValid)
return View(instructionSet);
_context.Add(instructionSet);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
// GET: Admin/InstructionSets/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSet instructionSet = await _context.InstructionSets.FindAsync(id);
if(instructionSet == null) return NotFound();
if(instructionSet == null)
return NotFound();
return View(instructionSet);
}
@@ -95,11 +98,11 @@ namespace Marechai.Areas.Admin.Controllers
// POST: Admin/InstructionSets/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Name")] InstructionSet instructionSet)
{
if(id != instructionSet.Id) return NotFound();
if(id != instructionSet.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -110,7 +113,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!InstructionSetExists(instructionSet.Id)) return NotFound();
if(!InstructionSetExists(instructionSet.Id))
return NotFound();
throw;
}
@@ -124,35 +128,33 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/InstructionSets/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
InstructionSet instructionSet = await _context.InstructionSets.FirstOrDefaultAsync(m => m.Id == id);
if(instructionSet == null) return NotFound();
if(instructionSet == null)
return NotFound();
return View(instructionSet);
}
// POST: Admin/InstructionSets/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
InstructionSet instructionSet = await _context.InstructionSets.FindAsync(id);
_context.InstructionSets.Remove(instructionSet);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool InstructionSetExists(int id)
{
return _context.InstructionSets.Any(e => e.Id == id);
}
bool InstructionSetExists(int id) => _context.InstructionSets.Any(e => e.Id == id);
[AcceptVerbs("Get", "Post")]
public IActionResult VerifyUnique(string name) =>
_context.InstructionSets.Any(i => string.Equals(i.Name, name, StringComparison.InvariantCultureIgnoreCase))
? Json("Instruction set already exists.")
: Json(true);
? Json("Instruction set already exists.") : Json(true);
}
}

View File

@@ -7,30 +7,26 @@ using Microsoft.EntityFrameworkCore;
namespace Marechai
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class LicensesController : Controller
{
readonly MarechaiContext _context;
public LicensesController(MarechaiContext context)
{
_context = context;
}
public LicensesController(MarechaiContext context) => _context = context;
// GET: Licenses
public async Task<IActionResult> Index()
{
return View(await _context.Licenses.OrderBy(l => l.Name).ToListAsync());
}
public async Task<IActionResult> Index() => View(await _context.Licenses.OrderBy(l => l.Name).ToListAsync());
// GET: Licenses/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
License license = await _context.Licenses.FirstOrDefaultAsync(m => m.Id == id);
if(license == null) return NotFound();
if(license == null)
return NotFound();
return View(license);
}
@@ -41,8 +37,7 @@ namespace Marechai
// POST: Licenses/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Name,SPDX,FsfApproved,OsiApproved,Link,Text,Id")]
License license)
{
@@ -50,6 +45,7 @@ namespace Marechai
{
_context.Add(license);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
@@ -59,10 +55,13 @@ namespace Marechai
// GET: Licenses/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
License license = await _context.Licenses.FindAsync(id);
if(license == null) return NotFound();
if(license == null)
return NotFound();
return View(license);
}
@@ -70,12 +69,12 @@ namespace Marechai
// POST: Licenses/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Name,SPDX,FsfApproved,OsiApproved,Link,Text,Id")]
License license)
{
if(id != license.Id) return NotFound();
if(id != license.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -86,7 +85,8 @@ namespace Marechai
}
catch(DbUpdateConcurrencyException)
{
if(!LicenseExists(license.Id)) return NotFound();
if(!LicenseExists(license.Id))
return NotFound();
throw;
}
@@ -100,29 +100,28 @@ namespace Marechai
// GET: Licenses/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
License license = await _context.Licenses.FirstOrDefaultAsync(m => m.Id == id);
if(license == null) return NotFound();
if(license == null)
return NotFound();
return View(license);
}
// POST: Licenses/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
License license = await _context.Licenses.FindAsync(id);
_context.Licenses.Remove(license);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool LicenseExists(int id)
{
return _context.Licenses.Any(e => e.Id == id);
}
bool LicenseExists(int id) => _context.Licenses.Any(e => e.Id == id);
}
}

View File

@@ -30,8 +30,8 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -40,23 +40,21 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class MachineFamiliesController : Controller
{
readonly MarechaiContext _context;
public MachineFamiliesController(MarechaiContext context)
{
_context = context;
}
public MachineFamiliesController(MarechaiContext context) => _context = context;
// GET: Admin/MachineFamilies
public async Task<IActionResult> Index()
{
IIncludableQueryable<MachineFamily, Company> marechaiContext = _context.MachineFamilies.Include(m => m.Company);
return View(await marechaiContext.OrderBy(m => m.Company.Name).ThenBy(m => m.Name)
.Select(m => new MachineFamilyViewModel
IIncludableQueryable<MachineFamily, Company> marechaiContext =
_context.MachineFamilies.Include(m => m.Company);
return View(await marechaiContext.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
Select(m => new MachineFamilyViewModel
{
Id = m.Id, Company = m.Company.Name, Name = m.Name
}).ToListAsync());
@@ -65,11 +63,14 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/MachineFamilies/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MachineFamily machineFamily =
await _context.MachineFamilies.Include(m => m.Company).FirstOrDefaultAsync(m => m.Id == id);
if(machineFamily == null) return NotFound();
if(machineFamily == null)
return NotFound();
return View(machineFamily);
}
@@ -78,47 +79,53 @@ namespace Marechai.Areas.Admin.Controllers
public IActionResult Create()
{
ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name");
return View();
}
// POST: Admin/MachineFamilies/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,CompanyId,Name")] MachineFamily machineFamily)
{
if(ModelState.IsValid)
{
_context.Add(machineFamily);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", machineFamily.CompanyId);
return View(machineFamily);
}
// GET: Admin/MachineFamilies/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MachineFamily machineFamily = await _context.MachineFamilies.FindAsync(id);
if(machineFamily == null) return NotFound();
if(machineFamily == null)
return NotFound();
ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", machineFamily.CompanyId);
return View(machineFamily);
}
// POST: Admin/MachineFamilies/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,CompanyId,Name")] MachineFamily machineFamily)
{
if(id != machineFamily.Id) return NotFound();
if(id != machineFamily.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -129,7 +136,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!MachineFamilyExists(machineFamily.Id)) return NotFound();
if(!MachineFamilyExists(machineFamily.Id))
return NotFound();
throw;
}
@@ -138,36 +146,36 @@ namespace Marechai.Areas.Admin.Controllers
}
ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", machineFamily.CompanyId);
return View(machineFamily);
}
// GET: Admin/MachineFamilies/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MachineFamily machineFamily =
await _context.MachineFamilies.Include(m => m.Company).FirstOrDefaultAsync(m => m.Id == id);
if(machineFamily == null) return NotFound();
if(machineFamily == null)
return NotFound();
return View(machineFamily);
}
// POST: Admin/MachineFamilies/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
MachineFamily machineFamily = await _context.MachineFamilies.FindAsync(id);
_context.MachineFamilies.Remove(machineFamily);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool MachineFamilyExists(int id)
{
return _context.MachineFamilies.Any(e => e.Id == id);
}
bool MachineFamilyExists(int id) => _context.MachineFamilies.Any(e => e.Id == id);
}
}

View File

@@ -2,8 +2,8 @@ using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Marechai.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
@@ -16,8 +16,7 @@ using SixLabors.ImageSharp.Formats;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class MachinePhotosController : Controller
{
readonly MarechaiContext _context;
@@ -33,74 +32,57 @@ namespace Marechai.Areas.Admin.Controllers
}
// GET: MachinePhotos
public async Task<IActionResult> Index()
public async Task<IActionResult> Index() => View(await _context.
MachinePhotos.Include(m => m.Machine).
Include(m => m.Machine.Company).Include(m => m.User).
Select(p => new MachinePhotoViewModel
{
return View(await _context.MachinePhotos.Include(m => m.Machine).Include(m => m.Machine.Company)
.Include(m => m.User).Select(p => new MachinePhotoViewModel
{
Id = p.Id,
Author = p.Author,
Id = p.Id, Author = p.Author,
License = p.License.Name,
Machine =
$"{p.Machine.Company.Name} {p.Machine.Name}",
UploadDate = p.UploadDate,
UploadUser = p.User.UserName,
LicenseId = p.License.Id
}).OrderBy(p => p.Machine)
.ThenBy(p => p.UploadUser).ThenBy(p => p.UploadDate).ToListAsync());
}
}).OrderBy(p => p.Machine).ThenBy(p => p.UploadUser).
ThenBy(p => p.UploadDate).ToListAsync());
// GET: MachinePhotos/Details/5
public async Task<IActionResult> Details(Guid? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MachinePhotoDetailsViewModel machinePhoto = await _context
.MachinePhotos
.Select(m => new MachinePhotoDetailsViewModel
MachinePhotoDetailsViewModel machinePhoto =
await _context.MachinePhotos.Select(m => new MachinePhotoDetailsViewModel
{
Id = m.Id,
CameraManufacturer = m.CameraManufacturer,
Id = m.Id, CameraManufacturer = m.CameraManufacturer,
CameraModel = m.CameraModel,
ColorSpace = m.ColorSpace,
Comments = m.Comments,
ColorSpace = m.ColorSpace, Comments = m.Comments,
Contrast = m.Contrast,
CreationDate = m.CreationDate,
DigitalZoomRatio = m.DigitalZoomRatio,
CreationDate = m.CreationDate, DigitalZoomRatio = m.DigitalZoomRatio,
ExifVersion = m.ExifVersion,
Exposure = m.Exposure,
ExposureProgram = m.ExposureProgram,
Flash = m.Flash,
Focal = m.Focal,
FocalLength = m.FocalLength,
FocalLengthEquivalent =
m.FocalLengthEquivalent,
HorizontalResolution =
m.HorizontalResolution,
IsoRating = m.IsoRating,
Exposure = m.Exposure, ExposureProgram = m.ExposureProgram,
Flash = m.Flash, Focal = m.Focal,
FocalLength = m.FocalLength, FocalLengthEquivalent = m.FocalLengthEquivalent,
HorizontalResolution = m.HorizontalResolution, IsoRating = m.IsoRating,
Lens = m.Lens,
LightSource = m.LightSource,
MeteringMode = m.MeteringMode,
LightSource = m.LightSource, MeteringMode = m.MeteringMode,
ResolutionUnit = m.ResolutionUnit,
Orientation = m.Orientation,
Saturation = m.Saturation,
Orientation = m.Orientation, Saturation = m.Saturation,
SceneCaptureType = m.SceneCaptureType,
SensingMethod = m.SensingMethod,
Sharpness = m.Sharpness,
SensingMethod = m.SensingMethod, Sharpness = m.Sharpness,
SoftwareUsed = m.SoftwareUsed,
SubjectDistanceRange =
m.SubjectDistanceRange,
UploadDate = m.UploadDate,
VerticalResolution = m.VerticalResolution,
WhiteBalance = m.WhiteBalance,
SubjectDistanceRange = m.SubjectDistanceRange, UploadDate = m.UploadDate,
VerticalResolution = m.VerticalResolution, WhiteBalance = m.WhiteBalance,
License = m.License.Name,
UploadUser = m.User.UserName,
Machine =
$"{m.Machine.Company.Name} {m.Machine.Name}",
MachineId = m.Machine.Id,
Source = m.Source
Machine = $"{m.Machine.Company.Name} {m.Machine.Name}",
MachineId = m.Machine.Id, Source = m.Source
}).FirstOrDefaultAsync(m => m.Id == id);
if(machinePhoto == null) return NotFound();
if(machinePhoto == null)
return NotFound();
return View(machinePhoto);
}
@@ -108,26 +90,31 @@ namespace Marechai.Areas.Admin.Controllers
// GET: MachinePhotos/Create
public IActionResult Create()
{
ViewData["MachineId"] =
new
SelectList(_context.Machines.OrderBy(c => c.Company.Name).ThenBy(c => c.Name).Select(m => new {m.Id, Name = $"{m.Company.Name} {m.Name}"}),
"Id", "Name");
ViewData["LicenseId"] =
new SelectList(_context.Licenses.OrderBy(c => c.Name).Select(l => new {l.Id, l.Name}), "Id", "Name");
ViewData["MachineId"] = new SelectList(_context.Machines.OrderBy(c => c.Company.Name).ThenBy(c => c.Name).
Select(m => new
{
m.Id, Name = $"{m.Company.Name} {m.Name}"
}), "Id", "Name");
ViewData["LicenseId"] = new SelectList(_context.Licenses.OrderBy(c => c.Name).Select(l => new
{
l.Id, l.Name
}), "Id", "Name");
return View();
}
// POST: MachinePhotos/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("MachineId,LicenseId,Photo,Source")]
MachinePhotoViewModel machinePhoto)
{
if(!ModelState.IsValid) return View(machinePhoto);
if(!ModelState.IsValid)
return View(machinePhoto);
Guid newId = Guid.NewGuid();
var newId = Guid.NewGuid();
string tmpPath = Path.GetTempPath();
string tmpFileName = newId + ".tmp";
string tmpFile = Path.Combine(tmpPath, tmpFileName);
@@ -135,26 +122,31 @@ namespace Marechai.Areas.Admin.Controllers
if(System.IO.File.Exists(tmpFile))
{
machinePhoto.ErrorMessage = "Colliding temp file please retry.";
return View(machinePhoto);
}
using(FileStream tmpStream = new FileStream(tmpFile, FileMode.CreateNew))
using(var tmpStream = new FileStream(tmpFile, FileMode.CreateNew))
await machinePhoto.Photo.CopyToAsync(tmpStream);
IImageFormat imageinfo = Image.DetectFormat(tmpFile);
string extension;
switch(imageinfo?.Name)
{
case "JPEG":
case"JPEG":
extension = ".jpg";
break;
case "PNG":
case"PNG":
extension = ".png";
break;
default:
System.IO.File.Delete(tmpFile);
machinePhoto.ErrorMessage = "Unsupported file format, only JPEG and PNG are allowed at the moment.";
return View(machinePhoto);
}
@@ -168,24 +160,34 @@ namespace Marechai.Areas.Admin.Controllers
_context.Add(photo);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Details), new {Id = newId});
return RedirectToAction(nameof(Details), new
{
Id = newId
});
}
// GET: MachinePhotos/Edit/5
public async Task<IActionResult> Edit(Guid? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MachinePhoto machinePhoto = await _context.MachinePhotos.FindAsync(id);
if(machinePhoto == null) return NotFound();
ViewData["MachineId"] =
new
SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new {m.Id, Name = $"{m.Company.Name} {m.Name}"}),
"Id", "Name", machinePhoto.MachineId);
ViewData["LicenseId"] =
new SelectList(_context.Licenses.OrderBy(l => l.Name).Select(l => new {l.Id, l.Name}), "Id", "Name",
machinePhoto.LicenseId);
if(machinePhoto == null)
return NotFound();
ViewData["MachineId"] = new SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
Select(m => new
{
m.Id, Name = $"{m.Company.Name} {m.Name}"
}), "Id", "Name", machinePhoto.MachineId);
ViewData["LicenseId"] = new SelectList(_context.Licenses.OrderBy(l => l.Name).Select(l => new
{
l.Id, l.Name
}), "Id", "Name", machinePhoto.LicenseId);
return View(machinePhoto);
}
@@ -193,15 +195,17 @@ namespace Marechai.Areas.Admin.Controllers
// POST: MachinePhotos/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(Guid id, [Bind(
"Author,CameraManufacturer,CameraModel,ColorSpace,Comments,Contrast,CreationDate,DigitalZoomRatio,ExifVersion,Exposure,ExposureMethod,ExposureProgram,Flash,Focal,FocalLength,FocalLengthEquivalent,HorizontalResolution,IsoRating,Lens,LicenseId,LightSource,MachineId,MeteringMode,ResolutionUnit,Orientation,Saturation,SceneCaptureType,SensingMethod,Sharpness,SoftwareUsed,SubjectDistanceRange,VerticalResolution,WhiteBalance,Id,Source")]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
Guid id,
[Bind("Author,CameraManufacturer,CameraModel,ColorSpace,Comments,Contrast,CreationDate,DigitalZoomRatio,ExifVersion,Exposure,ExposureMethod,ExposureProgram,Flash,Focal,FocalLength,FocalLengthEquivalent,HorizontalResolution,IsoRating,Lens,LicenseId,LightSource,MachineId,MeteringMode,ResolutionUnit,Orientation,Saturation,SceneCaptureType,SensingMethod,Sharpness,SoftwareUsed,SubjectDistanceRange,VerticalResolution,WhiteBalance,Id,Source")]
MachinePhoto machinePhoto)
{
if(id != machinePhoto.Id) return NotFound();
if(id != machinePhoto.Id)
return NotFound();
if(!ModelState.IsValid) return View(machinePhoto);
if(!ModelState.IsValid)
return View(machinePhoto);
try
{
@@ -210,7 +214,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!MachinePhotoExists(machinePhoto.Id)) return NotFound();
if(!MachinePhotoExists(machinePhoto.Id))
return NotFound();
throw;
}
@@ -221,42 +226,43 @@ namespace Marechai.Areas.Admin.Controllers
// GET: MachinePhotos/Delete/5
public async Task<IActionResult> Delete(Guid? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MachinePhotoViewModel machinePhoto = await _context
.MachinePhotos.Include(m => m.Machine)
.Include(m => m.Machine.Company).Include(m => m.User)
.Select(p => new MachinePhotoViewModel
MachinePhotoViewModel machinePhoto =
await _context.MachinePhotos.Include(m => m.Machine).Include(m => m.Machine.Company).
Include(m => m.User).Select(p => new MachinePhotoViewModel
{
Id = p.Id,
Author = p.Author,
Id = p.Id, Author = p.Author,
License = p.License.Name,
Machine =
$"{p.Machine.Company.Name} {p.Machine.Name}",
UploadDate = p.UploadDate,
UploadUser = p.User.UserName,
LicenseId = p.License.Id
}).OrderBy(p => p.Machine).ThenBy(p => p.UploadUser)
.ThenBy(p => p.UploadDate).FirstOrDefaultAsync(m => m.Id == id);
Machine = $"{p.Machine.Company.Name} {p.Machine.Name}", UploadDate = p.UploadDate,
UploadUser = p.User.UserName, LicenseId = p.License.Id
}).OrderBy(p => p.Machine).ThenBy(p => p.UploadUser).ThenBy(p => p.UploadDate).
FirstOrDefaultAsync(m => m.Id == id);
if(machinePhoto == null) return NotFound();
if(machinePhoto == null)
return NotFound();
return View(machinePhoto);
}
// POST: MachinePhotos/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(Guid id)
{
MachinePhoto machinePhoto = await _context.MachinePhotos.FindAsync(id);
_context.MachinePhotos.Remove(machinePhoto);
await _context.SaveChangesAsync();
foreach(string format in new[] {"jpg", "webp"})
foreach(string format in new[]
{
foreach(int multiplier in new[] {1, 2, 3})
"jpg", "webp"
})
{
foreach(int multiplier in new[]
{
1, 2, 3
})
System.IO.File.Delete(Path.Combine(hostingEnvironment.WebRootPath, "assets/photos/machines/thumbs",
format, $"{multiplier}x", id + $".{format}"));
}
@@ -264,9 +270,6 @@ namespace Marechai.Areas.Admin.Controllers
return RedirectToAction(nameof(Index));
}
bool MachinePhotoExists(Guid id)
{
return _context.MachinePhotos.Any(e => e.Id == id);
}
bool MachinePhotoExists(Guid id) => _context.MachinePhotos.Any(e => e.Id == id);
}
}

View File

@@ -31,9 +31,9 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Marechai.Areas.Admin.Models;
using Marechai.Database;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -42,43 +42,39 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class MachinesController : Controller
{
readonly MarechaiContext _context;
public MachinesController(MarechaiContext context)
{
_context = context;
}
public MachinesController(MarechaiContext context) => _context = context;
// GET: Admin/Machines
public async Task<IActionResult> Index()
{
IIncludableQueryable<Machine, MachineFamily> marechaiContext =
_context.Machines.Include(m => m.Company).Include(m => m.Family);
return View(await marechaiContext.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).ThenBy(m => m.Family.Name)
.Select(m => new MachineViewModel
return View(await marechaiContext.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
ThenBy(m => m.Family.Name).Select(m => new MachineViewModel
{
Id = m.Id,
Company = m.Company.Name,
Name = m.Name,
Id = m.Id, Company = m.Company.Name, Name = m.Name,
Model = m.Model,
Introduced = m.Introduced,
Type = m.Type,
Family = m.Family.Name
Introduced = m.Introduced, Type = m.Type, Family = m.Family.Name
}).ToListAsync());
}
// GET: Admin/Machines/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Machine machine = await _context.Machines.Include(m => m.Company).Include(m => m.Family)
.FirstOrDefaultAsync(m => m.Id == id);
if(machine == null) return NotFound();
Machine machine = await _context.Machines.Include(m => m.Company).Include(m => m.Family).
FirstOrDefaultAsync(m => m.Id == id);
if(machine == null)
return NotFound();
return View(machine);
}
@@ -88,14 +84,14 @@ namespace Marechai.Areas.Admin.Controllers
{
ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name");
ViewData["FamilyId"] = new SelectList(_context.MachineFamilies, "Id", "Name");
return View();
}
// POST: Admin/Machines/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,CompanyId,Name,Type,Introduced,FamilyId,Model")]
Machine machine)
{
@@ -104,18 +100,25 @@ namespace Marechai.Areas.Admin.Controllers
_context.Add(machine);
await _context.SaveChangesAsync();
NewsType newsType = new NewsType();
var newsType = new NewsType();
switch(machine.Type)
{
case MachineType.Computer:
newsType = NewsType.NewComputerInDb;
break;
case MachineType.Console:
newsType = NewsType.NewConsoleInDb;
break;
}
_context.News.Add(new News {AddedId = machine.Id, Date = DateTime.UtcNow, Type = newsType});
_context.News.Add(new News
{
AddedId = machine.Id, Date = DateTime.UtcNow, Type = newsType
});
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
@@ -123,31 +126,36 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", machine.CompanyId);
ViewData["FamilyId"] = new SelectList(_context.MachineFamilies, "Id", "Name", machine.FamilyId);
return View(machine);
}
// GET: Admin/Machines/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Machine machine = await _context.Machines.FindAsync(id);
if(machine == null) return NotFound();
if(machine == null)
return NotFound();
ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", machine.CompanyId);
ViewData["FamilyId"] = new SelectList(_context.MachineFamilies, "Id", "Name", machine.FamilyId);
return View(machine);
}
// POST: Admin/Machines/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,CompanyId,Name,Type,Introduced,FamilyId,Model")]
Machine machine)
{
if(id != machine.Id) return NotFound();
if(id != machine.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -156,23 +164,31 @@ namespace Marechai.Areas.Admin.Controllers
_context.Update(machine);
await _context.SaveChangesAsync();
NewsType newsType = new NewsType();
var newsType = new NewsType();
switch(machine.Type)
{
case MachineType.Computer:
newsType = NewsType.UpdatedComputerInDb;
break;
case MachineType.Console:
newsType = NewsType.UpdatedConsoleInDb;
break;
}
_context.News.Add(new News {AddedId = machine.Id, Date = DateTime.UtcNow, Type = newsType});
_context.News.Add(new News
{
AddedId = machine.Id, Date = DateTime.UtcNow, Type = newsType
});
await _context.SaveChangesAsync();
}
catch(DbUpdateConcurrencyException)
{
if(!MachineExists(machine.Id)) return NotFound();
if(!MachineExists(machine.Id))
return NotFound();
throw;
}
@@ -182,36 +198,36 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", machine.CompanyId);
ViewData["FamilyId"] = new SelectList(_context.MachineFamilies, "Id", "Name", machine.FamilyId);
return View(machine);
}
// GET: Admin/Machines/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Machine machine = await _context.Machines.Include(m => m.Company).Include(m => m.Family)
.FirstOrDefaultAsync(m => m.Id == id);
if(machine == null) return NotFound();
Machine machine = await _context.Machines.Include(m => m.Company).Include(m => m.Family).
FirstOrDefaultAsync(m => m.Id == id);
if(machine == null)
return NotFound();
return View(machine);
}
// POST: Admin/Machines/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Machine machine = await _context.Machines.FindAsync(id);
_context.Machines.Remove(machine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool MachineExists(int id)
{
return _context.Machines.Any(e => e.Id == id);
}
bool MachineExists(int id) => _context.Machines.Any(e => e.Id == id);
}
}

View File

@@ -30,8 +30,8 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -40,43 +40,38 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class MemoryByMachinesController : Controller
{
readonly MarechaiContext _context;
public MemoryByMachinesController(MarechaiContext context)
{
_context = context;
}
public MemoryByMachinesController(MarechaiContext context) => _context = context;
// GET: Admin/MemoryByMachines
public async Task<IActionResult> Index()
{
IIncludableQueryable<MemoryByMachine, Machine> marechaiContext =
_context.MemoryByMachine.Include(m => m.Machine);
return View(await marechaiContext.OrderBy(m => m.Machine.Name).ThenBy(m => m.Usage).ThenBy(m => m.Size)
.ThenBy(m => m.Type)
.Select(m => new MemoryByMachineViewModel
return View(await marechaiContext.OrderBy(m => m.Machine.Name).ThenBy(m => m.Usage).ThenBy(m => m.Size).
ThenBy(m => m.Type).Select(m => new MemoryByMachineViewModel
{
Id = m.Id,
Machine = m.Machine.Name,
Size = m.Size,
Speed = m.Speed,
Type = m.Type,
Usage = m.Usage
Id = m.Id, Machine = m.Machine.Name, Size = m.Size, Speed = m.Speed,
Type = m.Type, Usage = m.Usage
}).ToListAsync());
}
// GET: Admin/MemoryByMachines/Details/5
public async Task<IActionResult> Details(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MemoryByMachine memoryByMachine =
await _context.MemoryByMachine.Include(m => m.Machine).FirstOrDefaultAsync(m => m.Id == id);
if(memoryByMachine == null) return NotFound();
if(memoryByMachine == null)
return NotFound();
return View(memoryByMachine);
}
@@ -85,14 +80,14 @@ namespace Marechai.Areas.Admin.Controllers
public IActionResult Create()
{
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name");
return View();
}
// POST: Admin/MemoryByMachines/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("MachineId,Type,Usage,Size,Speed,Id")]
MemoryByMachine memoryByMachine)
{
@@ -100,34 +95,40 @@ namespace Marechai.Areas.Admin.Controllers
{
_context.Add(memoryByMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", memoryByMachine.MachineId);
return View(memoryByMachine);
}
// GET: Admin/MemoryByMachines/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MemoryByMachine memoryByMachine = await _context.MemoryByMachine.FindAsync(id);
if(memoryByMachine == null) return NotFound();
if(memoryByMachine == null)
return NotFound();
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", memoryByMachine.MachineId);
return View(memoryByMachine);
}
// POST: Admin/MemoryByMachines/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(long id, [Bind("MachineId,Type,Usage,Size,Speed,Id")]
MemoryByMachine memoryByMachine)
{
if(id != memoryByMachine.Id) return NotFound();
if(id != memoryByMachine.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -138,7 +139,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!MemoryByMachineExists(memoryByMachine.Id)) return NotFound();
if(!MemoryByMachineExists(memoryByMachine.Id))
return NotFound();
throw;
}
@@ -147,36 +149,36 @@ namespace Marechai.Areas.Admin.Controllers
}
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", memoryByMachine.MachineId);
return View(memoryByMachine);
}
// GET: Admin/MemoryByMachines/Delete/5
public async Task<IActionResult> Delete(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MemoryByMachine memoryByMachine =
await _context.MemoryByMachine.Include(m => m.Machine).FirstOrDefaultAsync(m => m.Id == id);
if(memoryByMachine == null) return NotFound();
if(memoryByMachine == null)
return NotFound();
return View(memoryByMachine);
}
// POST: Admin/MemoryByMachines/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
MemoryByMachine memoryByMachine = await _context.MemoryByMachine.FindAsync(id);
_context.MemoryByMachine.Remove(memoryByMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool MemoryByMachineExists(long id)
{
return _context.MemoryByMachine.Any(e => e.Id == id);
}
bool MemoryByMachineExists(long id) => _context.MemoryByMachine.Any(e => e.Id == id);
}
}

View File

@@ -30,8 +30,8 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -40,62 +40,55 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class MemoryByOwnedMachinesController : Controller
{
readonly MarechaiContext _context;
public MemoryByOwnedMachinesController(MarechaiContext context)
{
_context = context;
}
public MemoryByOwnedMachinesController(MarechaiContext context) => _context = context;
// GET: Admin/MemoryByOwnedMachines
public async Task<IActionResult> Index()
{
IIncludableQueryable<MemoryByOwnedMachine, OwnedMachine> marechaiContext =
_context.MemoryByOwnedMachine.Include(m => m.OwnedMachine);
return View(await marechaiContext.OrderBy(m => m.OwnedMachine.Machine.Company.Name)
.ThenBy(m => m.OwnedMachine.Machine.Name)
.ThenBy(m => m.OwnedMachine.User.UserName).ThenBy(m => m.Usage)
.ThenBy(m => m.Size).ThenBy(m => m.Type)
.Select(m => new MemoryByMachineViewModel
return View(await marechaiContext.OrderBy(m => m.OwnedMachine.Machine.Company.Name).
ThenBy(m => m.OwnedMachine.Machine.Name).
ThenBy(m => m.OwnedMachine.User.UserName).ThenBy(m => m.Usage).
ThenBy(m => m.Size).ThenBy(m => m.Type).
Select(m => new MemoryByMachineViewModel
{
Id = m.Id,
Machine =
$"{m.OwnedMachine.Machine.Company.Name} {m.OwnedMachine.Machine.Name} <{m.OwnedMachine.User.UserName}>",
Size = m.Size,
Speed = m.Speed,
Type = m.Type,
Usage = m.Usage
Size = m.Size, Speed = m.Speed, Type = m.Type, Usage = m.Usage
}).ToListAsync());
}
// GET: Admin/MemoryByOwnedMachines/Details/5
public async Task<IActionResult> Details(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
IIncludableQueryable<MemoryByOwnedMachine, OwnedMachine> marechaiContext =
_context.MemoryByOwnedMachine.Include(m => m.OwnedMachine);
MemoryByMachineViewModel memoryByOwnedMachine = await marechaiContext
.OrderBy(m => m.OwnedMachine.Machine.Company.Name)
.ThenBy(m => m.OwnedMachine.Machine.Name)
.ThenBy(m => m.OwnedMachine.User.UserName)
.ThenBy(m => m.Usage).ThenBy(m => m.Size)
.ThenBy(m => m.Type)
.Select(m => new MemoryByMachineViewModel
MemoryByMachineViewModel memoryByOwnedMachine =
await marechaiContext.OrderBy(m => m.OwnedMachine.Machine.Company.Name).
ThenBy(m => m.OwnedMachine.Machine.Name).
ThenBy(m => m.OwnedMachine.User.UserName).ThenBy(m => m.Usage).
ThenBy(m => m.Size).ThenBy(m => m.Type).Select(m => new MemoryByMachineViewModel
{
Id = m.Id,
Machine =
$"{m.OwnedMachine.Machine.Company.Name} {m.OwnedMachine.Machine.Name} <{m.OwnedMachine.User.UserName}>",
Size = m.Size,
Speed = m.Speed,
Type = m.Type,
Usage = m.Usage
Size = m.Size, Speed = m.Speed, Type = m.Type, Usage = m.Usage
}).FirstOrDefaultAsync(m => m.Id == id);
if(memoryByOwnedMachine == null) return NotFound();
if(memoryByOwnedMachine == null)
return NotFound();
return View(memoryByOwnedMachine);
}
@@ -103,18 +96,22 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/MemoryByOwnedMachines/Create
public IActionResult Create()
{
ViewData["OwnedMachineId"] =
new
SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).ThenBy(m => m.Machine.Name).ThenBy(m => m.User.UserName).Select(m => new {m.Id, Name = $"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"}),
"Id", "Name");
ViewData["OwnedMachineId"] = new SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).
ThenBy(m => m.Machine.Name).
ThenBy(m => m.User.UserName).Select(m => new
{
m.Id,
Name =
$"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"
}), "Id", "Name");
return View();
}
// POST: Admin/MemoryByOwnedMachines/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("OwnedMachineId,Type,Usage,Size,Speed,Id")]
MemoryByOwnedMachine memoryByOwnedMachine)
{
@@ -122,40 +119,54 @@ namespace Marechai.Areas.Admin.Controllers
{
_context.Add(memoryByOwnedMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["OwnedMachineId"] =
new
SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).ThenBy(m => m.Machine.Name).ThenBy(m => m.User.UserName).Select(m => new {m.Id, Name = $"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"}),
"Id", "Name", memoryByOwnedMachine.OwnedMachineId);
ViewData["OwnedMachineId"] = new SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).
ThenBy(m => m.Machine.Name).
ThenBy(m => m.User.UserName).Select(m => new
{
m.Id,
Name =
$"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"
}), "Id", "Name", memoryByOwnedMachine.OwnedMachineId);
return View(memoryByOwnedMachine);
}
// GET: Admin/MemoryByOwnedMachines/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MemoryByOwnedMachine memoryByOwnedMachine = await _context.MemoryByOwnedMachine.FindAsync(id);
if(memoryByOwnedMachine == null) return NotFound();
ViewData["OwnedMachineId"] =
new
SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).ThenBy(m => m.Machine.Name).ThenBy(m => m.User.UserName).Select(m => new {m.Id, Name = $"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"}),
"Id", "Name", memoryByOwnedMachine.OwnedMachineId);
if(memoryByOwnedMachine == null)
return NotFound();
ViewData["OwnedMachineId"] = new SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).
ThenBy(m => m.Machine.Name).
ThenBy(m => m.User.UserName).Select(m => new
{
m.Id,
Name =
$"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"
}), "Id", "Name", memoryByOwnedMachine.OwnedMachineId);
return View(memoryByOwnedMachine);
}
// POST: Admin/MemoryByOwnedMachines/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(long id, [Bind("OwnedMachineId,Type,Usage,Size,Speed,Id")]
MemoryByOwnedMachine memoryByOwnedMachine)
{
if(id != memoryByOwnedMachine.Id) return NotFound();
if(id != memoryByOwnedMachine.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -166,7 +177,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!MemoryByOwnedMachineExists(memoryByOwnedMachine.Id)) return NotFound();
if(!MemoryByOwnedMachineExists(memoryByOwnedMachine.Id))
return NotFound();
throw;
}
@@ -174,40 +186,44 @@ namespace Marechai.Areas.Admin.Controllers
return RedirectToAction(nameof(Index));
}
ViewData["OwnedMachineId"] =
new
SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).ThenBy(m => m.Machine.Name).ThenBy(m => m.User.UserName).Select(m => new {m.Id, Name = $"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"}),
"Id", "Name", memoryByOwnedMachine.OwnedMachineId);
ViewData["OwnedMachineId"] = new SelectList(_context.OwnedMachines.OrderBy(m => m.Machine.Company.Name).
ThenBy(m => m.Machine.Name).
ThenBy(m => m.User.UserName).Select(m => new
{
m.Id,
Name =
$"{m.Machine.Company.Name} {m.Machine.Name} <{m.User.UserName}>"
}), "Id", "Name", memoryByOwnedMachine.OwnedMachineId);
return View(memoryByOwnedMachine);
}
// GET: Admin/MemoryByOwnedMachines/Delete/5
public async Task<IActionResult> Delete(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
MemoryByOwnedMachine memoryByOwnedMachine =
await _context.MemoryByOwnedMachine.Include(m => m.OwnedMachine).FirstOrDefaultAsync(m => m.Id == id);
if(memoryByOwnedMachine == null) return NotFound();
if(memoryByOwnedMachine == null)
return NotFound();
return View(memoryByOwnedMachine);
}
// POST: Admin/MemoryByOwnedMachines/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
MemoryByOwnedMachine memoryByOwnedMachine = await _context.MemoryByOwnedMachine.FindAsync(id);
_context.MemoryByOwnedMachine.Remove(memoryByOwnedMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool MemoryByOwnedMachineExists(long id)
{
return _context.MemoryByOwnedMachine.Any(e => e.Id == id);
}
bool MemoryByOwnedMachineExists(long id) => _context.MemoryByOwnedMachine.Any(e => e.Id == id);
}
}

View File

@@ -37,16 +37,12 @@ using Microsoft.EntityFrameworkCore;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class NewsController : Controller
{
readonly MarechaiContext _context;
public NewsController(MarechaiContext context)
{
_context = context;
}
public NewsController(MarechaiContext context) => _context = context;
// GET: Admin/News
public async Task<IActionResult> Index() =>
@@ -55,29 +51,28 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/News/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
News news = await _context.News.FirstOrDefaultAsync(m => m.Id == id);
if(news == null) return NotFound();
if(news == null)
return NotFound();
return View(news);
}
// POST: Admin/News/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
News news = await _context.News.FindAsync(id);
_context.News.Remove(news);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool NewsExists(int id)
{
return _context.News.Any(e => e.Id == id);
}
bool NewsExists(int id) => _context.News.Any(e => e.Id == id);
}
}

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -9,33 +9,28 @@ using Microsoft.EntityFrameworkCore;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class OwnedMachineController : Controller
{
readonly MarechaiContext _context;
public OwnedMachineController(MarechaiContext context)
{
_context = context;
}
public OwnedMachineController(MarechaiContext context) => _context = context;
// GET: OwnedMachine
public async Task<IActionResult> Index()
{
IQueryable<OwnedMachineViewModel> marechaiContext = _context
.OwnedMachines.Include(o => o.Machine)
.OrderBy(o => o.Machine.Company.Name)
.ThenBy(o => o.Machine.Name).ThenBy(o => o.User.UserName)
.ThenBy(o => o.AcquisitionDate)
.Select(o => new OwnedMachineViewModel
IQueryable<OwnedMachineViewModel> marechaiContext = _context.
OwnedMachines.Include(o => o.Machine).
OrderBy(o => o.Machine.Company.Name).
ThenBy(o => o.Machine.Name).
ThenBy(o => o.User.UserName).
ThenBy(o => o.AcquisitionDate).
Select(o => new OwnedMachineViewModel
{
AcquisitionDate = o.AcquisitionDate,
Id = o.Id,
AcquisitionDate = o.AcquisitionDate, Id = o.Id,
Machine =
$"{o.Machine.Company.Name} {o.Machine.Name}",
Status = o.Status,
User = o.User.UserName
Status = o.Status, User = o.User.UserName
});
return View(await marechaiContext.ToListAsync());
@@ -44,27 +39,23 @@ namespace Marechai.Areas.Admin.Controllers
// GET: OwnedMachine/Details/5
public async Task<IActionResult> Details(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
OwnedMachineViewModel ownedMachine = await _context.OwnedMachines
.Include(o => o.Machine)
.Select(o => new OwnedMachineViewModel
OwnedMachineViewModel ownedMachine =
await _context.OwnedMachines.Include(o => o.Machine).Select(o => new OwnedMachineViewModel
{
AcquisitionDate = o.AcquisitionDate,
Boxed = o.Boxed,
AcquisitionDate = o.AcquisitionDate, Boxed = o.Boxed,
LastStatusDate = o.LastStatusDate,
LostDate = o.LostDate,
Machine =
$"{o.Machine.Company.Name} {o.Machine.Name}",
Manuals = o.Manuals,
SerialNumber = o.SerialNumber,
SerialNumberVisible =
o.SerialNumberVisible,
Machine = $"{o.Machine.Company.Name} {o.Machine.Name}", Manuals = o.Manuals,
SerialNumber = o.SerialNumber, SerialNumberVisible = o.SerialNumberVisible,
Status = o.Status,
User = o.User.UserName,
Id = o.Id
User = o.User.UserName, Id = o.Id
}).FirstOrDefaultAsync(m => m.Id == id);
if(ownedMachine == null) return NotFound();
if(ownedMachine == null)
return NotFound();
return View(ownedMachine);
}
@@ -72,73 +63,87 @@ namespace Marechai.Areas.Admin.Controllers
// GET: OwnedMachine/Create
public IActionResult Create()
{
ViewData["MachineId"] =
new
SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new {m.Id, Name = $"{m.Company.Name} {m.Name}"}),
"Id", "Name");
ViewData["UserId"] =
new SelectList(_context.Users.OrderBy(u => u.UserName).Select(u => new {u.Id, u.UserName}), "Id",
"UserName");
ViewData["MachineId"] = new SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
Select(m => new
{
m.Id, Name = $"{m.Company.Name} {m.Name}"
}), "Id", "Name");
ViewData["UserId"] = new SelectList(_context.Users.OrderBy(u => u.UserName).Select(u => new
{
u.Id, u.UserName
}), "Id", "UserName");
return View();
}
// POST: OwnedMachine/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create(
[Bind(
"AcquisitionDate,LostDate,Status,LastStatusDate,Trade,Boxed,Manuals,SerialNumber,SerialNumberVisible,MachineId,UserId,Id")]
[Bind("AcquisitionDate,LostDate,Status,LastStatusDate,Trade,Boxed,Manuals,SerialNumber,SerialNumberVisible,MachineId,UserId,Id")]
OwnedMachine ownedMachine)
{
if(ModelState.IsValid)
{
_context.Add(ownedMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["MachineId"] =
new
SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new {m.Id, Name = $"{m.Company.Name} {m.Name}"}),
"Id", "Name");
ViewData["UserId"] =
new SelectList(_context.Users.OrderBy(u => u.UserName).Select(u => new {u.Id, u.UserName}), "Id",
"UserName");
ViewData["MachineId"] = new SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
Select(m => new
{
m.Id, Name = $"{m.Company.Name} {m.Name}"
}), "Id", "Name");
ViewData["UserId"] = new SelectList(_context.Users.OrderBy(u => u.UserName).Select(u => new
{
u.Id, u.UserName
}), "Id", "UserName");
return View(ownedMachine);
}
// GET: OwnedMachine/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
OwnedMachine ownedMachine = await _context.OwnedMachines.FindAsync(id);
if(ownedMachine == null) return NotFound();
ViewData["MachineId"] =
new
SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new {m.Id, Name = $"{m.Company.Name} {m.Name}"}),
"Id", "Name");
ViewData["UserId"] =
new
SelectList(_context.Users.OrderBy(u => u.UserName).Where(u => u.Id == ownedMachine.UserId).Select(u => new {u.Id, u.UserName}),
"Id", "UserName");
if(ownedMachine == null)
return NotFound();
ViewData["MachineId"] = new SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
Select(m => new
{
m.Id, Name = $"{m.Company.Name} {m.Name}"
}), "Id", "Name");
ViewData["UserId"] = new SelectList(_context.Users.OrderBy(u => u.UserName).
Where(u => u.Id == ownedMachine.UserId).Select(u => new
{
u.Id, u.UserName
}), "Id", "UserName");
return View(ownedMachine);
}
// POST: OwnedMachine/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
long id, [Bind(
"AcquisitionDate,LostDate,Status,LastStatusDate,Trade,Boxed,Manuals,SerialNumber,SerialNumberVisible,MachineId,Id")]
long id,
[Bind("AcquisitionDate,LostDate,Status,LastStatusDate,Trade,Boxed,Manuals,SerialNumber,SerialNumberVisible,MachineId,Id")]
OwnedMachine ownedMachine)
{
if(id != ownedMachine.Id) return NotFound();
if(id != ownedMachine.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -149,7 +154,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!OwnedMachineExists(ownedMachine.Id)) return NotFound();
if(!OwnedMachineExists(ownedMachine.Id))
return NotFound();
throw;
}
@@ -157,60 +163,56 @@ namespace Marechai.Areas.Admin.Controllers
return RedirectToAction(nameof(Index));
}
ViewData["MachineId"] =
new
SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).Select(m => new {m.Id, Name = $"{m.Company.Name} {m.Name}"}),
"Id", "Name");
ViewData["UserId"] =
new
SelectList(_context.Users.OrderBy(u => u.UserName).Where(u => u.Id == ownedMachine.UserId).Select(u => new {u.Id, u.UserName}),
"Id", "UserName");
ViewData["MachineId"] = new SelectList(_context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).
Select(m => new
{
m.Id, Name = $"{m.Company.Name} {m.Name}"
}), "Id", "Name");
ViewData["UserId"] = new SelectList(_context.Users.OrderBy(u => u.UserName).
Where(u => u.Id == ownedMachine.UserId).Select(u => new
{
u.Id, u.UserName
}), "Id", "UserName");
return View(ownedMachine);
}
// GET: OwnedMachine/Delete/5
public async Task<IActionResult> Delete(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
OwnedMachineViewModel ownedMachine = await _context.OwnedMachines
.Include(o => o.Machine)
.Select(o => new OwnedMachineViewModel
OwnedMachineViewModel ownedMachine =
await _context.OwnedMachines.Include(o => o.Machine).Select(o => new OwnedMachineViewModel
{
AcquisitionDate = o.AcquisitionDate,
Boxed = o.Boxed,
AcquisitionDate = o.AcquisitionDate, Boxed = o.Boxed,
LastStatusDate = o.LastStatusDate,
LostDate = o.LostDate,
Machine =
$"{o.Machine.Company.Name} {o.Machine.Name}",
Manuals = o.Manuals,
SerialNumber = o.SerialNumber,
SerialNumberVisible =
o.SerialNumberVisible,
Machine = $"{o.Machine.Company.Name} {o.Machine.Name}", Manuals = o.Manuals,
SerialNumber = o.SerialNumber, SerialNumberVisible = o.SerialNumberVisible,
Status = o.Status,
User = o.User.UserName,
Id = o.Id
User = o.User.UserName, Id = o.Id
}).FirstOrDefaultAsync(m => m.Id == id);
if(ownedMachine == null) return NotFound();
if(ownedMachine == null)
return NotFound();
return View(ownedMachine);
}
// POST: OwnedMachine/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
OwnedMachine ownedMachine = await _context.OwnedMachines.FindAsync(id);
_context.OwnedMachines.Remove(ownedMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool OwnedMachineExists(long id)
{
return _context.OwnedMachines.Any(e => e.Id == id);
}
bool OwnedMachineExists(long id) => _context.OwnedMachines.Any(e => e.Id == id);
}
}

View File

@@ -9,31 +9,32 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class PeopleController : Controller
{
readonly MarechaiContext _context;
public PeopleController(MarechaiContext context)
{
_context = context;
}
public PeopleController(MarechaiContext context) => _context = context;
// GET: People
public async Task<IActionResult> Index()
{
IIncludableQueryable<Person, Iso31661Numeric> marechaiContext = _context.People.Include(p => p.CountryOfBirth);
IIncludableQueryable<Person, Iso31661Numeric> marechaiContext =
_context.People.Include(p => p.CountryOfBirth);
return View(await marechaiContext.OrderBy(p => p.FullName).ToListAsync());
}
// GET: People/Details/5
public async Task<IActionResult> Details(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Person person = await _context.People.Include(p => p.CountryOfBirth).FirstOrDefaultAsync(m => m.Id == id);
if(person == null) return NotFound();
if(person == null)
return NotFound();
return View(person);
}
@@ -42,55 +43,60 @@ namespace Marechai.Areas.Admin.Controllers
public IActionResult Create()
{
ViewData["CountryOfBirthId"] = new SelectList(_context.Iso31661Numeric, "Id", "Name");
return View();
}
// POST: People/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create(
[Bind(
"Name,Surname,BirthDate,DeathDate,Webpage,Twitter,Facebook,Photo,CountryOfBirthId,Id,Alias,DisplayName")]
[Bind("Name,Surname,BirthDate,DeathDate,Webpage,Twitter,Facebook,Photo,CountryOfBirthId,Id,Alias,DisplayName")]
Person person)
{
if(ModelState.IsValid)
{
_context.Add(person);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["CountryOfBirthId"] =
new SelectList(_context.Iso31661Numeric, "Id", "Name", person.CountryOfBirthId);
return View(person);
}
// GET: People/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Person person = await _context.People.FindAsync(id);
if(person == null) return NotFound();
if(person == null)
return NotFound();
ViewData["CountryOfBirthId"] =
new SelectList(_context.Iso31661Numeric, "Id", "Name", person.CountryOfBirthId);
return View(person);
}
// POST: People/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(
int id, [Bind(
"Name,Surname,BirthDate,DeathDate,Webpage,Twitter,Facebook,Photo,CountryOfBirthId,Id,Alias,DisplayName")]
int id,
[Bind("Name,Surname,BirthDate,DeathDate,Webpage,Twitter,Facebook,Photo,CountryOfBirthId,Id,Alias,DisplayName")]
Person person)
{
if(id != person.Id) return NotFound();
if(id != person.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -101,7 +107,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!PersonExists(person.Id)) return NotFound();
if(!PersonExists(person.Id))
return NotFound();
throw;
}
@@ -111,36 +118,36 @@ namespace Marechai.Areas.Admin.Controllers
ViewData["CountryOfBirthId"] =
new SelectList(_context.Iso31661Numeric, "Id", "Name", person.CountryOfBirthId);
return View(person);
}
// GET: People/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
Person person = await _context.People.Include(p => p.CountryOfBirth).FirstOrDefaultAsync(m => m.Id == id);
if(person == null) return NotFound();
if(person == null)
return NotFound();
return View(person);
}
// POST: People/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
Person person = await _context.People.FindAsync(id);
_context.People.Remove(person);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool PersonExists(int id)
{
return _context.People.Any(e => e.Id == id);
}
bool PersonExists(int id) => _context.People.Any(e => e.Id == id);
[AcceptVerbs("Get", "Post")]
public IActionResult VerifyTwitter(string twitter) =>

View File

@@ -30,8 +30,8 @@
using System.Linq;
using System.Threading.Tasks;
using Marechai.Database.Models;
using Marechai.Areas.Admin.Models;
using Marechai.Database.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -40,28 +40,23 @@ using Microsoft.EntityFrameworkCore.Query;
namespace Marechai.Areas.Admin.Controllers
{
[Area("Admin")]
[Authorize]
[Area("Admin"), Authorize]
public class ProcessorsByMachinesController : Controller
{
readonly MarechaiContext _context;
public ProcessorsByMachinesController(MarechaiContext context)
{
_context = context;
}
public ProcessorsByMachinesController(MarechaiContext context) => _context = context;
// GET: Admin/ProcessorsByMachines
public async Task<IActionResult> Index()
{
IIncludableQueryable<ProcessorsByMachine, Processor> marechaiContext =
_context.ProcessorsByMachine.Include(p => p.Machine).Include(p => p.Processor);
return View(await marechaiContext.OrderBy(p => p.Machine.Name).ThenBy(p => p.Processor.Name)
.Select(p => new ProcessorsByMachineViewModel
return View(await marechaiContext.OrderBy(p => p.Machine.Name).ThenBy(p => p.Processor.Name).
Select(p => new ProcessorsByMachineViewModel
{
Id = p.Id,
Machine = p.Machine.Name,
Processor = p.Processor.Name,
Id = p.Id, Machine = p.Machine.Name, Processor = p.Processor.Name,
Speed = p.Speed
}).ToListAsync());
}
@@ -69,12 +64,15 @@ namespace Marechai.Areas.Admin.Controllers
// GET: Admin/ProcessorsByMachines/Details/5
public async Task<IActionResult> Details(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
ProcessorsByMachine processorsByMachine =
await _context.ProcessorsByMachine.Include(p => p.Machine).Include(p => p.Processor)
.FirstOrDefaultAsync(m => m.Id == id);
if(processorsByMachine == null) return NotFound();
await _context.ProcessorsByMachine.Include(p => p.Machine).Include(p => p.Processor).
FirstOrDefaultAsync(m => m.Id == id);
if(processorsByMachine == null)
return NotFound();
return View(processorsByMachine);
}
@@ -84,14 +82,14 @@ namespace Marechai.Areas.Admin.Controllers
{
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name");
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name");
return View();
}
// POST: Admin/ProcessorsByMachines/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("ProcessorId,MachineId,Speed,Id")]
ProcessorsByMachine processorsByMachine)
{
@@ -99,38 +97,46 @@ namespace Marechai.Areas.Admin.Controllers
{
_context.Add(processorsByMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", processorsByMachine.MachineId);
ViewData["ProcessorId"] =
new SelectList(_context.Processors, "Id", "Name", processorsByMachine.ProcessorId);
return View(processorsByMachine);
}
// GET: Admin/ProcessorsByMachines/Edit/5
public async Task<IActionResult> Edit(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
ProcessorsByMachine processorsByMachine = await _context.ProcessorsByMachine.FindAsync(id);
if(processorsByMachine == null) return NotFound();
if(processorsByMachine == null)
return NotFound();
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", processorsByMachine.MachineId);
ViewData["ProcessorId"] =
new SelectList(_context.Processors, "Id", "Name", processorsByMachine.ProcessorId);
return View(processorsByMachine);
}
// POST: Admin/ProcessorsByMachines/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
[HttpPost, ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(long id, [Bind("ProcessorId,MachineId,Speed,Id")]
ProcessorsByMachine processorsByMachine)
{
if(id != processorsByMachine.Id) return NotFound();
if(id != processorsByMachine.Id)
return NotFound();
if(ModelState.IsValid)
{
@@ -141,7 +147,8 @@ namespace Marechai.Areas.Admin.Controllers
}
catch(DbUpdateConcurrencyException)
{
if(!ProcessorsByMachineExists(processorsByMachine.Id)) return NotFound();
if(!ProcessorsByMachineExists(processorsByMachine.Id))
return NotFound();
throw;
}
@@ -150,39 +157,40 @@ namespace Marechai.Areas.Admin.Controllers
}
ViewData["MachineId"] = new SelectList(_context.Machines, "Id", "Name", processorsByMachine.MachineId);
ViewData["ProcessorId"] =
new SelectList(_context.Processors, "Id", "Name", processorsByMachine.ProcessorId);
return View(processorsByMachine);
}
// GET: Admin/ProcessorsByMachines/Delete/5
public async Task<IActionResult> Delete(long? id)
{
if(id == null) return NotFound();
if(id == null)
return NotFound();
ProcessorsByMachine processorsByMachine =
await _context.ProcessorsByMachine.Include(p => p.Machine).Include(p => p.Processor)
.FirstOrDefaultAsync(m => m.Id == id);
if(processorsByMachine == null) return NotFound();
await _context.ProcessorsByMachine.Include(p => p.Machine).Include(p => p.Processor).
FirstOrDefaultAsync(m => m.Id == id);
if(processorsByMachine == null)
return NotFound();
return View(processorsByMachine);
}
// POST: Admin/ProcessorsByMachines/Delete/5
[HttpPost]
[ActionName("Delete")]
[ValidateAntiForgeryToken]
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(long id)
{
ProcessorsByMachine processorsByMachine = await _context.ProcessorsByMachine.FindAsync(id);
_context.ProcessorsByMachine.Remove(processorsByMachine);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
bool ProcessorsByMachineExists(long id)
{
return _context.ProcessorsByMachine.Any(e => e.Id == id);
}
bool ProcessorsByMachineExists(long id) => _context.ProcessorsByMachine.Any(e => e.Id == id);
}
}

Some files were not shown because too many files have changed in this diff Show More